Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kernel-hardening-checker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
kernel-hardening-checker
Commits
6aa06e0b
Commit
6aa06e0b
authored
Apr 02, 2023
by
Alexander Popov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_engine: implement get_engine_result() for stdout
parent
a1888d29
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
test_engine.py
kconfig_hardened_check/test_engine.py
+15
-2
No files found.
kconfig_hardened_check/test_engine.py
View file @
6aa06e0b
...
...
@@ -13,6 +13,8 @@ This module performs unit-testing of the kconfig-hardened-check engine.
# pylint: disable=missing-function-docstring,line-too-long
import
unittest
import
io
import
sys
from
collections
import
OrderedDict
import
json
from
.engine
import
KconfigCheck
,
CmdlineCheck
,
VersionCheck
,
OR
,
AND
,
populate_with_data
,
perform_checks
...
...
@@ -63,8 +65,9 @@ class TestEngine(unittest.TestCase):
# print the table with the results
print
(
'TABLE:'
)
for
opt
in
checklist
:
opt
.
table_print
(
None
,
True
)
# default
mode, with_results
opt
.
table_print
(
'verbose'
,
True
)
# verbose
mode, with_results
print
()
print
(
'='
*
121
)
# print the results in JSON
print
(
'JSON:'
)
...
...
@@ -76,11 +79,21 @@ class TestEngine(unittest.TestCase):
@staticmethod
def
get_engine_result
(
checklist
,
result
,
result_type
):
assert
(
result_type
in
(
'
table'
,
'json
'
)),
\
assert
(
result_type
in
(
'
json'
,
'stdout
'
)),
\
f
'invalid result type "{result_type}"'
if
result_type
==
'json'
:
for
opt
in
checklist
:
result
.
append
(
opt
.
json_dump
(
True
))
# with_results
return
captured_output
=
io
.
StringIO
()
stdout_backup
=
sys
.
stdout
sys
.
stdout
=
captured_output
for
opt
in
checklist
:
opt
.
table_print
(
'verbose'
,
True
)
# verbose mode, with_results
sys
.
stdout
=
stdout_backup
result
.
append
(
captured_output
.
getvalue
())
def
test_single_kconfig
(
self
):
# 1. prepare the checklist
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment