Skip to content

Instantly share code, notes, and snippets.

@ehabkost
Created June 2, 2011 17:45
Show Gist options
  • Save ehabkost/1004885 to your computer and use it in GitHub Desktop.
Save ehabkost/1004885 to your computer and use it in GitHub Desktop.
Simmple script to compare sets of flags on Qemu cpudef config files
#!/usr/bin/env python
# simple script to compare sets of flags on Qemu cpudef config files
# Author: Eduardo Habkost <[email protected]>
import sys
import ConfigParser
files = sys.argv[1:]
setlists = []
for fn in files:
sets = []
f = open(fn, 'r')
for l in f.readlines():
nc = l.split('#',1)[0]
parts = nc.split('=', 1)
if len(parts) > 1 and parts[1]:
n = parts[0]
p1 = parts[1]
p1 = p1.strip().strip('"')
s = set(p1.split())
sets.append( (n,s) )
else:
print 'ignoring: %r' % (l)
setlists.append(sets)
if len(setlists[0]) <> len(setlists[1]):
print 'not OK (size)'
print repr(setlists[0])
print repr(setlists[1])
sys.exit(1)
lastname = None
ok = True
for (na,a),(nb,b) in zip(setlists[0], setlists[1]):
if na.strip().startswith('name'):
lastname = a
if a <> b:
print 'not OK:'
print na,nb
print repr(sorted(a))
print repr(sorted(b))
print lastname
ok = False
if ok:
print 'OK!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment