utils/genrandconfig: allow overriding KCONFIG_PROBABILITY

Tweaking this variable should allow us to get better coverage of
packages with larger dependency trees.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit ea6bb507b1d3841be052525936121f7e88c43fbd)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
James Hilliard 2024-08-19 18:03:25 -06:00 committed by Peter Korsgaard
parent 3dd70ef15b
commit 72ef77c836

View File

@ -535,7 +535,7 @@ async def gen_config(args):
proc = await asyncio.create_subprocess_exec(
"make", "O=%s" % args.outputdir, "-C", args.buildrootdir,
"KCONFIG_SEED=0x%s" % hexlify(os.urandom(4)).decode("ascii").upper(),
"KCONFIG_PROBABILITY=%d" % randint(1, 20),
"KCONFIG_PROBABILITY=%d" % args.probability,
"randconfig",
stdout=asyncio.subprocess.DEVNULL,
stderr=asyncio.subprocess.DEVNULL)
@ -596,6 +596,21 @@ async def gen_config(args):
if __name__ == '__main__':
import argparse
class Range(argparse.Action):
def __init__(self, minimum=None, maximum=None, *args, **kwargs):
self.min = minimum
self.max = maximum
kwargs["metavar"] = "[%d-%d]" % (self.min, self.max)
super(Range, self).__init__(*args, **kwargs)
def __call__(self, parser, namespace, value, option_string=None):
if not (self.min <= value <= self.max):
msg = 'invalid choice: %r (choose from [%d-%d])' % \
(value, self.min, self.max)
raise argparse.ArgumentError(self, msg)
setattr(namespace, self.dest, value)
parser = argparse.ArgumentParser(description="Generate a random configuration")
parser.add_argument("--outputdir", "-o",
help="Output directory (relative to current directory)",
@ -603,6 +618,10 @@ if __name__ == '__main__':
parser.add_argument("--buildrootdir", "-b",
help="Buildroot directory (relative to current directory)",
type=str, default='.')
parser.add_argument("--probability", "-p",
help="Override the KCONFIG_PROBABILITY value",
type=int, action=Range, minimum=0, maximum=100,
default=randint(1, 20))
parser.add_argument("--toolchains-csv", help="Legacy, unused", type=str)
parser.add_argument("--no-toolchains-csv", help="Legacy, unused", type=bool)