1. 08 7月, 2022 3 次提交
  2. 17 5月, 2022 1 次提交
  3. 13 5月, 2022 1 次提交
    • D
      kunit: tool: stop using a shell to run kernel under QEMU · 3f0a50f3
      Daniel Latypov 提交于
      Note: this potentially breaks custom qemu_configs if people are using
      them! But the fix for them is simple, don't specify multiple arguments
      in one string and don't add on a redundant ''.
      
      It feels a bit iffy to be using a shell in the first place.
      
      There's the usual shenanigans where people could pass in arbitrary shell
      commands via --kernel_arg (since we're just adding '' around the
      kernel_cmdline) or via a custom qemu_config.
      This isn't too much of a concern given the nature of this script (and
      the qemu_config file is in python, you can do w/e you want already).
      
      But it does have some other drawbacks.
      
      One example of a kunit-specific pain point:
      If the relevant qemu binary is missing, we get output like this:
      > /bin/sh: line 1: qemu-system-aarch64: command not found
      This in turn results in our KTAP parser complaining about
      missing/invalid KTAP, but we don't directly show the error!
      It's even more annoying to debug when you consider --raw_output only
      shows KUnit output by default, i.e. you need --raw_output=all to see it.
      
      Whereas directly invoking the binary, Python will raise a
      FileNotFoundError for us, which is a noisier but more clear.
      
      Making this change requires
      * splitting parameters like ['-m 256'] into ['-m', '256'] in
        kunit/qemu_configs/*.py
      * change [''] to [] in kunit/qemu_configs/*.py since otherwise
        QEMU fails w/ 'Device needs media, but drive is empty'
      * dropping explicit quoting of the kernel cmdline
      * using shlex.quote() when we print what command we're running
        so the user can copy-paste and run it
      Signed-off-by: NDaniel Latypov <dlatypov@google.com>
      Reviewed-by: NBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      3f0a50f3
  4. 05 4月, 2022 2 次提交
  5. 26 1月, 2022 1 次提交
  6. 16 12月, 2021 1 次提交
    • D
      kunit: tool: fix newly introduced typechecker errors · 85310a62
      Daniel Latypov 提交于
      After upgrading mypy and pytype from pip, we see 2 new errors when
      running ./tools/testing/kunit/run_checks.py.
      
      Error #1: mypy and pytype
      They now deduce that importlib.util.spec_from_file_location() can return
      None and note that we're not checking for this.
      
      We validate that the arch is valid (i.e. the file exists) beforehand.
      Add in an `asssert spec is not None` to appease the checkers.
      
      Error #2: pytype bug https://github.com/google/pytype/issues/1057
      It doesn't like `from datetime import datetime`, specifically that a
      type shares a name with a module.
      
      We can workaround this by either
      * renaming the import or just using `import datetime`
      * passing the new `--fix-module-collisions` flag to pytype.
      
      We pick the first option for now because
      * the flag is quite new, only in the 2021.11.29 release.
      * I'd prefer if people can just run `pytype <file>`
      Signed-off-by: NDaniel Latypov <dlatypov@google.com>
      Reviewed-by: NBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      85310a62
  7. 14 12月, 2021 4 次提交
  8. 30 10月, 2021 1 次提交
  9. 26 10月, 2021 1 次提交
  10. 20 10月, 2021 3 次提交
  11. 13 7月, 2021 1 次提交
  12. 24 6月, 2021 1 次提交
  13. 12 6月, 2021 2 次提交
  14. 03 4月, 2021 1 次提交
  15. 09 2月, 2021 3 次提交
    • D
      kunit: tool: fix unintentional statefulness in run_kernel() · 7af29141
      Daniel Latypov 提交于
      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: 6ebf5866 ("kunit: tool: add Python wrappers for running KUnit tests")
      Signed-off-by: NDaniel Latypov <dlatypov@google.com>
      Reviewed-by: NBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      7af29141
    • D
      kunit: tool: add support for filtering suites by glob · d992880b
      Daniel Latypov 提交于
      This allows running different subsets of tests, e.g.
      
      $ ./tools/testing/kunit/kunit.py build
      $ ./tools/testing/kunit/kunit.py exec 'list*'
      $ ./tools/testing/kunit/kunit.py exec 'kunit*'
      
      This passes the "kunit_filter.glob" commandline option to the UML
      kernel, which currently only supports filtering by suite name.
      Signed-off-by: NDaniel Latypov <dlatypov@google.com>
      Reviewed-by: NBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      d992880b
    • D
      kunit: make kunit_tool accept optional path to .kunitconfig fragment · 243180f5
      Daniel Latypov 提交于
      Currently running tests via KUnit tool means tweaking a .kunitconfig
      file, which you'd keep around locally and never commit.
      This changes makes it so users can pass in a path to a kunitconfig.
      
      One of the imagined use cases is having kunitconfig fragments in-tree
      to formalize interesting sets of tests for features/subsystems, e.g.
        $ ./tools/testing/kunit/kunit.py run --kunticonfig=fs/ext4/kunitconfig
      
      For now, this hypothetical fs/ext4/kunitconfig would contain
        CONFIG_KUNIT=y
        CONFIG_EXT4_FS=y
        CONFIG_EXT4_KUNIT_TESTS=y
      
      At the moment, it's not hard to manually whip up this file, but as more
      and more tests get added, this will get tedious.
      
      It also opens the door to documenting how to run all the tests relevant
      to a specific subsystem or feature as a simple one-liner.
      
      This can be seen as an analogue to tools/testing/selftests/*/config
      But in the case of KUnit, the tests live in the same directory as the
      code-under-test, so it feels more natural to allow the kunitconfig
      fragments to live anywhere. (Though, people could create a separate
      directory if wanted; this patch imposes no restrictions on the path).
      Signed-off-by: NDaniel Latypov <dlatypov@google.com>
      Reviewed-by: NBrendan Higgins <brendanhiggins@google.com>
      Tested-by: NBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      243180f5
  16. 16 1月, 2021 2 次提交
  17. 05 1月, 2021 1 次提交
  18. 01 12月, 2020 1 次提交
  19. 11 11月, 2020 3 次提交
  20. 10 10月, 2020 1 次提交
    • D
      kunit: tool: fix display of make errors · 1abdd39f
      Daniel Latypov 提交于
      CalledProcessError stores the output of the failed process as `bytes`,
      not a `str`.
      
      So when we log it on build error, the make output is all crammed into
      one line with "\n" instead of actually printing new lines.
      
      After this change, we get readable output with new lines, e.g.
      >   CC      lib/kunit/kunit-example-test.o
      > In file included from ../lib/kunit/test.c:9:
      > ../include/kunit/test.h:22:1: error: unknown type name ‘invalid_type_that_causes_compile’
      >    22 | invalid_type_that_causes_compile errors;
      >       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      > make[3]: *** [../scripts/Makefile.build:283: lib/kunit/test.o] Error 1
      
      Secondly, trying to concat exceptions to strings will fail with
      > TypeError: can only concatenate str (not "OSError") to str
      so fix this with an explicit cast to str.
      Signed-off-by: NDaniel Latypov <dlatypov@google.com>
      Reviewed-by: NBrendan Higgins <brendanhiggins@google.com>
      Tested-by: NBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      1abdd39f
  21. 24 9月, 2020 1 次提交
  22. 18 7月, 2020 1 次提交
  23. 24 3月, 2020 1 次提交
  24. 21 3月, 2020 1 次提交
    • H
      kunit: Run all KUnit tests through allyesconfig · 021ed9f5
      Heidi Fahim 提交于
      Implemented the functionality to run all KUnit tests through kunit_tool
      by specifying an --alltests flag, which builds UML with allyesconfig
      enabled, and consequently runs every KUnit test. A new function was
      added to kunit_kernel: make_allyesconfig.
      Firstly, if --alltests is specified, kunit.py triggers build_um_kernel
      which call make_allyesconfig. This function calls the make command,
      disables the broken configs that would otherwise prevent UML from
      building, then starts the kernel with all possible configurations
      enabled. All stdout and stderr is sent to test.log and read from there
      then fed through kunit_parser to parse the tests to the user. Also added
      a signal_handler in case kunit is interrupted while running.
      Tested: Run under different conditions such as testing with
      --raw_output, testing program interrupt then immediately running kunit
      again without --alltests and making sure to clean the console.
      Signed-off-by: NHeidi Fahim <heidifahim@google.com>
      Reviewed-by: NBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      021ed9f5
  25. 20 2月, 2020 1 次提交
  26. 24 12月, 2019 1 次提交