[PATCH 1/3] test_fs: Allow running unprivileged

Simon Glass sjg at chromium.org
Sun Aug 18 17:25:37 CEST 2024


Hi Richard,

On Sun, Aug 18, 2024, 03:11 Richard Weinberger <richard at sigma-star.at> wrote:
>
> Am Freitag, 16. August 2024, 00:14:18 CEST schrieb Tom Rini:
> > This brings two new pylint errors:
> > test/py/tests/fs_helper.py:47:12: E0704: The raise statement is not inside an except clause (misplaced-bare-raise)
>
> This raise was on purpose, I wanted the test to fail when an unsupported filesystem is used.
> I have changed it to an assert 0.
>
> > test/py/tests/fs_helper.py:78:4: E1120: No value for argument 'src_dir' in function call (no-value-for-parameter)
>
> Fixed too.
>
> But I'm still wrestling with the Azure pipeline.
> After wasting^wspending a full afternoon, I think I know what is going on.
>
> With my patches applied, it always failed like that:
>
> ___________________________ test_ut_dm_init_bootstd ____________________________
> test/py/tests/test_ut.py:234: in setup_bootflow_image
>     u_boot_utils.run_and_log(cons, 'mkimage -f auto -d %s %s' %
> test/py/u_boot_utils.py:181: in run_and_log
>     output = runner.run(cmd, ignore_errors=ignore_errors, stdin=stdin, env=env)
> test/py/multiplexed_log.py:183: in run
>     raise exception
> test/py/multiplexed_log.py:141: in run
>     p = subprocess.Popen(cmd, cwd=cwd,
> /usr/lib/python3.10/subprocess.py:971: in __init__
>     self._execute_child(args, executable, preexec_fn, close_fds,
> /usr/lib/python3.10/subprocess.py:1863: in _execute_child
>     raise child_exception_type(errno_num, err_msg, err_filename)
> E   FileNotFoundError: [Errno 2] No such file or directory: 'mkimage'
>
> This makes little sense because I'm not touching mkimage nor PATH.
>
> It turned out that without my changes, mount_image() always fails
> inside the Azure pipeline.
> So, in setup_bootflow_image() the whole try/catch block around
> image creating, mounting it, etc.. fails and it always falls back
> to the prepared image via copy_prepared_image().
> The log print('Falled to create image, failing back to prepared copy: %s', str(exc))
> is never shown because the test itself succeeds.


> My patches change the tests to work without root privileges, so mount_image()
> is no longer needed and no exception occurs.
> As a consequence, mkimage is used the very first time on the Azure pipeline via:
> u_boot_utils.run_and_log(cons, 'mkimage -f auto -d %s %s' % (inf, os.path.join(scratch_dir, vmlinux)))
>
> To my best knowledge, u-boot-tools are not installed in the docker image,
> nor does the test framework install mkimage.
> So, the failure is expected.  Running test_ut.my manually always worked
> within my test bed because I had mkimage installed.
>
> So, can we please have mkimage inside the Docker image?

Sorry about all your trouble. Perhaps we should add a comment about
specifically what the code is for. Also, once you get all this in, we
can perhaps remove the fallbacks. I still get errors from qemu-img on
Ubuntu unless I chmod a+r /boot/* but presumably you don't use that
tool.

For mkinage, it would be better to use the version that is built in
CI, for sandbox. That is how the tools tests work.

Regards,
Simon


More information about the U-Boot mailing list