summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmin Kuster <akuster808@gmail.com>2023-07-07 13:44:28 -0400
committerArmin Kuster <akuster808@gmail.com>2023-07-31 06:18:52 -0400
commit1ca654ef4fe809c642164eccc186ac9acee6b778 (patch)
treef8486ed607cafe588f6f13992b74d9842a935db6
parentef184ce03a0f442ccb9e069994eb3bc353275a78 (diff)
downloadmeta-security-1ca654ef4fe809c642164eccc186ac9acee6b778.tar.gz
scap-security-guide: enable ptest
This add the basic framework to allow the test suite to run. It takes a very long time so it my not be practical to run in some cases (days in my case). The ptest log format has not been verified. Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--recipes-compliance/scap-security-guide/files/run-ptest7
-rw-r--r--recipes-compliance/scap-security-guide/scap-security-guide_0.1.67.bb47
2 files changed, 53 insertions, 1 deletions
diff --git a/recipes-compliance/scap-security-guide/files/run-ptest b/recipes-compliance/scap-security-guide/files/run-ptest
new file mode 100644
index 0000000..e8d270f
--- /dev/null
+++ b/recipes-compliance/scap-security-guide/files/run-ptest
@@ -0,0 +1,7 @@
1#!/bin/sh
2
3export PYTHONPATH="/usr/lib/scap-security-guide/ptest/git:$PYTHONPATH"
4
5cd git/build
6
7ctest --output-on-failure -E unique-stigids
diff --git a/recipes-compliance/scap-security-guide/scap-security-guide_0.1.67.bb b/recipes-compliance/scap-security-guide/scap-security-guide_0.1.67.bb
index 6e62f22..988e48b 100644
--- a/recipes-compliance/scap-security-guide/scap-security-guide_0.1.67.bb
+++ b/recipes-compliance/scap-security-guide/scap-security-guide_0.1.67.bb
@@ -9,6 +9,7 @@ LICENSE = "BSD-3-Clause"
9SRCREV = "3a1012bc9ec2b01b3b71c6feefd3cff0f52bd64d" 9SRCREV = "3a1012bc9ec2b01b3b71c6feefd3cff0f52bd64d"
10SRC_URI = "git://github.com/ComplianceAsCode/content.git;branch=master;protocol=https \ 10SRC_URI = "git://github.com/ComplianceAsCode/content.git;branch=master;protocol=https \
11 file://run_eval.sh \ 11 file://run_eval.sh \
12 file://run-ptest \
12 file://0001-scap-security-guide-add-openembedded-distro-support.patch \ 13 file://0001-scap-security-guide-add-openembedded-distro-support.patch \
13 file://0002-scap-security-guide-Add-Poky-support.patch \ 14 file://0002-scap-security-guide-Add-Poky-support.patch \
14 " 15 "
@@ -19,7 +20,7 @@ DEPENDS = "openscap-native python3-pyyaml-native python3-jinja2-native libxml2-n
19S = "${WORKDIR}/git" 20S = "${WORKDIR}/git"
20B = "${S}/build" 21B = "${S}/build"
21 22
22inherit cmake pkgconfig python3native python3targetconfig 23inherit cmake pkgconfig python3native python3targetconfig ptest
23 24
24OECMAKE_GENERATOR = "Unix Makefiles" 25OECMAKE_GENERATOR = "Unix Makefiles"
25 26
@@ -37,8 +38,52 @@ do_install:append() {
37 install ${WORKDIR}/run_eval.sh ${D}${datadir}/openscap/. 38 install ${WORKDIR}/run_eval.sh ${D}${datadir}/openscap/.
38} 39}
39 40
41do_compile_ptest() {
42 cd ${S}/build
43 cmake ../
44 make
45}
46
47do_install_ptest() {
48
49 # remove host & work dir from tests
50 for x in $(find ${S}/build -type f) ;
51 do
52 sed -e 's#${HOSTTOOLS_DIR}/##g' \
53 -e 's#${RECIPE_SYSROOT_NATIVE}##g' \
54 -e 's#${WORKDIR}#${PTEST_PATH}#g' \
55 -e 's#/.*/xmllint#/usr/bin/xmllint#g' \
56 -e 's#/.*/oscap#/usr/bin/oscap#g' \
57 -e 's#/python3-native##g' \
58 -i ${x}
59 done
60
61 for x in $(find ${S}/build-scripts -type f) ;
62 do
63 sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' ${x}
64 done
65
66 for x in $(find ${S}/tests -type f) ;
67 do
68 sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' ${x}
69 done
70
71 for x in $(find ${S}/utils -type f) ;
72 do
73 sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' ${x}
74 done
75
76 PDIRS="apple_os build controls products shared components applications linux_os ocp-resources tests utils ssg build-scripts"
77 t=${D}/${PTEST_PATH}/git
78 for d in ${PDIRS}; do
79 install -d ${t}/$d
80 cp -fr ${S}/$d/* ${t}/$d/.
81 done
82}
83
40FILES:${PN} += "${datadir}/xml ${datadir}/openscap" 84FILES:${PN} += "${datadir}/xml ${datadir}/openscap"
41 85
42RDEPENDS:${PN} = "openscap" 86RDEPENDS:${PN} = "openscap"
87RDEPENDS:${PN}-ptest = "cmake grep sed bash git python3 python3-modules python3-mypy python3-pyyaml python3-yamlpath python3-xmldiff python3-json2html python3-pandas python3-openpyxl python3-pytest libxml2-utils libxslt-bin"
43 88
44COMPATIBLE_HOST:libc-musl = "null" 89COMPATIBLE_HOST:libc-musl = "null"