diff options
-rw-r--r-- | conf.py | 6 | ||||
-rw-r--r-- | scripts/boot.py | 30 | ||||
-rwxr-xr-x | scripts/initialize.py | 8 | ||||
-rw-r--r-- | scripts/kernel.py | 4 | ||||
-rwxr-xr-x | scripts/test.py | 17 | ||||
-rw-r--r-- | scripts/utils.py | 29 |
6 files changed, 50 insertions, 44 deletions
@@ -48,10 +48,10 @@ linux_kconfig_head = linux_sources + 'Kconfig' linux_dot_config = linux_sources + '.config' linux_image = linux_sources + 'arch/' + ARCH + '/boot/bzImage' -buildroot_def_config = 'scripts/buildroot_recipe/buildroot.def.config' -buildroot_inittab_directive = 'scripts/buildroot_recipe/inittab_directive' +buildroot_def_config = 'buildroot_recipe/buildroot.def.config' +buildroot_inittab_directive = 'buildroot_recipe/inittab_directive' buildroot_initscript = 'scripts/buildroot_recipe/linux-conf-perf' -buildroot_initram = 'scripts/buildroot/output/images/rootfs.cpio.gz' +buildroot_initram = 'buildroot/output/images/rootfs.cpio.gz' build_folder = 'jobfiles/' phase_file = build_folder + 'phase' diff --git a/scripts/boot.py b/scripts/boot.py index bff70d9..d03504a 100644 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -18,27 +18,15 @@ def boot(): except FileExistsError: pass - bench = importlib.machinery.SourceFileLoader("module.name", - sf(conf.benchmark_python)).load_module() + wd = os.getcwd() - sprc = subprocess.Popen([sf(conf.novaboot), sf(conf.nbscript)] + conf.novaboot_args, + sprc = subprocess.Popen(conf.boot_command, stdout = subprocess.PIPE) - output = '' - for linen in sprc.stdout: - line = linen.decode('utf-8') - if conf.boot_output: - print(line, end="") - if line.startswith('lcp-output: '): - output += line[12:] - print(output) + with open(os.path.join(sf(conf.output_folder), utils.get_last_configuration()), "w") as f: + for linen in sprc.stdout: + line = linen.decode('utf-8') + if conf.boot_output: + print(line, end="") + f.write(line) - # TODO change - data = bench.stdoutput(output) - - iteration = 0 - with open(sf(conf.iteration_file), 'r') as f: - iteration = int(f.readline()) - - for key, val in data.items(): - with open(os.path.join(sf(conf.output_folder),key), 'w') as f: - f.write(str(iteration) + ':' + str(val) + '\n') + os.chdir(wd) diff --git a/scripts/initialize.py b/scripts/initialize.py index 35510d2..c77803c 100755 --- a/scripts/initialize.py +++ b/scripts/initialize.py @@ -89,10 +89,14 @@ def gen_nbscript(): " already exists. Generation skipped.") return + wd = os.getcwd() + os.chdir(os.path.dirname(sf(conf.nbscript))) + prefix = os.path.relpath(conf.absroot) + os.chdir(wd) with open(sf(conf.nbscript), 'w') as f: f.write('# generated novaboot script. Please don\'t edit unless you know what are you doing.\n') - f.write('load ' + sf(conf.linux_image) + ' console=ttyS0,115200\n') - f.write('load ' + sf(conf.buildroot_initram) + '\n') + f.write('load ' + os.path.join(prefix, conf.linux_image) + ' console=ttyS0,115200\n') + f.write('load ' + os.path.join(prefix, conf.buildroot_initram) + '\n') ################################################################################# diff --git a/scripts/kernel.py b/scripts/kernel.py index 4494f22..71ad1ac 100644 --- a/scripts/kernel.py +++ b/scripts/kernel.py @@ -39,8 +39,8 @@ def make(): wd = os.getcwd() os.chdir(sf(conf.linux_sources)) if conf.kernel_make_output: - subprocess.call(build_command, env=utils.get_kernel_env()) + subprocess.call(conf.build_command, env=utils.get_kernel_env()) else: - subprocess.call(build_command, stdout=subprocess.DEVNULL, + subprocess.call(conf.build_command, stdout=subprocess.DEVNULL, env=utils.get_kernel_env()) os.chdir(wd) diff --git a/scripts/test.py b/scripts/test.py index a69c5b7..5b94df2 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -5,32 +5,17 @@ import sys from conf import conf from conf import sf import initialize -import iteration import kernel import boot def test(): + initialize.base() initialize.parse_kconfig() initialize.gen_requred() # Call this to check initial solution - iteration.reset() # Reset iteration conf.kernel_make_output = True kernel.make() conf.boot_output = True boot.boot() - print('------------------------------') - for nm in os.listdir(sf(conf.output_folder)): - if os.path.isfile(os.path.join(sf(conf.output_folder), nm)): - with open(os.path.join(sf(conf.output_folder), nm), 'r') as f: - print(nm + ':') - for line in f: - print(line, end='') - os.remove(os.path.join(sf(conf.output_folder), nm)) - # To be sure also try remove other file - try: - os.remove(sf(conf.solved_file)) - except OSError: - pass - ################################################################################# diff --git a/scripts/utils.py b/scripts/utils.py index 0b6ac9c..060aa3e 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -114,3 +114,32 @@ def config_strtoint(str): except ValueError: pass return rtn + +def get_config_from_hash(hash): + with open(sf(conf.config_map_file), "r") as f: + for line in f: + w = line.rstrip().split(sep=':') + if w[0] == hash: + return config_strtoint(w[1]) + return None + +def get_last_configuration(): + hsh = "" + try: + with open(sf(conf.config_solved_file), "r") as f: + for line in f: + sline = line.rstrip() + if sline != '': + hsh = sline + except FileNotFoundError: + try: + with open(sf(conf.config_map_file), "r") as f: + w = f.readline().split(sep=':') + hsh = w[0] + except FileNotFoundError: + pass + + if hsh != '': + return hsh + else: + return 'NoConfig' |