Commits (2)
......@@ -206,6 +206,8 @@ def environment(ctx, build, vary):
removed += [k]
else:
added += [(k, v)]
if ctx.verbosity >= 1:
logger.info("ENVIRONMENT variation: added = (" + ','.join(map(str, added)) + ") removed = " + ''.join(removed))
return build.modify_env(added, removed)
def domain_host(ctx, build, vary):
......@@ -214,6 +216,8 @@ def domain_host(ctx, build, vary):
hostname = "reprotest-capture-hostname"
domainname = "reprotest-capture-domainname"
_ = build
if ctx.verbosity >= 1:
logger.info("DOMAIN_HOST variation: hostname = " + hostname + " domainname = " + domainname)
# TODO: below only works on linux, of course..
if ctx.spec.domain_host.use_sudo:
......@@ -249,12 +253,16 @@ def build_path(ctx, build, vary):
if vary:
return build
const_path = os.path.join(dirname(build.tree), 'const_build_path')
if ctx.verbosity >= 1:
logger.info("BUILD_PATH variation: const_path = " + const_path)
return build.move_tree(build.tree, const_path, True)
@tool_required("disorderfs")
def fileordering(ctx, build, vary):
if not vary:
return build
if ctx.verbosity >= 1:
logger.info("DISORDERFS variation: --shuffle-dirents=yes")
old_tree = os.path.join(dirname(build.tree), basename(build.tree) + '-before-disorderfs', '')
_ = build.move_tree(build.tree, old_tree, False)
......@@ -274,6 +282,8 @@ def home(ctx, build, vary):
# choose an existent HOME, see Debian bug #860428
return build.add_env('HOME', build.tree)
else:
if ctx.verbosity >= 1:
logger.info("HOME variation: HOME = /nonexistent/second-build")
return build.add_env('HOME', '/nonexistent/second-build')
# TODO: uname is a POSIX standard. The related Linux command
......@@ -289,10 +299,14 @@ def kernel(ctx, build, vary):
_ = _.append_setup_exec_raw('SETARCH_ARCH=$(setarch --list | grep -vF "$(uname -m)" | shuf | head -n1)')
_ = _.append_setup_exec_raw('KERNEL_VERSION=$(uname -r)')
_ = _.append_setup_exec_raw('if [ ${KERNEL_VERSION#2.6} = $KERNEL_VERSION ]; then SETARCH_OPTS=--uname-2.6; fi')
if ctx.verbosity >= 1:
_ = _.append_setup_exec_raw('echo "INFO:reprotest.build:KERNEL variation: SETARCH_ARCH = \'$SETARCH_ARCH\' SETARCH_OPTS = \'$SETARCH_OPTS\'" >&2')
return _.prepend_to_build_command_raw('setarch', '$SETARCH_ARCH', '$SETARCH_OPTS')
def aslr(ctx, build, vary):
if vary:
if ctx.verbosity >= 1:
logger.info("ASLR variation: ASLR enabled")
return build
return build.append_setup_exec_raw('SETARCH_OPTS="$SETARCH_OPTS -R"')
......@@ -311,8 +325,10 @@ def num_cpus(ctx, build, vary):
else shuf -i$((CPU_MIN + 1))-$CPU_MAX -n1; fi)')
# select CPU_NUM random cpus from the range 0..$((CPU_MAX-1))
cpu_list = "$(echo $(shuf -i0-$((CPU_MAX - 1)) -n$CPU_NUM) | tr ' ' ,)"
return _.prepend_to_build_command_raw('taskset', '-a', '-c', cpu_list)
_ = _.append_setup_exec_raw("export CPU_LIST=\"$(echo $(shuf -i0-$((CPU_MAX - 1)) -n$CPU_NUM) | tr ' ' ,)\"")
if vary and ctx.verbosity >= 1:
_ = _.append_setup_exec_raw('echo "INFO:reprotest.build:NUM_CPUS variation: cpu_list = $CPU_LIST" >&2')
return _.prepend_to_build_command_raw('taskset', '-a', '-c', '$CPU_LIST')
# TODO: if this locale doesn't exist on the system, Python's
# locales.getlocale() will return (None, None) rather than this
......@@ -333,11 +349,15 @@ def locales(ctx, build, vary):
# if there is an issue with this being random, we could instead select it
# based on a deterministic hash of the inputs
loc = random.choice(['fr_CH.UTF-8', 'es_ES', 'ru_RU.CP1251', 'kk_KZ.RK1048', 'zh_CN'])
if ctx.verbosity >= 1:
logger.info("LOCALE variation: LC_ALL = " + loc + " LANGUAGE = " + loc + ":fr")
return build.add_env('LANG', loc).add_env('LC_ALL', loc).add_env('LANGUAGE', '%s:fr' % loc)
def exec_path(ctx, build, vary):
if not vary:
return build
if ctx.verbosity >= 1:
logger.info("EXEC_PATH variation: PATH = " + build.env['PATH'] + ':/i_capture_the_path')
return build.add_env('PATH', build.env['PATH'] + ':/i_capture_the_path')
# This doesn't require superuser privileges, but the chsh command
......@@ -351,8 +371,12 @@ def timezone(ctx, build, vary):
# (http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08),
# so they should be cross-platform compatible.
if not vary:
if ctx.verbosity >= 1:
logger.info("TIMEZONE variation: TZ=GMT+12")
return build.add_env('TZ', 'GMT+12')
else:
if ctx.verbosity >= 1:
logger.info("TIMEZONE variation: TZ=GMT-14")
return build.add_env('TZ', 'GMT-14')
@tool_required("faketime")
......@@ -371,6 +395,8 @@ def faketime(ctx, build, vary):
if base < now - 15552000 and not random.randint(0, 1):
# if ctx.base_faketime is far in the past, with 1/2 probability
# reuse the current time and don't fake it
if ctx.verbosity >= 1:
logger.info("FAKETIME variation: enabled but chosen randomly not to fake!")
return build
else:
# otherwise use a date far in the future
......@@ -381,12 +407,16 @@ def faketime(ctx, build, vary):
# this is only mentioned in the README. we do not want this, it really really
# messes with GNU make and other buildsystems that look at timestamps.
# set NO_FAKE_STAT=1 avoids this.
if ctx.verbosity >= 1:
logger.info("FAKETIME variation: faketime = " + faket)
return build.add_env('NO_FAKE_STAT', '1').prepend_to_build_command('faketime', faket)
def umask(ctx, build, vary):
if not vary:
return build.append_setup_exec('umask', '0022')
else:
if ctx.verbosity >= 1:
logger.info("UMASK variation: umask 0002")
return build.append_setup_exec('umask', '0002')
......