Bug 16189 - qemurunner.run_serial() might report a false failure when command generate kernel log
Summary: qemurunner.run_serial() might report a false failure when command generate ke...
Status: RESOLVED FIXED
Alias: None
Product: Functional (self) Testing
Classification: QA/Testing
Component: oe-selftest (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 6.1 M4
Assignee: Yoann Congal
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2026-03-04 13:25 UTC by Yoann Congal
Modified: 2026-03-16 22:44 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yoann Congal 2026-03-04 13:25:09 UTC
While developing rust support for linux, I wrote a test containing
  status, _ = qemu.run_serial("modprobe rust_out_of_tree")
  self.assertEqual(status, 1, "Loading rust_out_of_tree module failed!")
these lines did fail intermittently.

With Harish Sadineni added logs[0]:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3432/steps/15/logs/stdio
  (qemu) 
  Waiting at most 1000 seconds for login banner (03/02/26 10:29:57)
  Connection from 127.0.0.1:35160
  Reached login banner in 2.84 seconds (03/02/26 10:30:00)
  Logged in as root in serial console
  2026-03-02 10:30:03,561 - oe-selftest - INFO - modprobe rust_minimal -> status=0, output=
  [    5.910903] rust_minimal: Rust minimal sample (init)
  0[    5.911126] rust_minimal: Am I built-in? false
  2026-03-02 10:30:09,346 - oe-selftest - INFO - 11: 13/57 301/670 (521.04s) (0 failed) (runtime_test.RustKernel.test_kernel_rust_sample)
  2026-03-02 10:30:09,346 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
    File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/runtime_test.py", line 528, in test_kernel_rust_sample
      self.assertEqual(status, 1, "Loading rust_minimal module failed!")
      ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.13/unittest/case.py", line 907, in assertEqual
      assertion_func(first, second, msg=msg)
      ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.13/unittest/case.py", line 900, in _baseAssertEqual
      raise self.failureException(msg)
  AssertionError: 0 != 1 : Loading rust_minimal module failed!

run_serial code is here: https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/utils/qemurunner.py#n661:
It runs "$command; echo $?" and read the last line to get the command exit code. 

I wonder if the kernel printing on the console prevents run_serial to correctly read the command exit code...
Maybe removing all console printing after banner (with the kernel.printk sysctl maybe) is a good idea?

Also, this intermittent error only happened on arm host and qemuarm64 machine, so maybe it's KVM timing related or/and qemuarm64 serial console configuration related...

[0]: https://lore.kernel.org/openembedded-core/56f69f79-77b8-4bdc-8401-f51d3e7d3bed@windriver.com/T/#u
Comment 1 Randy MacLeod 2026-03-05 15:46:46 UTC
Only seen on arm host and qemuarm64 emulator.

Ross mentioned that LabGrid had the same problem and 
they have a fix/work-around.
Comment 2 Ross Burton 2026-03-05 15:50:54 UTC
https://github.com/labgrid-project/labgrid/blob/master/labgrid/driver/shelldriver.py has the labgrid code where they generate a marker (taking care not to accidentally generate something like "ERROR") and use that to mark up where the exit code is.

Josh mentioned that labgrid also turns off kernel console messages when it connects, so we should likely do both.
Comment 3 Yoann Congal 2026-03-14 16:58:52 UTC
Patch sent: [PATCH] qemurunner: Hide kernel messages on first non-raw run_serial() call
https://lists.openembedded.org/g/openembedded-core/message/233091
Comment 4 Yoann Congal 2026-03-16 22:44:48 UTC
Merged: qemurunner: Hide kernel messages on first non-raw run_serial() call - openembedded-core - OpenEmbedded Core layer
https://git.openembedded.org/openembedded-core/commit/?id=2dc4d2f8b5c7a6e87291385fb860436593767199&h=master