Explorar o código

utils/genrandconfig: improve logging

Right now, genrandconfig just spits out the random messages from the
different make invocations, which isn't terribly useful. Instead,
let's redirect the output of make invocations to oblivion, and add
some more high level logging.

As part of this logging, we're interested to see how many iterations
were needed to find a valid configuration, so changed the loop logic
to count from 0 to 100 instead of from 100 to 0 so that we can easily
show the iteration number.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
(cherry picked from commit ce3dedc26b9080399c44d86e14aa1704f7bf563a)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Thomas Petazzoni hai 11 meses
pai
achega
82346f7c8e
Modificáronse 1 ficheiros con 21 adicións e 7 borrados
  1. 21 7
      utils/genrandconfig

+ 21 - 7
utils/genrandconfig

@@ -524,23 +524,27 @@ async def gen_config(args):
     # things if needed.
     # things if needed.
     # Safe-guard, in case we can not quickly come to a valid
     # Safe-guard, in case we can not quickly come to a valid
     # configuration: allow at most 100 (arbitrary) iterations.
     # configuration: allow at most 100 (arbitrary) iterations.
-    bounded_loop = 100
+    loop = 0
     while True:
     while True:
-        if bounded_loop == 0:
+        if loop == 100:
             print("ERROR: cannot generate random configuration after 100 iterations",
             print("ERROR: cannot generate random configuration after 100 iterations",
                   file=sys.stderr)
                   file=sys.stderr)
             return 1
             return 1
-        bounded_loop -= 1
+        print("Generating configuration, loop %d" % loop)
+        loop += 1
         proc = await asyncio.create_subprocess_exec(
         proc = await asyncio.create_subprocess_exec(
             "make", "O=%s" % args.outputdir, "-C", args.buildrootdir,
             "make", "O=%s" % args.outputdir, "-C", args.buildrootdir,
             "KCONFIG_SEED=0x%s" % hexlify(os.urandom(4)).decode("ascii").upper(),
             "KCONFIG_SEED=0x%s" % hexlify(os.urandom(4)).decode("ascii").upper(),
             "KCONFIG_PROBABILITY=%d" % randint(1, 20),
             "KCONFIG_PROBABILITY=%d" % randint(1, 20),
-            "randconfig")
+            "randconfig",
+            stdout=asyncio.subprocess.DEVNULL,
+            stderr=asyncio.subprocess.DEVNULL)
         ret = await proc.wait()
         ret = await proc.wait()
         if ret:
         if ret:
             return ret
             return ret
 
 
         if await fixup_config(sysinfo, configfile):
         if await fixup_config(sysinfo, configfile):
+            print("  configuration valid")
             break
             break
 
 
     configlines = list()
     configlines = list()
@@ -563,20 +567,30 @@ async def gen_config(args):
     with open(configfile, "a") as configf:
     with open(configfile, "a") as configf:
         configf.writelines(configlines)
         configf.writelines(configlines)
 
 
+    print("  olddefconfig")
     proc = await asyncio.create_subprocess_exec(
     proc = await asyncio.create_subprocess_exec(
-        "make", "O=%s" % args.outputdir, "-C", args.buildrootdir, "olddefconfig")
+        "make", "O=%s" % args.outputdir, "-C", args.buildrootdir, "olddefconfig",
+        stdout=asyncio.subprocess.DEVNULL,
+        stderr=asyncio.subprocess.DEVNULL)
     ret = await proc.wait()
     ret = await proc.wait()
     if ret:
     if ret:
         return ret
         return ret
 
 
+    print("  savedefconfig")
     proc = await asyncio.create_subprocess_exec(
     proc = await asyncio.create_subprocess_exec(
-        "make", "O=%s" % args.outputdir, "-C", args.buildrootdir, "savedefconfig")
+        "make", "O=%s" % args.outputdir, "-C", args.buildrootdir, "savedefconfig",
+        stdout=asyncio.subprocess.DEVNULL,
+        stderr=asyncio.subprocess.DEVNULL)
+
     ret = await proc.wait()
     ret = await proc.wait()
     if ret:
     if ret:
         return ret
         return ret
 
 
+    print("  dependencies")
     proc = await asyncio.create_subprocess_exec(
     proc = await asyncio.create_subprocess_exec(
-        "make", "O=%s" % args.outputdir, "-C", args.buildrootdir, "dependencies")
+        "make", "O=%s" % args.outputdir, "-C", args.buildrootdir, "dependencies",
+        stdout=asyncio.subprocess.DEVNULL,
+        stderr=asyncio.subprocess.DEVNULL)
     return await proc.wait()
     return await proc.wait()