• Rae Moar's avatar
    kunit: tool: Add command line interface to filter and report attributes · 723c8258
    Rae Moar authored
    Add ability to kunit.py to filter attributes and report a list of tests
    including attributes without running tests.
    
    Add flag "--filter" to input filters on test attributes. Tests will be
    filtered out if they do not match all inputted filters.
    
    Example: --filter speed=slow (This filter would run only the tests that are
    marked as slow)
    
    Filters have operations: <, >, <=, >=, !=, and =. But note that the
    characters < and > are often interpreted by the shell, so they may need to
    be quoted or escaped.
    
    Example: --filter "speed>slow" or --filter speed\>slow (This filter would
    run only the tests that have the speed faster than slow.
    
    Additionally, multiple filters can be used.
    
    Example: --filter "speed=slow, module!=example" (This filter would run
    only the tests that have the speed slow and are not in the "example"
    module)
    
    Note if the user wants to skip filtered tests instead of not
    running/showing them use the "--filter_action=skip" flag instead.
    
    Expose the output of kunit.action=list option with flag "--list_tests" to
    output a list of tests. Additionally, add flag "--list_tests_attr" to
    output a list of tests and their attributes. These flags are useful to see
    tests and test attributes without needing to run tests.
    
    Example of the output of "--list_tests_attr":
      example
      example.test_1
      example.test_2
      # example.test_2.speed: slow
    
    This output includes a suite, example, with two test cases, test_1 and
    test_2. And in this instance test_2 has been marked as slow.
    Reviewed-by: default avatarDavid Gow <davidgow@google.com>
    Signed-off-by: default avatarRae Moar <rmoar@google.com>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    723c8258
kunit_tool_test.py 33.1 KB