diff --git a/DEVELOPERS b/DEVELOPERS index 0a6d4e455e..cbca07f9fa 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -159,6 +159,8 @@ F: package/libxmlsec1/ F: package/openscap/ F: package/python-scp/ F: support/testing/tests/package/test_libldns.py +F: support/testing/tests/package/test_openscap/ +F: support/testing/tests/package/test_openscap.py F: support/testing/tests/package/test_python_scp.py N: Alistair Francis diff --git a/support/testing/tests/package/test_openscap.py b/support/testing/tests/package/test_openscap.py new file mode 100644 index 0000000000..08527d28aa --- /dev/null +++ b/support/testing/tests/package/test_openscap.py @@ -0,0 +1,63 @@ +import os + +import infra.basetest + + +class TestOpenSCAPBase(infra.basetest.BRTest): + config = """ + BR2_arm=y + BR2_cortex_a8=y + BR2_ARM_EABIHF=y + BR2_TOOLCHAIN_EXTERNAL=y + BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y + BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV7_EABIHF_GLIBC_STABLE=y + BR2_PACKAGE_OPENSCAP=y + BR2_ROOTFS_OVERLAY="{}" + BR2_TARGET_ROOTFS_CPIO=y + # BR2_TARGET_ROOTFS_TAR is not set + """.format( + infra.filepath("tests/package/test_openscap/rootfs-overlay")) + + def test_run(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot( + arch="armv7", + kernel="builtin", + options=["-m", "512M", "-initrd", cpio_file], + ) + self.emulator.login() + + out, ret = self.emulator.run("oscap --version") + self.assertEqual(ret, 0) + + out, ret = self.emulator.run("oscap info /root/benchmark.xml") + self.assertEqual(ret, 0) + self.assertIn("Document type: XCCDF Checklist", "\n".join(out)) + + +class TestOpenSCAPGcrypt(TestOpenSCAPBase): + """Test openscap using the gcrypt crypto backend.""" + + config = ( + TestOpenSCAPBase.config + + """ + BR2_PACKAGE_LIBGCRYPT=y + """ + ) + + +class TestOpenSCAPNss(TestOpenSCAPBase): + """Test openscap using the nss crypto backend.""" + + config = ( + TestOpenSCAPBase.config + + """ + BR2_PACKAGE_LIBNSS=y + """ + ) + + +class TestOpenSCAPNoCrypto(TestOpenSCAPBase): + """Test openscap without any crypto backend.""" + + config = TestOpenSCAPBase.config diff --git a/support/testing/tests/package/test_openscap/rootfs-overlay/root/benchmark.xml b/support/testing/tests/package/test_openscap/rootfs-overlay/root/benchmark.xml new file mode 100644 index 0000000000..aac0f1e0fa --- /dev/null +++ b/support/testing/tests/package/test_openscap/rootfs-overlay/root/benchmark.xml @@ -0,0 +1,5 @@ + + + accepted + 1.0 +