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