From: Nicolas Iooss <nicolas.iooss@m4x.org>
To: selinux@vger.kernel.org
Subject: [PATCH 3/5] python/audit2allow: use local sepolgen-ifgen-attr-helper for tests
Date: Sat, 5 Jan 2019 20:37:57 +0100 [thread overview]
Message-ID: <20190105193759.3333-4-nicolas.iooss@m4x.org> (raw)
In-Reply-To: <20190105193759.3333-1-nicolas.iooss@m4x.org>
Introduce option --attr-helper to sepolgen-ifgen to make it possible to
override /usr/bin/sepolgen-ifgen-attr-helper and use it in the testuite
in order to test the helper which has been compiled from the project
instead of the one installed on the system.
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
python/audit2allow/sepolgen-ifgen | 8 +++++---
python/audit2allow/test_audit2allow.py | 5 ++++-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/python/audit2allow/sepolgen-ifgen b/python/audit2allow/sepolgen-ifgen
index e3f67d430647..c482f227193f 100644
--- a/python/audit2allow/sepolgen-ifgen
+++ b/python/audit2allow/sepolgen-ifgen
@@ -56,6 +56,8 @@ def parse_options():
help="print debuging output")
parser.add_option("-d", "--debug", action="store_true", default=False,
help="extra debugging output")
+ parser.add_option("--attr-helper", default=ATTR_HELPER,
+ help="path to sepolgen-ifgen-attr-helper")
parser.add_option("--no_attrs", action="store_true", default=False,
help="do not retrieve attribute access from kernel policy")
options, args = parser.parse_args()
@@ -77,7 +79,7 @@ def get_policy():
return None
-def get_attrs(policy_path):
+def get_attrs(policy_path, attr_helper):
try:
if not policy_path:
policy_path = get_policy()
@@ -93,7 +95,7 @@ def get_attrs(policy_path):
return None
fd = open("/dev/null", "w")
- ret = subprocess.Popen([ATTR_HELPER, policy_path, outfile.name], stdout=fd).wait()
+ ret = subprocess.Popen([attr_helper, policy_path, outfile.name], stdout=fd).wait()
fd.close()
if ret != 0:
sys.stderr.write("could not run attribute helper\n")
@@ -127,7 +129,7 @@ def main():
# Get the attibutes from the binary
attrs = None
if not options.no_attrs:
- attrs = get_attrs(options.policy_path)
+ attrs = get_attrs(options.policy_path, options.attr_helper)
if attrs is None:
return 1
diff --git a/python/audit2allow/test_audit2allow.py b/python/audit2allow/test_audit2allow.py
index 0320c6dd5c1b..87e5504ada47 100644
--- a/python/audit2allow/test_audit2allow.py
+++ b/python/audit2allow/test_audit2allow.py
@@ -28,7 +28,10 @@ class Audit2allowTests(unittest.TestCase):
"Verify sepolgen-ifgen works"
temp_directory = mkdtemp(suffix='audit2allow_test')
output_file = os.path.join(temp_directory, 'interface_info')
- p = Popen([sys.executable, './sepolgen-ifgen', '-p', 'test_dummy_policy', '-o', output_file], stdout=PIPE)
+ p = Popen([
+ sys.executable, './sepolgen-ifgen', '-p', 'test_dummy_policy', '-o', output_file,
+ '--attr-helper', './sepolgen-ifgen-attr-helper'
+ ], stdout=PIPE)
out, err = p.communicate()
if err:
print(out, err)
--
2.20.1
next prev parent reply other threads:[~2019-01-05 19:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-05 19:37 [PATCH 0/5] Run tests in python/ with "make test" Nicolas Iooss
2019-01-05 19:37 ` [PATCH 1/5] Travis-CI: download refpolicy and install headers Nicolas Iooss
2019-01-05 19:37 ` [PATCH 2/5] python/audit2allow: make the tests useful again Nicolas Iooss
2019-01-05 19:37 ` Nicolas Iooss [this message]
2019-01-05 19:37 ` [PATCH 4/5] python/sepolgen: refpolicy installs its Makefile in include/Makefile Nicolas Iooss
2019-01-05 19:37 ` [PATCH 5/5] python: run all the tests with "make test" Nicolas Iooss
2019-01-08 11:04 ` Petr Lautrbach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190105193759.3333-4-nicolas.iooss@m4x.org \
--to=nicolas.iooss@m4x.org \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).