]> git.ipfire.org Git - thirdparty/linux.git/commit
unittests: test_kdoc_parser: add command line arg to read a YAML file
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 23 Mar 2026 09:10:45 +0000 (10:10 +0100)
committerJonathan Corbet <corbet@lwn.net>
Wed, 25 Mar 2026 19:36:45 +0000 (13:36 -0600)
commit3f049a5ba920f96df9eeb576d72c99535ab300f2
tree97e5c59c3f1968585509e995ec0173574712eef8
parent625ce45f2c39bf5059d33de573da624f4b2988cb
unittests: test_kdoc_parser: add command line arg to read a YAML file

The test_kdoc_parser.py already supports loading dynamic tests
when running unit tests.

Add support to read from a different file. This is useful for:
- regression tests before/afer some changes;
- preparing new unit tests;
- test a different yaml before adding its contents at
  tools/unittests/kdoc-test.yaml.

It should be noticed that passing an argument to a unit test
is not too trivial, as unittest core will load itself the
runner with a separate environment. The best (only?) way to
do it is by setting the system environment. This way, when
the class is called by the unit test loader, it can pick
the var from the environment without relying on a global
variable.

The unittest_helper has already provision for it, so let's
use its support.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <1d1a56de012c43756f9ca87aa9bf6c285674f113.1774256269.git.mchehab+huawei@kernel.org>
tools/unittests/test_kdoc_parser.py