Fix failing tests
- fix test tests/API/XCCDF/unittests/test_profile_selection_by_suffix.sh from upstream test suite (runs as a part of smoke test) - oval/yamlfilecontent: Add 'null' values handling Resolves: RHBZ#1952789
This commit is contained in:
parent
96f558718c
commit
71d8346d4a
40
openscap-1.3.6-fix-failing-test-pr-1775.patch
Normal file
40
openscap-1.3.6-fix-failing-test-pr-1775.patch
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
From 11e5d42d279f39c13a9bdea7df6da7728b85a0b5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
|
||||||
|
Date: Tue, 29 Jun 2021 09:12:34 +0200
|
||||||
|
Subject: [PATCH] Fix failing test
|
||||||
|
|
||||||
|
The test fails becuse the OVAL content in
|
||||||
|
`test_remediation_simple.oval.xml` used in rule
|
||||||
|
`xccdf_moc.elpmaxe.www_rule_1` in
|
||||||
|
`test_profile_selection_by_suffix.xccdf.xml` expects that a file named
|
||||||
|
`test_file` exists in the current working directory.
|
||||||
|
|
||||||
|
This test doesn't fail when executed as a part of complete test suite
|
||||||
|
run. I guess that it's because some other test creates the `test_file`
|
||||||
|
file and doesn't delete it. Unfortunately, I can't find which test
|
||||||
|
creates it. There are many test cases that use a file `test_file`
|
||||||
|
and it is also created often by remediation executed in some tests.
|
||||||
|
---
|
||||||
|
.../API/XCCDF/unittests/test_profile_selection_by_suffix.sh | 5 +++++
|
||||||
|
1 file changed, 5 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/tests/API/XCCDF/unittests/test_profile_selection_by_suffix.sh b/tests/API/XCCDF/unittests/test_profile_selection_by_suffix.sh
|
||||||
|
index 910264626a..9b0852df37 100755
|
||||||
|
--- a/tests/API/XCCDF/unittests/test_profile_selection_by_suffix.sh
|
||||||
|
+++ b/tests/API/XCCDF/unittests/test_profile_selection_by_suffix.sh
|
||||||
|
@@ -13,6 +13,9 @@ echo "Stderr file = $stderr"
|
||||||
|
echo "Result file = $result"
|
||||||
|
ret=0
|
||||||
|
|
||||||
|
+touch test_file
|
||||||
|
+[ -f test_file ]
|
||||||
|
+
|
||||||
|
# Multiple matches should result in failure
|
||||||
|
$OSCAP xccdf eval --profile common $benchmark 2> $stderr || ret=$?
|
||||||
|
[ $ret -eq 1 ]
|
||||||
|
@@ -55,3 +58,5 @@ grep -Fq "No profile matching suffix \"another\" was found" $stderr
|
||||||
|
|
||||||
|
[ -f $stderr ]; rm $stderr
|
||||||
|
rm $result
|
||||||
|
+
|
||||||
|
+rm -f test_file
|
150
openscap-1.3.6-yamlfile-null-pr-1756.patch
Normal file
150
openscap-1.3.6-yamlfile-null-pr-1756.patch
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
From 89f99834ba183284a7d75835932a0c0ea4eb9007 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Evgeny Kolesnikov <ekolesni@redhat.com>
|
||||||
|
Date: Mon, 17 May 2021 08:40:17 +0200
|
||||||
|
Subject: [PATCH] oval/yamlfilecontent: Add 'null' values handling
|
||||||
|
|
||||||
|
For now null values would be represented as string '(null)' as
|
||||||
|
record's field could not be attributed as nil="true" yet.
|
||||||
|
---
|
||||||
|
.../independent/yamlfilecontent_probe.c | 9 ++++
|
||||||
|
.../test_probes_yamlfilecontent_types.sh | 5 ++
|
||||||
|
.../test_probes_yamlfilecontent_types.xml | 52 +++++++++++++++++++
|
||||||
|
tests/probes/yamlfilecontent/types.yaml | 4 ++
|
||||||
|
4 files changed, 70 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/OVAL/probes/independent/yamlfilecontent_probe.c b/src/OVAL/probes/independent/yamlfilecontent_probe.c
|
||||||
|
index 62a8f4ff29..2d0cac6991 100644
|
||||||
|
--- a/src/OVAL/probes/independent/yamlfilecontent_probe.c
|
||||||
|
+++ b/src/OVAL/probes/independent/yamlfilecontent_probe.c
|
||||||
|
@@ -41,6 +41,7 @@
|
||||||
|
#define OSCAP_YAML_BOOL_TAG "tag:yaml.org,2002:bool"
|
||||||
|
#define OSCAP_YAML_FLOAT_TAG "tag:yaml.org,2002:float"
|
||||||
|
#define OSCAP_YAML_INT_TAG "tag:yaml.org,2002:int"
|
||||||
|
+#define OSCAP_YAML_NULL_TAG "tag:yaml.org,2002:null"
|
||||||
|
|
||||||
|
#define OVECCOUNT 30 /* should be a multiple of 3 */
|
||||||
|
|
||||||
|
@@ -135,6 +136,14 @@ static SEXP_t *yaml_scalar_event_to_sexp(yaml_event_t *event)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ if (question || !strcmp(tag, OSCAP_YAML_NULL_TAG)) {
|
||||||
|
+ if (match_regex("^(null|Null|NULL|~|)$", value)) {
|
||||||
|
+ // TODO: Return real NULL when record's field will support nil="true"
|
||||||
|
+ return SEXP_string_new("(null)", strlen("(null)"));
|
||||||
|
+ } else if (!question) {
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
|
return SEXP_string_new(value, strlen(value));
|
||||||
|
}
|
||||||
|
diff --git a/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.sh b/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.sh
|
||||||
|
index 4f110f6eb7..e445771d03 100755
|
||||||
|
--- a/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.sh
|
||||||
|
+++ b/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.sh
|
||||||
|
@@ -60,6 +60,11 @@ function test_probes_yamlfilecontent_types {
|
||||||
|
assert_exists 1 $sd'/ind-sys:yamlfilecontent_item/ind-sys:value/field[@name="#" and @datatype!="boolean" and text()="true"]'
|
||||||
|
# string_number
|
||||||
|
assert_exists 1 $sd'/ind-sys:yamlfilecontent_item/ind-sys:value/field[@name="#" and @datatype!="int" and text()="81"]'
|
||||||
|
+ # string_null
|
||||||
|
+ assert_exists 1 $sd'/ind-sys:yamlfilecontent_item/ind-sys:value/field[@name="#" and text()="null"]'
|
||||||
|
+
|
||||||
|
+ # null_1_2_3
|
||||||
|
+ assert_exists 3 $sd'/ind-sys:yamlfilecontent_item/ind-sys:value/field[@name="#" and text()="(null)"]'
|
||||||
|
|
||||||
|
# bool_error_cast, int_error_cast, float_error_cast
|
||||||
|
co='/oval_results/results/system/oval_system_characteristics/collected_objects'
|
||||||
|
diff --git a/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.xml b/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.xml
|
||||||
|
index adf96571b8..503ec2d4a4 100644
|
||||||
|
--- a/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.xml
|
||||||
|
+++ b/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.xml
|
||||||
|
@@ -262,6 +262,19 @@
|
||||||
|
</criteria>
|
||||||
|
</definition>
|
||||||
|
|
||||||
|
+ <definition class="compliance" version="1" id="oval:0:def:26">
|
||||||
|
+ <metadata>
|
||||||
|
+ <title></title>
|
||||||
|
+ <description></description>
|
||||||
|
+ </metadata>
|
||||||
|
+ <criteria operator="AND">
|
||||||
|
+ <criterion comment="comment" test_ref="oval:0:tst:26"/>
|
||||||
|
+ <criterion comment="comment" test_ref="oval:0:tst:27"/>
|
||||||
|
+ <criterion comment="comment" test_ref="oval:0:tst:28"/>
|
||||||
|
+ <criterion comment="comment" test_ref="oval:0:tst:29"/>
|
||||||
|
+ </criteria>
|
||||||
|
+ </definition>
|
||||||
|
+
|
||||||
|
</definitions>
|
||||||
|
|
||||||
|
<tests>
|
||||||
|
@@ -364,6 +377,21 @@
|
||||||
|
<ind-def:object object_ref="oval:0:obj:25"/>
|
||||||
|
</ind-def:yamlfilecontent_test>
|
||||||
|
|
||||||
|
+ <ind-def:yamlfilecontent_test version="1" id="oval:0:tst:26" check="all" comment="true">
|
||||||
|
+ <ind-def:object object_ref="oval:0:obj:26"/>
|
||||||
|
+ </ind-def:yamlfilecontent_test>
|
||||||
|
+
|
||||||
|
+ <ind-def:yamlfilecontent_test version="1" id="oval:0:tst:27" check="all" comment="true">
|
||||||
|
+ <ind-def:object object_ref="oval:0:obj:27"/>
|
||||||
|
+ </ind-def:yamlfilecontent_test>
|
||||||
|
+
|
||||||
|
+ <ind-def:yamlfilecontent_test version="1" id="oval:0:tst:28" check="all" comment="true">
|
||||||
|
+ <ind-def:object object_ref="oval:0:obj:28"/>
|
||||||
|
+ </ind-def:yamlfilecontent_test>
|
||||||
|
+
|
||||||
|
+ <ind-def:yamlfilecontent_test version="1" id="oval:0:tst:29" check="all" comment="true">
|
||||||
|
+ <ind-def:object object_ref="oval:0:obj:29"/>
|
||||||
|
+ </ind-def:yamlfilecontent_test>
|
||||||
|
</tests>
|
||||||
|
|
||||||
|
<objects>
|
||||||
|
@@ -517,6 +545,30 @@
|
||||||
|
<ind-def:filename>types.yaml</ind-def:filename>
|
||||||
|
<ind-def:yamlpath>.float_error_cast</ind-def:yamlpath>
|
||||||
|
</ind-def:yamlfilecontent_object>
|
||||||
|
+
|
||||||
|
+ <ind-def:yamlfilecontent_object version="1" id="oval:0:obj:26">
|
||||||
|
+ <ind-def:path>/tmp</ind-def:path>
|
||||||
|
+ <ind-def:filename>types.yaml</ind-def:filename>
|
||||||
|
+ <ind-def:yamlpath>.null_1</ind-def:yamlpath>
|
||||||
|
+ </ind-def:yamlfilecontent_object>
|
||||||
|
+
|
||||||
|
+ <ind-def:yamlfilecontent_object version="1" id="oval:0:obj:27">
|
||||||
|
+ <ind-def:path>/tmp</ind-def:path>
|
||||||
|
+ <ind-def:filename>types.yaml</ind-def:filename>
|
||||||
|
+ <ind-def:yamlpath>.null_2</ind-def:yamlpath>
|
||||||
|
+ </ind-def:yamlfilecontent_object>
|
||||||
|
+
|
||||||
|
+ <ind-def:yamlfilecontent_object version="1" id="oval:0:obj:28">
|
||||||
|
+ <ind-def:path>/tmp</ind-def:path>
|
||||||
|
+ <ind-def:filename>types.yaml</ind-def:filename>
|
||||||
|
+ <ind-def:yamlpath>.null_3</ind-def:yamlpath>
|
||||||
|
+ </ind-def:yamlfilecontent_object>
|
||||||
|
+
|
||||||
|
+ <ind-def:yamlfilecontent_object version="1" id="oval:0:obj:29">
|
||||||
|
+ <ind-def:path>/tmp</ind-def:path>
|
||||||
|
+ <ind-def:filename>types.yaml</ind-def:filename>
|
||||||
|
+ <ind-def:yamlpath>.string_null</ind-def:yamlpath>
|
||||||
|
+ </ind-def:yamlfilecontent_object>
|
||||||
|
</objects>
|
||||||
|
|
||||||
|
</oval_definitions>
|
||||||
|
diff --git a/tests/probes/yamlfilecontent/types.yaml b/tests/probes/yamlfilecontent/types.yaml
|
||||||
|
index f05fa3a967..fb26eab5f0 100644
|
||||||
|
--- a/tests/probes/yamlfilecontent/types.yaml
|
||||||
|
+++ b/tests/probes/yamlfilecontent/types.yaml
|
||||||
|
@@ -19,7 +19,11 @@ bool_false_cast: !!bool "false"
|
||||||
|
int_cast: !!int "369"
|
||||||
|
float_cast: !!float "978.65"
|
||||||
|
string_true: "true"
|
||||||
|
+string_null: "null"
|
||||||
|
string_number: "81"
|
||||||
|
bool_error_cast: !!bool "falsee"
|
||||||
|
int_error_cast: !!int "50%"
|
||||||
|
float_error_cast: !!float "58.41$"
|
||||||
|
+null_1: null
|
||||||
|
+null_2:
|
||||||
|
+null_3: !!null "null"
|
@ -1,6 +1,6 @@
|
|||||||
Name: openscap
|
Name: openscap
|
||||||
Version: 1.3.5
|
Version: 1.3.5
|
||||||
Release: 3%{?dist}
|
Release: 4%{?dist}
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Summary: Set of open source libraries enabling integration of the SCAP line of standards
|
Summary: Set of open source libraries enabling integration of the SCAP line of standards
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
@ -11,6 +11,8 @@ Patch2: openscap-1.3.6-replace-getlogin-pr-1753.patch
|
|||||||
Patch3: openscap-1.3.6-rpath-pr-1765.patch
|
Patch3: openscap-1.3.6-rpath-pr-1765.patch
|
||||||
Patch4: openscap-1.3.6-ubi9-pr-1772.patch
|
Patch4: openscap-1.3.6-ubi9-pr-1772.patch
|
||||||
Patch5: openscap-1.3.6-rpminspect-xml-pr-1773.patch
|
Patch5: openscap-1.3.6-rpminspect-xml-pr-1773.patch
|
||||||
|
Patch6: openscap-1.3.6-fix-failing-test-pr-1775.patch
|
||||||
|
Patch7: openscap-1.3.6-yamlfile-null-pr-1756.patch
|
||||||
BuildRequires: cmake >= 2.6
|
BuildRequires: cmake >= 2.6
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
BuildRequires: gcc-c++
|
BuildRequires: gcc-c++
|
||||||
@ -196,6 +198,10 @@ pathfix.py -i %{__python3} -p -n $RPM_BUILD_ROOT%{_bindir}/scap-as-rpm
|
|||||||
%{_bindir}/oscap-run-sce-script
|
%{_bindir}/oscap-run-sce-script
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jun 29 2021 Jan Černý <jcerny@redhat.com> - 1:1.3.5-4
|
||||||
|
- Fix failing test tests/API/XCCDF/unittests/test_profile_selection_by_suffix.sh
|
||||||
|
- Add 'null' yamlfilecontent values handling
|
||||||
|
|
||||||
* Mon Jun 28 2021 Jan Černý <jcerny@redhat.com> - 1:1.3.5-3
|
* Mon Jun 28 2021 Jan Černý <jcerny@redhat.com> - 1:1.3.5-3
|
||||||
- Do not set RPATH on built binaries
|
- Do not set RPATH on built binaries
|
||||||
- Fix UBI9 scan (rhbz#1953610)
|
- Fix UBI9 scan (rhbz#1953610)
|
||||||
|
Loading…
Reference in New Issue
Block a user