mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] test: py: add dry run check for FIT image
@ 2026-01-16 10:14 Ahmad Fatoum
  2026-01-19 11:26 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 10:14 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

A dry run should not alter system state in a way that would inhibit
normal operation or repeated dry runs.

The FIT image boot in the test suite, however, reduces the VFS root's
reference count beyond the initial value before the bootm.

This leads to a warning on boot that can be reproduced by repeating the
dry run multiple times:

  FAILED test/py/test_fit.py::test_fit_dryrun -
	AssertionError: ['WARNING: at fs/fs.c:255/mntput()!',
			 'WARNING: refcount for mount "/" becomes negative']

Add a regression test for this issue.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
@Sascha, given that you introduced the warning, maybe you are interested
in looking into this? :-)
I am not sure if it's 9PFS related. It's reproducible with:

  pytest -x test/py/test_fit.py

On this has run once, you should be able to use --interactive and
reproduce this issue manually with repeating

  bootm -d /mnt/9p/testfs/barebox-gzipped.fit
---
 test/py/helper.py   | 14 ++++++++++++++
 test/py/test_fit.py | 36 ++++++++++++++++++++++++++++--------
 2 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/test/py/helper.py b/test/py/helper.py
index 756a06a8be66..4ed60ead1ef4 100644
--- a/test/py/helper.py
+++ b/test/py/helper.py
@@ -86,6 +86,20 @@ def devinfo(barebox, device):
     return info
 
 
+def filter_errors(lines):
+    prefixes = (
+        "WARNING:",
+        "ERROR:",
+        "CRITICAL:",
+        "ALERT:",
+        "EMERG:",
+        "PANIC:",
+        "BUG:",
+    )
+
+    return [line for line in lines if line.startswith(prefixes)]
+
+
 def format_dict_with_prefix(varset: dict, prefix: str) -> str:
     parts = []
     for k, v in varset.items():
diff --git a/test/py/test_fit.py b/test/py/test_fit.py
index e0999a01b0cb..3182fe8cf0d8 100644
--- a/test/py/test_fit.py
+++ b/test/py/test_fit.py
@@ -6,11 +6,7 @@ import pytest
 import shutil
 import subprocess
 from pathlib import Path
-from .helper import of_get_property
-
-
-def fit_name(suffix):
-    return f"/mnt/9p/testfs/barebox-{suffix}.fit"
+from .helper import of_get_property, filter_errors
 
 
 def generate_bootscript(barebox, image, name="test"):
@@ -58,11 +54,35 @@ def fit_testdata(barebox_config, testfs):
         pytest.skip(f"Skip dm tests due to missing dependency: {e}")
 
 
-def test_fit(barebox, strategy, testfs, fit_testdata):
-    _, _, returncode = barebox.run(f"ls {fit_name('gzipped')}")
+@pytest.fixture(scope="function")
+def fitimage(barebox, testfs, fit_testdata):
+    path = f"/mnt/9p/testfs/barebox-gzipped.fit"
+    _, _, returncode = barebox.run(f"ls {path}")
     if returncode != 0:
         pytest.xfail("skipping test due to missing FIT image")
 
+    return path
+
+
+def test_fit_dryrun(barebox, strategy, fitimage):
+    # Sanity check, this is only fixed up on first boot
+    assert of_get_property(barebox, "/chosen/barebox-version") is False
+    [ver] = barebox.run_check("echo barebox-$global.version")
+    assert ver.startswith('barebox-2')
+
+    barebox.run_check("global dyrun_attempts=5")
+    barebox.run_check('[ "$global.dyrun_attempts" = 5 ]')
+
+    for i in range(5):
+        stdout, _, _ = barebox.run(f"bootm -d -v {fitimage}")
+        errors = filter_errors(stdout)
+        assert errors == [], errors
+
+    # If we actually did boot, this variable would be undefined
+    barebox.run_check('[ "$global.dyrun_attempts" = 5 ]')
+
+
+def test_fit(barebox, strategy, fitimage):
     # Sanity check, this is only fixed up on first boot
     assert of_get_property(barebox, "/chosen/barebox-version") is False
     [ver] = barebox.run_check("echo barebox-$global.version")
@@ -76,7 +96,7 @@ def test_fit(barebox, strategy, testfs, fit_testdata):
 
     barebox.run_check("global linux.bootargs.testarg=barebox.chainloaded")
 
-    boottarget = generate_bootscript(barebox, fit_name('gzipped'))
+    boottarget = generate_bootscript(barebox, fitimage)
 
     with strategy.boot_barebox(boottarget) as barebox:
         assert of_get_property(barebox, "/chosen/barebox-version") == f'"{ver}"', \
-- 
2.47.3




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] test: py: add dry run check for FIT image
  2026-01-16 10:14 [PATCH] test: py: add dry run check for FIT image Ahmad Fatoum
@ 2026-01-19 11:26 ` Sascha Hauer
  2026-01-19 11:42   ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2026-01-19 11:26 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Fri, Jan 16, 2026 at 11:14:03AM +0100, Ahmad Fatoum wrote:
> A dry run should not alter system state in a way that would inhibit
> normal operation or repeated dry runs.
> 
> The FIT image boot in the test suite, however, reduces the VFS root's
> reference count beyond the initial value before the bootm.
> 
> This leads to a warning on boot that can be reproduced by repeating the
> dry run multiple times:
> 
>   FAILED test/py/test_fit.py::test_fit_dryrun -
> 	AssertionError: ['WARNING: at fs/fs.c:255/mntput()!',
> 			 'WARNING: refcount for mount "/" becomes negative']
> 
> Add a regression test for this issue.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
> ---
> @Sascha, given that you introduced the warning, maybe you are interested
> in looking into this? :-)
> I am not sure if it's 9PFS related. It's reproducible with:

No, it's not 9pfs related. It's the O_TMPFILE creation that bites us
here. I've sent a fix.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] test: py: add dry run check for FIT image
  2026-01-19 11:26 ` Sascha Hauer
@ 2026-01-19 11:42   ` Ahmad Fatoum
  0 siblings, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-01-19 11:42 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi,

On 1/19/26 12:26 PM, Sascha Hauer wrote:
> On Fri, Jan 16, 2026 at 11:14:03AM +0100, Ahmad Fatoum wrote:
>> A dry run should not alter system state in a way that would inhibit
>> normal operation or repeated dry runs.
>>
>> The FIT image boot in the test suite, however, reduces the VFS root's
>> reference count beyond the initial value before the bootm.
>>
>> This leads to a warning on boot that can be reproduced by repeating the
>> dry run multiple times:
>>
>>   FAILED test/py/test_fit.py::test_fit_dryrun -
>> 	AssertionError: ['WARNING: at fs/fs.c:255/mntput()!',
>> 			 'WARNING: refcount for mount "/" becomes negative']
>>
>> Add a regression test for this issue.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
>> ---
>> @Sascha, given that you introduced the warning, maybe you are interested
>> in looking into this? :-)
>> I am not sure if it's 9PFS related. It's reproducible with:
> 
> No, it's not 9pfs related. It's the O_TMPFILE creation that bites us
> here. I've sent a fix.

Thank you!
Ahmad

> 
> Sascha
> 




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-19 11:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-16 10:14 [PATCH] test: py: add dry run check for FIT image Ahmad Fatoum
2026-01-19 11:26 ` Sascha Hauer
2026-01-19 11:42   ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox