From: Prarit Bhargava <prarit(a)redhat.com>
redhat/self-test: Cleanup SRPM related self-tests
The self-tests fail messily and loudly when a single SRPM is not
present in the directory. Fix these tests to skip instead of loudly
failing.
[Aside: I could have added a call to dist-srpm in the dist-self-test
target, however, that could result in overwriting an existing SRPM on the
users' system.]
Signed-off-by: Prarit Bhargava <prarit(a)redhat.com>
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats
index blahblah..blahblah 100644
--- a/redhat/self-test/1001-rpmlint.bats
+++ b/redhat/self-test/1001-rpmlint.bats
@@ -1,9 +1,4 @@
#!/usr/bin/env bats
-@test "Exactly one SRPM exists" {
- result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l)
- [ "$result" = 1 ]
-}
-
@test "rpmlint" {
if ! test -x /usr/bin/rpmlint
then
@@ -11,7 +6,14 @@
else
skip "Skip rpmlint test pending kernel.spec.template changes"
fi
+
+ numsrpms=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l)
+ if [ "$numsrpms" != "1" ]; then
+ skip "Only one SRPM should be in $BATS_TEST_DIRNAME/redhat/rpms/SRPMS."
+ fi
+
srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm")
run rpmlint $srpm
+ status=$?
[ "$status" = 0 ]
}
diff --git a/redhat/self-test/1002-basic-structural-test.bats
b/redhat/self-test/1002-basic-structural-test.bats
index blahblah..blahblah 100644
--- a/redhat/self-test/1002-basic-structural-test.bats
+++ b/redhat/self-test/1002-basic-structural-test.bats
@@ -1,6 +1,10 @@
#!/usr/bin/env bats
@test "SRPM unpacks OK" {
- result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l)
+ numsrpms=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l)
+ if [ "$numsrpms" != "1" ]; then
+ skip "Only one SRPM should be in $BATS_TEST_DIRNAME/redhat/rpms/SRPMS."
+ fi
+
srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm")
pushd "$BATS_TMPDIR"
if [ -e SRPMS ]
@@ -16,6 +20,11 @@
}
@test "Linux tree unpacks OK" {
+ numsrpms=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l)
+ if [ "$numsrpms" != "1" ]; then
+ skip "Only one SRPM should be in $BATS_TEST_DIRNAME/redhat/rpms/SRPMS."
+ fi
+
pushd "$BATS_TMPDIR"/SRPMS >& /dev/null
ls | wc
linuxname=$(ls linux*.tar.xz)
@@ -25,6 +34,11 @@
}
@test "Linux top level structural check" {
+ numsrpms=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l)
+ if [ "$numsrpms" != "1" ]; then
+ skip "Only one SRPM should be in $BATS_TEST_DIRNAME/redhat/rpms/SRPMS."
+ fi
+
pushd "$BATS_TMPDIR"/SRPMS >& /dev/null
linuxtree=$(ls linux*.tar.xz)
linuxtree=${linuxtree/.tar.xz}
diff --git a/redhat/self-test/1003-rpminspect.bats
b/redhat/self-test/1003-rpminspect.bats
index blahblah..blahblah 100644
--- a/redhat/self-test/1003-rpminspect.bats
+++ b/redhat/self-test/1003-rpminspect.bats
@@ -1,9 +1,4 @@
#!/usr/bin/env bats
-@test "Exactly one SRPM exists" {
- result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l)
- [ "$result" = 1 ]
-}
-
@test "rpminspect" {
if ! test -x /usr/bin/rpminspect
then
@@ -11,6 +6,12 @@
else
skip "Skip rpminspect test pending fixes"
fi
+
+ numsrpms=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l)
+ if [ "$numsrpms" != "1" ]; then
+ skip "Only one SRPM should be in $BATS_TEST_DIRNAME/redhat/rpms/SRPMS."
+ fi
+
srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm")
run rpminspect $srpm
[ "$status" = 0 ]
--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1642