mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-10-03 07:21:45 -09:00
Add basic tests for openscap, ensuring that it builds and runs a minimal
command with different cryptographic backends:
- libgcrypt
- libnss
- no crypto backend
Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit a304c7bf12)
Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
64 lines
1.6 KiB
Python
64 lines
1.6 KiB
Python
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
|