[U-Boot] [PATCH v2 4/8] test: py: add option to select device tree used during compilation

Patrick DELAUNAY patrick.delaunay at st.com
Tue May 21 18:32:50 UTC 2019


Hi Stephen,

For information after the remarksSimon's  remark, 
I simplify the test, so this part is no more needed
See http://patchwork.ozlabs.org/patch/1102938/

But I will answer with my status and my tests done on the python code.

> 
> On 5/20/19 7:00 AM, Patrick Delaunay wrote:
> > Only used for spl compilation which include the device tree (with
> > platdata or embedded device tree).
> > For U-boot, test use config.dtb, by default :
> >     "build_dir + '/arch/sandbox/dts/test.dtb'"
> >
> > Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
> > ---
> > I need to force o_dt = 'all' to avoid make error:
> >
> > make: *** empty string invalid as file name.  Stop.
> >
> > But, I don't sure that it is the better solution for pytest.
> 
> This feels a bit odd. What board are you compiling for? I would expect the same
> compilation commands to "just work" for all boards, and would initially claim that if
> they don't, it's a bug in the makefiles that should be fixed there.

Yes, it is strange.

When I compile the board I have not the problem, I have issue only when I use pytest.

For example:

./test/py/test.py --bd sandbox_spl --build --device-tree sandbox -k 'test_000_version'
+make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox_spl -s sandbox_spl_defconfig
+make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox_spl DEVICE_TREE=sandbox -s -j8

=> it tis OK

./test/py/test.py --bd sandbox --build  -k 'test_000_version'
+make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox -s sandbox_defconfig
+make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox all -s -j8

=> it is OK

But if I use =

        if build_dir != source_dir:
            o_opt = 'O=%s' % build_dir
        else:
            o_opt = 'all'

        if device_tree:
            o_dt = 'DEVICE_TREE=%s' % device_tree
        else:
            o_dt = ''

Same result for the first command : 
	./test/py/test.py --bd sandbox --build  -k 'test_000_version'
	=> it is OK

But the second command I have got the next error:

./test/py/test.py --bd sandbox --build  -k 'test_000_version'
+make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox -s sandbox_defconfig
+make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox  -s -j8
make: *** empty string invalid as file name.  Stop.
Exit code: 2
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/lib/python2.7/dist-packages/_pytest/main.py", line 86, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/usr/lib/python2.7/dist-packages/_pytest/config.py", line 830, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/usr/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 729, in call_historic
INTERNALERROR>     self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/usr/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/usr/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/usr/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/local/home/frq07632/views/u-boot/u-boot/test/py/conftest.py", line 148, in pytest_configure
INTERNALERROR>     runner.run(cmd, cwd=source_dir)
INTERNALERROR>   File "/local/home/frq07632/views/u-boot/u-boot/test/py/multiplexed_log.py", line 173, in run
INTERNALERROR>     raise exception
INTERNALERROR> Exception: Exit code: 2


Moreover when I execute the command manually (without python), the compilation is accepted.... 

$> make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox -s sandbox_defconfig
$> make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox  -s -j8


I also try: 

        options = []
        if build_dir != source_dir:
            options.append('O=%s ' % build_dir)
        if device_tree:
            options.append('DEVICE_TREE=%s ' % device_tree)
        o_opt = ' '.join(options)

        cmds = (
            ['make', o_opt, '-s', board_type + '_defconfig'],
            ['make', o_opt, '-s', '-j8'],
        )


Then the o_opt is correctly build but the DEVICE_TREE option is not used when the build is requested by python(it is done manually)

make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox_spl  DEVICE_TREE=bad  -s -j8

Device Tree Source is not correctly specified.
Please define 'CONFIG_DEFAULT_DEVICE_TREE'
or build with 'DEVICE_TREE=<device_tree>' argument

./test/py/test.py --bd sandbox_spl --build --device-tree bad -k 'test_000_version'

=> no error !

> > diff --git a/test/py/conftest.py b/test/py/conftest.py
> 
> > +        if device_tree:
> > +            o_dt = 'DEVICE_TREE=%s' % device_tree
> > +        else:
> > +            o_dt = 'all'
> 
> You might want to make o_dt be a list that's either empty or contains one string.
> Then ...
> 
> >           cmds = (
> >               ['make', o_opt, '-s', board_type + '_defconfig'],
> > -            ['make', o_opt, '-s', '-j8'],
> > +            ['make', o_opt, o_dt, '-s', '-j8'],
> >           )
> 
> ... you can modify that line so that it doesn't add any additional options if o_dt is
> empty, so there's no change to the command-line except in the case where a DT
> is specified, to avoid the potential for any change to the existing flow:
> 
>              ['make', o_opt, *o_dt, '-s', '-j8'],

Not OK for my setup :

./test/py/test.py --bd sandbox_spl --build --device-tree sandbox -k 'test_000_version'

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/_pytest/config.py", line 319, in _importconftest
    mod = conftestpath.pyimport()
  File "/usr/lib/python2.7/dist-packages/py/_path/local.py", line 650, in pyimport
    __import__(modname)
  File "/local/home/frq07632/views/u-boot/u-boot/test/py/conftest.py", line 143
    ['make', o_opt, *o_dt, '-s', '-j8'],
                    ^
SyntaxError: invalid syntax
ERROR: could not load /local/home/frq07632/views/u-boot/u-boot/test/py/conftest.py

> or:
> 
>              ['make', o_opt, '-s', '-j8'] + o_dt,

Also invalid (mising list and string.

So I am lost with my poor level of python.....

The only working test is :

    if config.getoption('build'):
        if build_dir != source_dir:
            o_opt = 'O=%s' % build_dir
        else:
            o_opt = ''

        cmds = (
            ['make', o_opt, '-s', board_type + '_defconfig'],
            ['make', o_opt, '-s', '-j8'],
        )
        if device_tree:
            cmds[1].append('DEVICE_TREE=%s' % device_tree)


So command with 'empty' string in cmds list for "make" cause the error ?

Anyway this patch is dropped in v3, I don't investigate more.

Regards

Patrick



More information about the U-Boot mailing list