Skip to content

Commit 224307e

Browse files
committed
selftest: use scripts/config for reliable kernel configuration
Root cause: vng --configitem is unreliable when .config already exists from a prior build — options may not actually get applied, leading to KCOV being compiled out despite CONFIG_KCOV=y being requested. Fix: explicitly run scripts/config --enable/--disable for each option then make olddefconfig before vng --build. This guarantees the .config has the correct values regardless of prior state. Also: - Verify critical configs in .config after build (print WARNING) - Print (no output, rc=N) when vng returns empty stdout/stderr - Show return code in HW mode failure messages Signed-off-by: Yunseong Kim <yunseong.kim@est.tech>
1 parent d3069e5 commit 224307e

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

selftest/run.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,22 @@ def kernel_build(kernel_src):
137137

138138

139139
def kernel_configure_and_build(kernel_src, configs):
140-
"""Configure + build in one step using vng --configitem + --build."""
140+
"""Configure + build in one step. Uses scripts/config for reliability."""
141141
if RUN_TARGET == "host":
142142
# On host, don't build — assume kernel is already built
143143
return True
144144

145145
print(" Configuring + building kernel...")
146+
147+
# Use scripts/config to force config options (vng --configitem is unreliable
148+
# when .config already exists from a previous build)
149+
script = os.path.join(kernel_src, "scripts/config")
150+
if os.path.isfile(script):
151+
for key, enable in configs.items():
152+
flag = "--enable" if enable else "--disable"
153+
run([script, flag, key], cwd=kernel_src, timeout=30)
154+
run(["make", f"LLVM={LLVM_SUFFIX}", "olddefconfig"], cwd=kernel_src, timeout=120)
155+
146156
cmd = ["vng"]
147157
for key, enable in configs.items():
148158
if enable:
@@ -152,8 +162,18 @@ def kernel_configure_and_build(kernel_src, configs):
152162
cmd += ["--build", f"LLVM={LLVM_SUFFIX}"]
153163
r = run(cmd, cwd=kernel_src, timeout=3600)
154164
if r.returncode != 0:
155-
vlog(r)
156-
return r.returncode == 0
165+
vlog(r, force=True)
166+
return False
167+
168+
# Verify critical configs were actually applied
169+
config_path = os.path.join(kernel_src, ".config")
170+
if os.path.isfile(config_path):
171+
with open(config_path) as f:
172+
config_text = f.read()
173+
for key, enable in configs.items():
174+
if enable and f"{key}=y" not in config_text:
175+
print(f" WARNING: {key}=y not found in .config!")
176+
return True
157177

158178

159179
def vng_run(kernel_src, cmd):
@@ -212,6 +232,9 @@ def vlog(r, force=False):
212232
return
213233
out = r.stdout.decode() if r.stdout else ""
214234
err = r.stderr.decode() if r.stderr else ""
235+
if not out and not err:
236+
print(f" (no output, rc={r.returncode})")
237+
return
215238
if out:
216239
for line in out.strip().split('\n')[-20:]:
217240
print(f" | {line}")
@@ -404,7 +427,7 @@ def test_intel_pt(vock_dir, kernel_src, arch_info):
404427
log("FAIL", f"hw+{backend}+vmlinux: no coverage")
405428
vlog(r, force=True)
406429
else:
407-
log("FAIL", f"hw+{backend}+vmlinux: failed")
430+
log("FAIL", f"hw+{backend}+vmlinux: failed (rc={r.returncode})")
408431
vlog(r, force=True)
409432
if "TRACE_OK=" in out:
410433
log("PASS", f" trace.log: {out.split('TRACE_OK=')[1].split()[0]} syscalls")

0 commit comments

Comments
 (0)