From: Ben Crocker <[email protected]>

1001-rpmlint.bats
- tests for exactly one SRPM
- runs rpmlint on that SRPM

1002-basic-structural-test.bats
- tests whether SRPM unpacks OK
- tests whether Linux tree unpacks OK
- runs top-level structural check on Linux tree

Nothing is hooked up yet.

Signed-off-by: Ben Crocker <[email protected]>
---
 redhat/self-test/1001-rpmlint.bats            | 11 ++++
 .../self-test/1002-basic-structural-test.bats | 57 +++++++++++++++++++
 redhat/self-test/Makefile                     |  8 +++
 3 files changed, 76 insertions(+)
 create mode 100644 redhat/self-test/1001-rpmlint.bats
 create mode 100644 redhat/self-test/1002-basic-structural-test.bats
 create mode 100644 redhat/self-test/Makefile

diff --git a/redhat/self-test/1001-rpmlint.bats 
b/redhat/self-test/1001-rpmlint.bats
new file mode 100644
index 000000000000..bd0d8d1bcc24
--- /dev/null
+++ b/redhat/self-test/1001-rpmlint.bats
@@ -0,0 +1,11 @@
+#!/usr/bin/env bats
+@test "Exactly one SRPM exists" {
+    result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l)
+    [ "$result" = 1 ]
+}
+
+@test "rpmlint" {
+      srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm")
+      run rpmlint $srpm
+      [ "$status" = 0 ]
+}
diff --git a/redhat/self-test/1002-basic-structural-test.bats 
b/redhat/self-test/1002-basic-structural-test.bats
new file mode 100644
index 000000000000..292e1b90e9d9
--- /dev/null
+++ b/redhat/self-test/1002-basic-structural-test.bats
@@ -0,0 +1,57 @@
+#!/usr/bin/env bats
+@test "SRPM unpacks OK" {
+    result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l)
+    srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm")
+    pushd "$BATS_TMPDIR"
+    if [ -e SRPMS ]
+    then
+        rm -fr SRPMS
+    fi
+    mkdir SRPMS
+    cd SRPMS
+    rpm2cpio "$srpm" | cpio -idm
+    status=$?
+    [ "$status" = 0 ]
+    popd >& /dev/null
+}
+
+@test "Linux tree unpacks OK" {
+    pushd "$BATS_TMPDIR"/SRPMS >& /dev/null
+    ls | wc
+    linuxname=$(ls linux*.tar.xz)
+    run tar --extract --xz -f "$linuxname"
+    [ "$status" = 0 ]
+    popd >& /dev/null
+}
+
+@test "Linux top level structural check" {
+    pushd "$BATS_TMPDIR"/SRPMS >& /dev/null
+    linuxtree=$(ls linux*.tar.xz)
+    linuxtree=${linuxtree/.tar.xz}
+    cd $linuxtree
+    test -d arch       && \
+    test -d block      && \
+    test -d certs      && \
+    test -d crypto     && \
+    test -d Documentation      && \
+    test -d drivers    && \
+    test -d fs         && \
+    test -d include    && \
+    test -d init       && \
+    test -d ipc                && \
+    test -d kernel     && \
+    test -d lib
+    test -d LICENSES   && \
+    test -d mm         && \
+    test -d net                && \
+    test -d samples    && \
+    test -d scripts    && \
+    test -d security   && \
+    test -d sound      && \
+    test -d tools      && \
+    test -d usr                && \
+    test -d virt
+    status=$?
+    popd >& /dev/null
+    [ "$status" = 0 ]
+}
diff --git a/redhat/self-test/Makefile b/redhat/self-test/Makefile
new file mode 100644
index 000000000000..b5fee9492a7d
--- /dev/null
+++ b/redhat/self-test/Makefile
@@ -0,0 +1,8 @@
+# use with 'make -I ../ debug'
+# with vars 'DIST='.eln' make -I ../ debug ' and compare expected output
+
+include ../Makefile
+
+debug:
+       @echo "SINGLE_TARBALL = $(SINGLE_TARBALL)"
+       @echo "DIST_TARGET = $(DIST_TARGET)"
-- 
GitLab
_______________________________________________
kernel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/[email protected]

Reply via email to