1#!/usr/bin/python -E 2import sys 3import re 4from selinux import * 5verbose = 0 6errors = 0 7 8if len(sys.argv) > 1 and sys.argv[1] == "-v": 9 verbose = 1 10 11for arg in sys.argv[1:]: 12 f = open(arg, 'r') 13 for line in f: 14 if line.startswith('#'): 15 continue 16 if not line.strip(): 17 continue 18 line = line.rstrip('\n') 19# print line 20 context, expected = line.split("=") 21 rc, raw = selinux_trans_to_raw_context(context) 22 if rc < 0: 23 print "Unable to get raw context of '%s'" % (context) 24 errors += 1 25 continue 26 rc, colors = selinux_raw_context_to_color(raw) 27 if rc < 0: 28 print "Unable to get colors for '%s'" % (context) 29 errors += 1 30 continue 31 colors = colors.rstrip() 32 if colors != expected: 33 print "For '%s' got\n\t'%s' expected\n\t'%s'" % (context, colors, expected) 34 errors += 1 35 continue 36 f.close() 37 38s = "s" 39if errors == 1: 40 s = "" 41print "mlscolor-test done with %d error%s" % (errors, s) 42 43sys.exit(errors) 44