[Git][reproducible-builds/reprotest][wip-specify-cpus-argument] working proof of concept for num_cpus.cpus=X
Vagrant Cascadian (@vagrant)
gitlab at salsa.debian.org
Tue Feb 27 22:32:01 UTC 2024
Vagrant Cascadian pushed to branch wip-specify-cpus-argument at Reproducible Builds / reprotest
Commits:
cab6270c by Vagrant Cascadian at 2024-02-27T14:29:06-08:00
working proof of concept for num_cpus.cpus=X
- - - - -
1 changed file:
- reprotest/build.py
Changes:
=====================================
reprotest/build.py
=====================================
@@ -333,19 +333,21 @@ def aslr(ctx, build, vary):
def num_cpus(ctx, build, vary):
_ = build
- if ctx.num_cpus.cpus:
+ if not vary:
+ _ = _.append_setup_exec_raw('CPU_MAX=$(nproc)')
+ elif not ctx.spec.num_cpus.cpus:
_ = _.append_setup_exec_raw('CPU_MAX=$(nproc)')
else:
- _ = _.append_setup_exec_raw('CPU_MAX=%s' % ctx.num_cpus.cpus)
+ _ = _.append_setup_exec_raw('CPU_MAX=%s' % random.choice(ctx.spec.num_cpus.cpus))
_ = _.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')
- if ctx.num_cpus.cpus:
+ elif ctx.spec.num_cpus.cpus:
_ = _.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 echo %s; fi)' % ctx.num_cpus.cpus)
+ else echo %s; fi)' % random.choice(ctx.spec.num_cpus.cpus))
else:
# random number between min_cpus and $(nproc)
_ = _.append_setup_exec_raw('CPU_NUM=$(if [ $CPU_MIN = $CPU_MAX ]; \
@@ -589,10 +591,10 @@ class LocalesVariation(collections.namedtuple('_LocaleVariation', 'locale')):
def default(cls):
return cls(mdiffconf.strlist_set(";"))
-class NumCpusVariation(collections.namedtuple('_LocaleVariation', 'cpus')):
+class NumCpusVariation(collections.namedtuple('_NumCpusVariation', 'cpus')):
@classmethod
def default(cls):
- return None
+ return cls(mdiffconf.strlist_set(";"))
class VariationSpec(mdiffconf.ImmutableNamespace):
@classmethod
View it on GitLab: https://salsa.debian.org/reproducible-builds/reprotest/-/commit/cab6270cd27f1d9a29ea9604c6321f4f0a280c45
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/reprotest/-/commit/cab6270cd27f1d9a29ea9604c6321f4f0a280c45
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20240227/07f6fca6/attachment.htm>
More information about the rb-commits
mailing list