Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some tests #91

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/it/test1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<goal>rpm</goal>
</goals>
<configuration>
<outputFileName>test1.rpm</outputFileName>
<attach>false</attach>
<group>Application/Misc</group>

Expand Down
7 changes: 3 additions & 4 deletions src/it/test1/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
def pb = new ProcessBuilder ( "bash", "-c", "rpm -qlvvp target/*.rpm" );
def pb = new ProcessBuilder ( "bash", "-c", "rpm -qlvvp target/test1.rpm" );
pb.directory ( basedir );
pb.inheritIO ();
pb.start ().waitFor();

return true;
return ( pb.start ().waitFor () == 0 );
1 change: 1 addition & 0 deletions src/it/test13-skipentry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<goal>rpm</goal>
</goals>
<configuration>
<outputFileName>test13.rpm</outputFileName>
<attach>false</attach>
<group>Application/Misc</group>

Expand Down
7 changes: 3 additions & 4 deletions src/it/test13-skipentry/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
def pb = new ProcessBuilder ( "bash", "-c", "rpm -qlvvp target/*.rpm" );
def pb = new ProcessBuilder ( "bash", "-c", "rpm -qlvvp target/test13.rpm" );
pb.directory ( basedir )
pb.inheritIO ();
pb.start ().waitFor();

return true;
return ( pb.start ().waitFor () == 0 );
6 changes: 4 additions & 2 deletions src/it/test17-reproducible-date/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
def generateMD5(File file) {
def digest = java.security.MessageDigest.getInstance("MD5")
import java.security.MessageDigest

def static generateMD5(File file) {
def digest = MessageDigest.getInstance("MD5")
file.eachByte(4096) { buffer, length ->
digest.update(buffer, 0, length)
}
Expand Down
6 changes: 4 additions & 2 deletions src/it/test17-reproducible-epoch/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
def generateMD5(File file) {
def digest = java.security.MessageDigest.getInstance("MD5")
import java.security.MessageDigest

def static generateMD5(File file) {
def digest = MessageDigest.getInstance("MD5")
file.eachByte(4096) { buffer, length ->
digest.update(buffer, 0, length)
}
Expand Down
1 change: 1 addition & 0 deletions src/it/test18-file-digest-default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<goal>rpm</goal>
</goals>
<configuration>
<outputFileName>test18.rpm</outputFileName>
<group>Application/Misc</group>

<forceRelease>false</forceRelease>
Expand Down
2 changes: 1 addition & 1 deletion src/it/test18-file-digest-default/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def dump ( ) {
Process proc = ('rpm -q --dump -p ' + basedir + "/target/test18.rpm").execute()
Process proc = ('rpm -q --dump -p ' + basedir.toString().replace(File.separator, "/") + "/target/test18.rpm").execute()
return proc.in.getText().trim()
}

Expand Down
2 changes: 1 addition & 1 deletion src/it/test18-file-digest-md5/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def dump ( ) {
Process proc = ('rpm -q --dump -p ' + basedir + "/target/test18.rpm").execute()
Process proc = ('rpm -q --dump -p ' + basedir.toString().replace(File.separator, "/") + "/target/test18.rpm").execute()
return proc.in.getText().trim()
}

Expand Down
1 change: 1 addition & 0 deletions src/it/test19-intermediate-directories-collect/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<goal>rpm</goal>
</goals>
<configuration>
<outputFileName>test19.rpm</outputFileName>
<attach>false</attach>
<group>Application/Misc</group>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def verifyFileInodes() {
Process proc = ['rpm', '-q', '--queryformat', '[%{FILEINODES} %{FILEMODES:perms} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\n]', basedir.path + '/target/*.rpm'].execute() | 'sort -n'.execute()
Process proc = ['rpm', '-q', '--queryformat', '[%{FILEINODES} %{FILEMODES:perms} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\n]', basedir.toString().replace(File.separator, "/") + '/target/test19.rpm'].execute()
proc.waitFor()
return proc.in.getText().trim()
}
Expand Down
1 change: 1 addition & 0 deletions src/it/test19-intermediate-directories/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<goal>rpm</goal>
</goals>
<configuration>
<outputFileName>test19.rpm</outputFileName>
<attach>false</attach>
<group>Application/Misc</group>

Expand Down
6 changes: 3 additions & 3 deletions src/it/test19-intermediate-directories/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def verifyFileInodes() {
Process proc = ['rpm', '-q', '--queryformat', '[%{FILEINODES} %{FILEMODES:perms} %-13{FILEUSERNAME} %-14{FILEGROUPNAME} %{FILENAMES}\n]', basedir.path + '/target/*.rpm'].execute() | 'sort -n'.execute()
Process proc = ['rpm', '-q', '--queryformat', '[%{FILEINODES} %{FILEMODES:perms} %-13{FILEUSERNAME} %-14{FILEGROUPNAME} %{FILENAMES}\n]', basedir.toString().replace(File.separator, "/") + '/target/test19.rpm'].execute()
proc.waitFor()
return proc.in.getText().trim()
return proc.in.getText().split().sort()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the sort order seems important here, we should not change this.

Copy link
Collaborator Author

@dwalluck dwalluck Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should just be a "better" way of keeping the same behavior as before.

I removed the call to sort -n (which only works in a shell) and replaced it with pure Groovy split().sort().

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this pull request currently causes some test failures, but this one passes.

I think that the test failures are correct now and show some issues with the packager code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, I missed that.

}

def actual = verifyFileInodes()
Expand All @@ -15,7 +15,7 @@ def expected = """\
5 -r-xr-xr-x myuser mygroup /opt/mycompany/myapp/a/b/c/foobar
6 drwxr-xr-x root root /etc/mycompany/myapp
7 drwxr-xr-x root root /etc/mycompany/myapp/defaults
8 ---x--x--x mygeneraluser mygeneralgroup /opt/mycompany/otherapp/a/b/c/foobar""".stripIndent()
8 ---x--x--x mygeneraluser mygeneralgroup /opt/mycompany/otherapp/a/b/c/foobar""".stripIndent().split().sort()

if (actual != expected) {
System.out.format("RPM file inodes doesn't match - actual:%n%s%nexpected:%n%s%n", actual, expected);
Expand Down
1 change: 1 addition & 0 deletions src/it/test2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<goal>rpm</goal>
</goals>
<configuration>
<outputFileName>test2.rpm</outputFileName>
<attach>false</attach>
<group>Application/Misc</group>

Expand Down
7 changes: 3 additions & 4 deletions src/it/test2/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
def pb = new ProcessBuilder ( "bash", "-c", "rpm -qlvvp target/*.rpm" );
def pb = new ProcessBuilder ( "bash", "-c", "rpm -qlvvp target/test2.rpm" );
pb.directory ( basedir );
pb.inheritIO ();
pb.start ().waitFor();

return true;
return ( pb.start ().waitFor () == 0 );
1 change: 1 addition & 0 deletions src/it/test3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<goal>rpm</goal>
</goals>
<configuration>
<outputFileName>test3.rpm</outputFileName>
<attach>false</attach>
<group>Application/Misc</group>

Expand Down
7 changes: 3 additions & 4 deletions src/it/test3/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
def pb = new ProcessBuilder ( "bash", "-c", "rpm -qlvvp target/*.rpm" );
def pb = new ProcessBuilder ( "bash", "-c", "rpm -qlvvp target/test3.rpm" );
pb.directory ( basedir )
pb.inheritIO ();
pb.start ().waitFor();

return true;
return ( pb.start ().waitFor () == 0 );
21 changes: 13 additions & 8 deletions src/it/test6-scanner/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@ import org.slf4j.LoggerFactory;

final Logger logger = LoggerFactory.getLogger("test6-scanner verify");

Process rpm = ("rpm -qp --fileclass " + basedir + "/target/test6.rpm").execute();
Process rpm = ("rpm -qp --fileclass " + basedir.toString().replace(File.separator, "/") + "/target/test6.rpm").execute();

def entries = rpm.in.readLines();

def trimmedEntries = entries.collect { it.trim().replaceAll("\\s+", " ") };

logger.info (trimmedEntries.join(", "));

return trimmedEntries.equals( [
"/usr/share/test6/a.foo",
"/usr/share/test6/include directory",
"/usr/share/test6/include/d.bar",
"/usr/share/test6/link_to_a.foo symbolic link to `a.foo'",

] );
def actual = trimmedEntries
def expected = [
"/usr/share/test6/a.foo",
"/usr/share/test6/include directory",
"/usr/share/test6/include/d.bar",
"/usr/share/test6/link_to_a.foo symbolic link to `a.foo'",
]

if (actual != expected) {
System.out.format("RPM file entries doesn't match - actual:%n%s%nexpected:%n%s%n", actual, expected);
return false;
}
7 changes: 3 additions & 4 deletions src/it/yum1/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
def pb = new ProcessBuilder ( "bash", "-c", "rpm -qlvvp target/*.rpm" );
def pb = new ProcessBuilder ( "bash", "-c", "rpm -qlvvp target/yum/packages/test1-1.0.0-0.201606241041-noarch.rpm" );
pb.directory ( basedir )
pb.inheritIO ();
pb.start ().waitFor();

return true;
return ( pb.start ().waitFor () == 0 || true ); // FIXME: This test has a known failure