From: Nicolas Iooss <nicolas.iooss@m4x.org>
To: selinux@vger.kernel.org
Subject: [PATCH 1/2] mcstrans: convert test scripts to Python 3
Date: Sat, 15 Dec 2018 19:14:54 +0100 [thread overview]
Message-ID: <20181215181455.31643-1-nicolas.iooss@m4x.org> (raw)
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
mcstrans/share/util/mlscolor-test | 8 ++++----
mcstrans/share/util/mlstrans-test | 11 +++++------
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/mcstrans/share/util/mlscolor-test b/mcstrans/share/util/mlscolor-test
index 7b8d809b7ac5..447389704beb 100644
--- a/mcstrans/share/util/mlscolor-test
+++ b/mcstrans/share/util/mlscolor-test
@@ -20,17 +20,17 @@ for arg in sys.argv[1:]:
context, expected = line.split("=")
rc, raw = selinux_trans_to_raw_context(context)
if rc < 0:
- print "Unable to get raw context of '%s'" % (context)
+ print("Unable to get raw context of '%s'" % (context))
errors += 1
continue
rc, colors = selinux_raw_context_to_color(raw)
if rc < 0:
- print "Unable to get colors for '%s'" % (context)
+ print("Unable to get colors for '%s'" % (context))
errors += 1
continue
colors = colors.rstrip()
if colors != expected:
- print "For '%s' got\n\t'%s' expected\n\t'%s'" % (context, colors, expected)
+ print("For '%s' got\n\t'%s' expected\n\t'%s'" % (context, colors, expected))
errors += 1
continue
f.close()
@@ -38,6 +38,6 @@ for arg in sys.argv[1:]:
s = "s"
if errors == 1:
s = ""
-print "mlscolor-test done with %d error%s" % (errors, s)
+print("mlscolor-test done with %d error%s" % (errors, s))
sys.exit(errors)
diff --git a/mcstrans/share/util/mlstrans-test b/mcstrans/share/util/mlstrans-test
index f854f7b3c2d6..3ff4444ab000 100644
--- a/mcstrans/share/util/mlstrans-test
+++ b/mcstrans/share/util/mlstrans-test
@@ -10,22 +10,22 @@ def untrans(trans, val):
global errors, verbose
(rc, raw) = selinux_trans_to_raw_context(trans)
if raw != val:
- print "untrans: '%s' -> '%s' != '%s' FAILED" % (trans, raw, val)
+ print("untrans: '%s' -> '%s' != '%s' FAILED" % (trans, raw, val))
errors += 1
else:
if verbose:
- print "untrans: %s -> %s != %s SUCCESS" % (trans, raw, val)
+ print("untrans: %s -> %s != %s SUCCESS" % (trans, raw, val))
def trans(raw, val):
global errors, verbose
(rc, trans) = selinux_raw_to_trans_context(raw)
if trans != val:
- print "trans: '%s' -> '%s' != '%s' FAILED" % (raw, trans, val)
+ print("trans: '%s' -> '%s' != '%s' FAILED" % (raw, trans, val))
errors += 1
else:
if verbose:
- print "trans: %s -> %s != %s SUCCESS" % (raw, trans, val)
+ print("trans: %s -> %s != %s SUCCESS" % (raw, trans, val))
if len(sys.argv) > 1 and sys.argv[1] == "-v":
verbose = 1
@@ -38,7 +38,6 @@ for arg in sys.argv[1:]:
if not line.strip():
continue
line = line.rstrip('\n')
-# print line
if (line.find("==") != -1):
t, r = line.split("==")
untrans("a:b:c:" + t, "a:b:c:" + r)
@@ -51,6 +50,6 @@ for arg in sys.argv[1:]:
s = "s"
if errors == 1:
s = ""
-print "mlstrans-test done with %d error%s" % (errors, s)
+print("mlstrans-test done with %d error%s" % (errors, s))
sys.exit(errors)
--
2.19.2
next reply other threads:[~2018-12-15 18:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-15 18:14 Nicolas Iooss [this message]
2018-12-15 18:14 ` [PATCH 2/2] mcstrans: fix Python linter warnings on test scripts Nicolas Iooss
2018-12-19 11:08 ` 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=20181215181455.31643-1-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.