traffic_replay: use packets per second as primary scale
[Samba.git] / script / compare_cc_results.py
blob4b8abf601f403394cce94c96788a888cc8e41edf
1 #!/usr/bin/env python3
4 # Compare the results of native and cross-compiled configure tests
7 from __future__ import print_function
8 import sys
9 import difflib
11 exceptions = [
12 'BUILD_DIRECTORY', 'SELFTEST_PREFIX', 'defines',
13 'CROSS_COMPILE', 'CROSS_ANSWERS', 'CROSS_EXECUTE',
14 'LIBSOCKET_WRAPPER_SO_PATH',
15 'LIBNSS_WRAPPER_SO_PATH',
16 'LIBPAM_WRAPPER_SO_PATH',
17 'PAM_SET_ITEMS_SO_PATH',
18 'LIBUID_WRAPPER_SO_PATH',
19 'LIBRESOLV_WRAPPER_SO_PATH',
22 base_lines = list()
23 base_fname = ''
25 found_diff = False
27 for fname in sys.argv[1:]:
28 lines = list()
29 f = open(fname, 'r')
30 for line in f:
31 if line.startswith("cfg_files ="):
32 # waf writes configuration files as absolute paths
33 continue
34 if len(line.split('=', 1)) == 2:
35 key = line.split('=', 1)[0].strip()
36 value = line.split('=', 1)[1].strip()
37 if key in exceptions:
38 continue
39 # using waf with python 3.4 seems to randomly sort dict keys
40 # we can't modify the waf code but we can fake a dict value
41 # string representation as if it were sorted. python 3.6.5
42 # doesn't seem to suffer from this behaviour
43 if value.startswith('{'):
44 import ast
45 amap = ast.literal_eval(value)
46 fakeline = ""
47 for k in sorted(amap.keys()):
48 if not len(fakeline) == 0:
49 fakeline = fakeline + ", "
50 fakeline = fakeline + '\'' + k + '\': \'' + amap[k] + '\''
51 line = key + ' = {' + fakeline + '}'
52 lines.append(line)
53 f.close()
54 if base_fname:
55 diff = list(difflib.unified_diff(base_lines, lines, base_fname, fname))
56 if diff:
57 print('configuration files %s and %s do not match' % (base_fname, fname))
58 for l in diff:
59 sys.stdout.write(l)
60 found_diff = True
61 else:
62 base_fname = fname
63 base_lines = lines
65 if found_diff:
66 sys.exit(1)