[reprotest] 01/01: Fix nondeterministic num_cpus-related test failures
Ximin Luo
infinity0 at debian.org
Fri Dec 15 15:05:12 UTC 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository reprotest.
commit 5ec344ea8504a266952c4db99ee917a83dcb08f6
Author: Ximin Luo <infinity0 at debian.org>
Date: Fri Dec 15 16:04:10 2017 +0100
Fix nondeterministic num_cpus-related test failures
---
debian/changelog | 8 ++++++++
debian/rules | 14 +++++++++++++-
debian/tests/control | 4 ++--
reprotest/build.py | 8 +++++---
4 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index c8e92a3..311df6c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+reprotest (0.7.6) UNRELEASED; urgency=medium
+
+ * Ensure num_cpus variation uses a different number of cpus in different
+ builds, and print a warning if only 1 cpu is available. (Closes: #884386)
+ * Don't test the num_cpus variation if only 1 cpu is available.
+
+ -- Ximin Luo <infinity0 at debian.org> Fri, 15 Dec 2017 16:00:44 +0100
+
reprotest (0.7.5) unstable; urgency=medium
[ Santiago Torres ]
diff --git a/debian/rules b/debian/rules
index bd560f3..3684c3c 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,12 +6,16 @@ export PYBUILD_NAME = reprotest
%:
dh $@ --with python3 --buildsystem=pybuild
+, := ,
# It's hard to make sure disorderfs works on buildds, so drop it.
# The build user needs fuse access and this is not easily arranged.
#
# To be user-friendly the user_group variation defaults to ON but is a no-op.
# This causes tests to fail since they expect something to be captured. So ignore it here
-export REPROTEST_TEST_DONTVARY = fileordering,user_group,domain_host
+#
+# Also disable the num_cpus variation if $(nproc) = 1 as there is no variation
+# in that case.
+export REPROTEST_TEST_DONTVARY = fileordering,user_group,domain_host$(if $(shell nproc | grep --color=no -Fx 1),$(,)num_cpus,)
override_dh_auto_configure:
test $$(python3 setup.py --version) = $$(dpkg-parsechangelog -SVersion)
@@ -32,6 +36,14 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_PROFILES)))
endif
endif
+# This is mean to be run by autopkgtest, and runs against the *installed*
+# version of reprotest. To run it against the development version, give
+# PYTHONPATH=$PWD. (Or just use override_dh_auto_test, above.)
+autopkgtest-pytest:
+# print the value, for debugging
+ REPROTEST_TEST_DONTVARY="$(REPROTEST_TEST_DONTVARY)"
+ pytest-3 $(if $(PYTEST_MARKEXPR),-m "$(PYTEST_MARKEXPR)",) $(PYTEST_ARGS)
+
override_dh_auto_clean:
dh_auto_clean
cd doc && $(MAKE) clean
diff --git a/debian/tests/control b/debian/tests/control
index c39729b..b1ddcd0 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,5 +1,5 @@
-Test-Command: env REPROTEST_TEST_DONTVARY=fileordering,user_group,domain_host pytest-3 -m "not need_builddeps"
+Test-Command: debian/rules autopkgtest-pytest PYTEST_MARKEXPR="not need_builddeps"
Depends: @, python3-pytest, faketime, locales-all, fakeroot
-Test-Command: env REPROTEST_TEST_DONTVARY=fileordering,user_group,domain_host pytest-3 -m "need_builddeps"
+Test-Command: debian/rules autopkgtest-pytest PYTEST_MARKEXPR="need_builddeps"
Depends: @, @builddeps@
diff --git a/reprotest/build.py b/reprotest/build.py
index 0e5c223..966d2f8 100644
--- a/reprotest/build.py
+++ b/reprotest/build.py
@@ -298,15 +298,17 @@ def aslr(ctx, build, vary):
def num_cpus(ctx, build, vary):
_ = build
- _ = _.append_setup_exec_raw('CPU_MAX=$(nproc --all)')
+ _ = _.append_setup_exec_raw('CPU_MAX=$(nproc)')
_ = _.append_setup_exec_raw('CPU_MIN=$({ echo $CPU_MAX; echo %s; } | sort -n | head -n1)' % ctx.min_cpus)
if ctx.min_cpus <= 0:
raise ValueError("--min-cpus must be a positive integer: " % ctx.min_cpus)
if not vary:
_ = _.append_setup_exec_raw('CPU_NUM=$CPU_MIN')
else:
- # random number between min_cpus and $(nproc --all)
- _ = _.append_setup_exec_raw('CPU_NUM=$(shuf -i$CPU_MIN-$CPU_MAX -n1)')
+ # random number between min_cpus and $(nproc)
+ _ = _.append_setup_exec_raw('CPU_NUM=$(if [ $CPU_MIN = $CPU_MAX ]; \
+ then echo $CPU_MIN; echo >&2 "only 1 CPU is available; num_cpus is ineffective"; \
+ 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 ' ' ,)"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/reprotest.git
More information about the Reproducible-commits
mailing list