aboutsummaryrefslogtreecommitdiff
path: root/scripts/configdiff.py
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-03-26 14:36:31 +0100
committerKarel Kočí <cynerd@email.cz>2015-03-26 14:36:31 +0100
commitf91e9e472d50795b6e67dfb3905559800a3bef66 (patch)
tree26e14579009a76487fbe1d9e3944ae37440cca72 /scripts/configdiff.py
parentee18912759d170e1f926bc1a234dba781a98fbdd (diff)
downloadlinux-conf-perf-f91e9e472d50795b6e67dfb3905559800a3bef66.tar.gz
linux-conf-perf-f91e9e472d50795b6e67dfb3905559800a3bef66.tar.bz2
linux-conf-perf-f91e9e472d50795b6e67dfb3905559800a3bef66.zip
Add .config check
config is not yet part of main_loop From now it seems that config is changing a lot of configs to diferent setting. Is it because of missing dependency for sat? or because of configuration restart. Shouldn't we be also exporting all non bool/tri state configs?
Diffstat (limited to 'scripts/configdiff.py')
-rw-r--r--scripts/configdiff.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/configdiff.py b/scripts/configdiff.py
new file mode 100644
index 0000000..3cf1b16
--- /dev/null
+++ b/scripts/configdiff.py
@@ -0,0 +1,48 @@
+import os
+import sys
+
+from conf import conf
+import utils
+
+
+def check():
+ """Check if .config file in kernel tree is consistent with generated solution.
+ This containst code fragments from solution.py (apply)
+ """
+ # Check if solution_file exist
+ if not os.path.isfile(conf.solution_file):
+ raise Exception("Solution file is missing. Run sat_solution and check existence of " + conf.solution_file)
+
+ utils.build_symbol_map() # Ensure smap existence
+ srmap = {value:key for key, value in utils.smap.items()}
+
+ # Read solution if satisfiable
+ with open(conf.solution_file, 'r') as f:
+ if not f.readline().rstrip() == 'SAT':
+ raise NoSolution()
+ solut = f.readline().split()
+ solut.remove('0') # Remove 0 at the end
+ solutb = []
+ for sl in solut: # This is using that sat. solver output is sorted
+ if sl[0] == '-':
+ solutb.append(False)
+ else:
+ solutb.append(True)
+
+ mismatch = False
+ with open(conf.linux_sources + '/.config', 'r') as f:
+ for line in f:
+ if (line[0] == '#') or (not '=' in line):
+ continue
+ indx = line.index('=')
+ if (line[indx + 1] == 'y'):
+ if (solutb[int(srmap[line[7:indx]]) - 1] == False):
+ print("W: Setting mismatch: " + line, end='')
+ mismatch = True
+ if (line[indx + 1] == 'm'):
+ print("W: module setting find: " + line, end='')
+ elif (line[indx + 1] == 'n'):
+ if (solutb[int(srmap[line[7:indx]]) - 1] == True):
+ print("W: Setting mismatch: " + line, end='')
+ mismatch = True
+ return mismatch