def host_check_config(self, i_kernel, i_config, console=0): l_file = "/boot/config-%s" % i_kernel try: l_res = self.host_run_command("test -e %s" % l_file, timeout=60, console=console) except CommandFailed as c: raise NoKernelConfig(i_kernel, l_file) log.debug("Config file is available") l_cmd = "cat %s | grep -i --color=never %s" % (l_file, i_config) l_res = self.host_run_command(l_cmd, timeout=60, console=console) log.debug(l_res) config_opts = {} for o in l_res: m = re.match('# (.*) is not set', o) if m: config_opts[m.group(0)]='n' else: if '=' in o: opt, val = o.split("=") config_opts[opt] = val if config_opts.get(i_config) not in ["y","m"]: raise KernelConfigNotSet(i_config) return config_opts[i_config]
def host_check_config(self, i_kernel, i_config, console=0): ''' This function will checks first for config file for a given kernel version on host, if available then check for config option value and return that value whether it is y or m...etc. sample config option values: :: CONFIG_CRYPTO_ZLIB=m CONFIG_CRYPTO_LZO=y # CONFIG_CRYPTO_842 is not set i_kernel kernel version i_config Which config option want to check in config file. e.g. `CONFIG_SENSORS_IBMPOWERNV` It will return config option value y or m, or raise OpTestError if config file is not available on host or raise OpTestError if config option is not set in file. ''' l_file = "/boot/config-%s" % i_kernel try: l_res = self.host_run_command("test -e %s" % l_file, timeout=60, console=console) except CommandFailed: raise NoKernelConfig(i_kernel, l_file) log.debug("Config file is available") l_cmd = "cat %s | grep -i --color=never %s" % (l_file, i_config) l_res = self.host_run_command(l_cmd, timeout=60, console=console) log.debug(l_res) config_opts = {} for o in l_res: m = re.match('# (.*) is not set', o) if m: config_opts[m.group(0)] = 'n' else: if '=' in o: opt, val = o.split("=") config_opts[opt] = val if config_opts.get(i_config) not in ["y", "m"]: raise KernelConfigNotSet(i_config) return config_opts[i_config]