linux/tools/testing/kunit
Daniel Latypov 7af29141a3 kunit: tool: fix unintentional statefulness in run_kernel()
This is a bug that has been present since the first version of this
code.
Using [] as a default parameter is dangerous, since it's mutable.

Example using the REPL:
>>> def bad(param = []):
...     param.append(len(param))
...     print(param)
...
>>> bad()
[0]
>>> bad()
[0, 1]

This wasn't a concern in the past since it would just keep appending the
same values to it.

E.g. before, `args` would just grow in size like:
  [mem=1G', 'console=tty']
  [mem=1G', 'console=tty', mem=1G', 'console=tty']

But with now filter_glob, this is more dangerous, e.g.
  run_kernel(filter_glob='my-test*') # default modified here
  run_kernel()			     # filter_glob still applies here!
That earlier `filter_glob` will affect all subsequent calls that don't
specify `args`.

Note: currently the kunit tool only calls run_kernel() at most once, so
it's not possible to trigger any negative side-effects right now.

Fixes: 6ebf5866f2 ("kunit: tool: add Python wrappers for running KUnit tests")
Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2021-02-08 16:10:22 -07:00
..
configs
test_data kunit: tools: fix kunit_tool tests for parsing test plans 2020-10-26 13:25:40 -06:00
.gitignore
kunit_config.py kunit: tool: simplify kconfig is_subset_of() logic 2021-02-08 15:38:55 -07:00
kunit_json.py kunit: tool: surface and address more typing issues 2021-01-15 17:49:34 -07:00
kunit_kernel.py kunit: tool: fix unintentional statefulness in run_kernel() 2021-02-08 16:10:22 -07:00
kunit_parser.py kunit: tool: fix minor typing issue with None status 2021-01-15 17:51:47 -07:00
kunit_tool_test.py kunit: tool: add support for filtering suites by glob 2021-02-08 16:10:00 -07:00
kunit.py kunit: tool: add support for filtering suites by glob 2021-02-08 16:10:00 -07:00