]> rtime.felk.cvut.cz Git - linux-conf-perf.git/commitdiff
Fix booting process and test target
authorKarel Kočí <cynerd@email.cz>
Thu, 14 May 2015 15:37:18 +0000 (17:37 +0200)
committerKarel Kočí <cynerd@email.cz>
Thu, 14 May 2015 15:37:18 +0000 (17:37 +0200)
Test target wasn't working properly. Now it should work.

conf.py
scripts/boot.py
scripts/initialize.py
scripts/kernel.py
scripts/test.py
scripts/utils.py

diff --git a/conf.py b/conf.py
index df13e8a6e7e112fbb0f73c4da3546af81ca077ae..2ead6b7ef36effb36df1847af516292614f6e99d 100644 (file)
--- a/conf.py
+++ b/conf.py
@@ -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'
index bff70d902af1c4fee7211d46e8e2107fa4de6731..d03504a64e1d5a4d6bbfbe52a39a37f7285ad35c 100644 (file)
@@ -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)
index 35510d29d6395029080ca43e790227b7ee57297f..c77803c74a9f99ffcae84273391e86dce75f81d8 100755 (executable)
@@ -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')
 
 #################################################################################
 
index 4494f22f6506c3ccabc33a330fa03b7fe72867db..71ad1ac7dcb19b72758a1b94d93c8e02c2b7e57b 100644 (file)
@@ -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)
index a69c5b7bf03880d0b4f115e81f79eb7f44206ce4..5b94df2194837dd3343265df969e3147d9b373ea 100755 (executable)
@@ -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
-
 
 #################################################################################
 
index 0b6ac9c681810253b0c2d07d868a295d0dd0d11c..060aa3ecc17ea8677e3eed976fde9080a1e95c54 100644 (file)
@@ -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'