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