diff options
author | Hector Fernandez <hector@iatec.biz> | 2020-06-19 13:15:56 +0200 |
---|---|---|
committer | Hector Fernandez <hector@iatec.biz> | 2020-06-19 13:15:56 +0200 |
commit | 278b5729a44837e37fe13611518c1babc8de00df (patch) | |
tree | 2e6a0350aa9edc5e05e886d32051f263f50f4040 /test-cli/test/helpers | |
parent | 736ddcfe6dc3b5edbab6773f1c6687f6597fa7a3 (diff) | |
download | board-278b5729a44837e37fe13611518c1babc8de00df.zip board-278b5729a44837e37fe13611518c1babc8de00df.tar.gz board-278b5729a44837e37fe13611518c1babc8de00df.tar.bz2 |
Model and variant type are obtained from kernel cmdline instead of setup.xml. Python checks if they exist and can generate an error message to the DB if they are missing.
Diffstat (limited to 'test-cli/test/helpers')
-rw-r--r-- | test-cli/test/helpers/cmdline.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test-cli/test/helpers/cmdline.py b/test-cli/test/helpers/cmdline.py new file mode 100644 index 0000000..fad81ac --- /dev/null +++ b/test-cli/test/helpers/cmdline.py @@ -0,0 +1,28 @@ + +class LinuxKernel: + + __kernel_vars = {} + + def __init__(self): + self.parse_kernel_cmdline() + + def parse_kernel_cmdline(self): + cmdline = open('/proc/cmdline', 'rb').read().decode() + cmd_array = cmdline.split() + i = 0 + for f in cmdline.split(): + pos = f.find('=') + if pos == -1: + cmd_array[i - 1] = cmd_array[i - 1] + " " + f + cmd_array.remove(cmd_array[i]) + else: + i += 1 + self.__kernel_vars = {} + for f in cmd_array: + dat = f.split('=') + self.__kernel_vars[dat[0]] = dat[1] + + def getkvar(self, vName, vdefault): + if vName in self.__kernel_vars: + return self.__kernel_vars[vName] + return vdefault |