Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
---
client/kernel.py | 24 ++++-----
client/kernel_config.py | 123 ++++++++++++++++++++++-------------------------
2 files changed, 69 insertions(+), 78 deletions(-)
diff --git a/client/kernel.py b/client/kernel.py
index 20cf247..a11f2f0 100644
--- a/client/kernel.py
+++ b/client/kernel.py
@@ -269,11 +269,12 @@ class kernel(BootableKernel):
@log.record
@tee_output_logdir_mark
- def config(self, config_file = '', config_list = None, defconfig = False,
make = None):
+ def config(self, config_file='', config_list=None, defconfig=False,
+ make=None):
self.set_cross_cc()
- config = kernel_config.kernel_config(self.job, self.build_dir,
- self.config_dir, config_file, config_list,
- defconfig, self.base_tree_version, make)
+ kernel_config.kernel_config(self.job, self.build_dir, self.config_dir,
+ config_file, config_list, defconfig,
+ self.base_tree_version, make)
def get_patches(self, patches):
@@ -351,7 +352,7 @@ class kernel(BootableKernel):
@log.record
@tee_output_logdir_mark
- def build(self, make_opts = '', logfile = '', extraversion='autotest'):
+ def build(self, make_opts='', logfile ='', extraversion='autotest'):
"""build the kernel
make_opts
@@ -381,19 +382,18 @@ class kernel(BootableKernel):
kernel_version = re.sub('-autotest', '', kernel_version)
self.logfile.write('BUILD VERSION: %s\n' % kernel_version)
- utils.force_copy(self.build_dir+'/System.map',
- self.results_dir)
+ utils.force_copy(self.build_dir + '/System.map', self.results_dir)
- def build_timed(self, threads, timefile = '/dev/null', make_opts = '',
- output = '/dev/null'):
+ def build_timed(self, threads, timefile='/dev/null', make_opts='',
+ output='/dev/null'):
"""time the bulding of the kernel"""
os.chdir(self.build_dir)
self.set_cross_cc()
self.clean()
- build_string = "/usr/bin/time -o %s make %s -j %s vmlinux" \
- % (timefile, make_opts, threads)
+ build_string = ("/usr/bin/time -o %s make %s -j %s vmlinux" %
+ (timefile, make_opts, threads))
build_string += ' > %s 2>&1' % output
print build_string
utils.system(build_string)
@@ -482,7 +482,7 @@ class kernel(BootableKernel):
@log.record
@tee_output_logdir_mark
- def install(self, tag='autotest', prefix = '/'):
+ def install(self, tag='autotest', prefix='/'):
"""make install in the kernel tree"""
# Record that we have installed the kernel, and
diff --git a/client/kernel_config.py b/client/kernel_config.py
index 06cfc9d..8429080 100644
--- a/client/kernel_config.py
+++ b/client/kernel_config.py
@@ -1,27 +1,25 @@
-# TODO: need a function to get the newest config file older than us from
-# the repo.
-
-import shutil, os
+import shutil, os, logging
from autotest.client import utils
from autotest.client.shared import error, kernel_versions
+
def apply_overrides(orig_file, changes_file, output_file):
override = dict()
# First suck all the changes into a dictionary.
- input = file(changes_file, 'r')
- for line in input.readlines():
+ input_file = file(changes_file, 'r')
+ for line in input_file.readlines():
if line.startswith('CONFIG_'):
key = line.split('=')[0]
override[key] = line;
elif line.startswith('# CONFIG_'):
key = line.split(' ')[1]
override[key] = line;
- input.close()
+ input_file.close()
# Now go through the input file, overriding lines where need be
- input = file(orig_file, 'r')
- output = file(output_file, 'w')
+ input_file = file(orig_file, 'r')
+ output_file = file(output_file, 'w')
for line in input.readlines():
if line.startswith('CONFIG_'):
key = line.split('=')[0]
@@ -30,11 +28,11 @@ def apply_overrides(orig_file, changes_file, output_file):
else:
key = None
if key and key in override:
- output.write(override[key])
+ output_file.write(override[key])
else:
- output.write(line)
- input.close()
- output.close()
+ output_file.write(line)
+ input_file.close()
+ output_file.close()
def diff_configs(old, new):
@@ -42,99 +40,92 @@ def diff_configs(old, new):
ignore_status=True)
-
def modules_needed(config):
return (utils.grep('CONFIG_MODULES=y', config) and utils.grep('=m',
config))
-def config_by_name(name, set):
- version = kernel_versions.version_choose_config(name, set[1:])
+def config_by_name(name, s):
+ version = kernel_versions.version_choose_config(name, s[1:])
if version:
- return set[0] + version
+ return s[0] + version
return None
class kernel_config(object):
- # Build directory must be ready before init'ing config.
- #
- # Stages:
- # 1. Get original config file
- # 2. Apply overrides
- # 3. Do 'make oldconfig' to update it to current source code
- # (gets done implicitly during the process)
- #
- # You may specifiy the a defconfig within the tree to build,
- # or a custom config file you want, or None, to get machine's
- # default config file from the repo.
-
- build_dir = '' # the directory we're building in
- config_dir = '' # local repository for config_file data
-
- build_config = '' # the config file in the build directory
- orig_config = '' # the original config file
- over_config = '' # config file + overrides
-
-
- def __init__(self, job, build_dir, config_dir, orig_file,
- overrides, defconfig = False, name = None, make =
None):
+ """
+ Build directory must be ready before init'ing config.
+
+ Stages:
+ 1. Get original config file
+ 2. Apply overrides
+ 3. Do 'make oldconfig' to update it to current source code
+ (gets done implicitly during the process)
+
+ You may specifiy the defconfig within the tree to build,
+ or a custom config file you want, or None, to get machine's
+ default config file from the repo.
+ """
+ def __init__(self, job, build_dir, config_dir, orig_file, overrides,
+ defconfig=False, name=None, make=None):
self.build_dir = build_dir
self.config_dir = config_dir
- # 1. Get original config file
- self.build_config = build_dir + '/.config'
- if (orig_file == '' and not defconfig and not make): # use user
default
- set = job.config_get("kernel.default_config_set")
+ # 1. Get original config file
+ self.build_config = os.path.join(build_dir, '.config')
+ if (orig_file == '' and not defconfig and not make): # use user default
+ s = job.config_get("kernel.default_config_set")
defconf = None
- if set and name:
- defconf = config_by_name(name, set)
+ if s and name:
+ defconf = config_by_name(name, s)
if not defconf:
defconf = job.config_get("kernel.default_config")
if defconf:
orig_file = defconf
- if (orig_file == '' and not make and defconfig): # use defconfig
+ if (orig_file == '' and not make and defconfig): # use defconfig
make = 'defconfig'
if (orig_file == '' and make): # use the config command
- print "kernel_config: using " + make + " to configure kernel"
+ logging.debug("kernel_config: using %s to configure kernel" % make)
os.chdir(build_dir)
make_return = utils.system('make %s > /dev/null' % make)
self.config_record(make)
- if (make_return):
- raise error.TestError('make % failed' % make)
+ if make_return:
+ raise error.TestError('make %s failed' % make)
else:
- print "kernel_config: using " + orig_file + \
- " to configure kernel"
- self.orig_config = config_dir + '/config.orig'
+ logging.debug("using %s to configure kernel", orig_file)
+ self.orig_config = os.path.join(config_dir, 'config.orig')
utils.get_file(orig_file, self.orig_config)
- self.update_config(self.orig_config, self.orig_config+'.new')
- diff_configs(self.orig_config, self.orig_config+'.new')
+ self.update_config(self.orig_config, self.orig_config + '.new')
+ diff_configs(self.orig_config, self.orig_config + '.new')
- # 2. Apply overrides
+ # 2. Apply overrides
if overrides:
- print "kernel_config: using " + overrides + \
- " to re-configure kernel"
- self.over_config = config_dir + '/config.over'
+ logging.debug("using %s to re-configure kernel", overrides)
+ self.over_config = os.path.join(config_dir, 'config.over')
overrides_local = self.over_config + '.changes'
utils.get_file(overrides, overrides_local)
apply_overrides(self.build_config, overrides_local,
self.over_config)
- self.update_config(self.over_config, self.over_config+'.new')
- diff_configs(self.over_config, self.over_config+'.new')
+ self.update_config(self.over_config, self.over_config + '.new')
+ diff_configs(self.over_config, self.over_config + '.new')
else:
self.over_config = self.orig_config
- def update_config(self, old_config, new_config = 'None'):
+ def update_config(self, old_config, new_config=None):
os.chdir(self.build_dir)
shutil.copyfile(old_config, self.build_config)
utils.system('yes "" | make oldconfig > /dev/null')
- if new_config:
+ if new_config is not None:
shutil.copyfile(self.build_config, new_config)
+
def config_record(self, name):
- #Copy the current .config file to the config.<name>[.<n>]
+ """
+ Copy the current .config file to the config.<name>[.<n>]
+ """
i = 1
- to = self.config_dir + '/config.%s' % name
+ to = os.path.join(self.config_dir, 'config.%s' % name)
while os.path.exists(to):
i += 1
- to = self.config_dir + '/config.%s.%d' % (name, i)
- shutil.copyfile(self.build_dir + '/.config', to)
+ to = os.path.join(self.config_dir, 'config.%s.%d' % (name, i))
+ shutil.copyfile(os.path.join(self.build_dir, '.config'), to)
--
1.7.10.1
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest