1. 12 May, 2022 4 commits
    • Daniel Latypov's avatar
      kunit: tool: update test counts summary line format · c2497643
      Daniel Latypov authored
      Before:
      > Testing complete. Passed: 137, Failed: 0, Crashed: 0, Skipped: 36, Errors: 0
      
      After:
      > Testing complete. Ran 173 tests: passed: 137, skipped: 36
      
      Even with our current set of statuses, the output is a bit verbose.
      It could get worse in the future if we add more (e.g. timeout, kasan).
      Let's only print the relevant ones.
      
      I had previously been sympathetic to the argument that always
      printing out all the statuses would make it easier to parse results.
      But now we have commit acd8e840 ("kunit: Print test statistics on
      failure"), there are test counts printed out in the raw output.
      We don't currently print out an overall total across all suites, but it
      would be easy to add, if we see a need for that.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Co-developed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      c2497643
    • Daniel Latypov's avatar
      kunit: bail out of test filtering logic quicker if OOM · a02353f4
      Daniel Latypov authored
      When filtering what tests to run (suites and/or cases) via
      kunit.filter_glob (e.g. kunit.py run <glob>), we allocate copies of
      suites.
      
      These allocations can fail, and we largely don't handle that.
      Note: realistically, this probably doesn't matter much.
      We're not allocating much memory and this happens early in boot, so if
      we can't do that, then there's likely far bigger problems.
      
      This patch makes us immediately bail out from the top-level function
      (kunit_filter_suites) with -ENOMEM if any of the underlying kmalloc()
      calls return NULL.
      
      Implementation note: we used to return NULL pointers from some functions
      to indicate either that all suites/tests were filtered out or there was
      an error allocating the new array.
      
      We'll log a short error in this case and not run any tests or print a
      TAP header. From a kunit.py user's perspective, they'll get a message
      about missing/invalid TAP output and have to dig into the test.log to
      see it. Since hitting this error seems so unlikely, it's probably fine
      to not invent a way to plumb this error message more visibly.
      
      See also: https://lore.kernel.org/linux-kselftest/20220329103919.2376818-1-lv.ruyi@zte.com.cn/Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reported-by: default avatarZeal Robot <zealci@zte.com.cn>
      Reported-by: default avatarLv Ruyi <lv.ruyi@zte.com.cn>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      a02353f4
    • Daniel Latypov's avatar
      lib/Kconfig.debug: change KUnit tests to default to KUNIT_ALL_TESTS · dcbb2ee2
      Daniel Latypov authored
      This is in line with Documentation/dev-tools/kunit/style.rst.
      Some of these tests predate that so they don't follow this convention.
      
      With this and commit b0841b51 ("kunit: arch/um/configs: Enable
      KUNIT_ALL_TESTS by default"), kunit.py will now run these tests by
      default. This hopefully makes it easier to run and maintain the tests.
      If any of these were to start failing, people would notice much quicker.
      
      Note: this commit doesn't update LINEAR_RANGES_TEST since that would
      select its dependency (LINEAR_RANGES). We don't want KUNIT_ALL_TESTS
      to enable anything other than test kconfigs.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarNico Pache <npache@redhat.com>
      Acked-by: default avatarNico Pache <npache@redhat.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      dcbb2ee2
    • David Gow's avatar
      kunit: Rework kunit_resource allocation policy · ad69172e
      David Gow authored
      KUnit's test-managed resources can be created in two ways:
      - Using the kunit_add_resource() family of functions, which accept a
        struct kunit_resource pointer, typically allocated statically or on
        the stack during the test.
      - Using the kunit_alloc_resource() family of functions, which allocate a
        struct kunit_resource using kzalloc() behind the scenes.
      
      Both of these families of functions accept a 'free' function to be
      called when the resource is finally disposed of.
      
      At present, KUnit will kfree() the resource if this 'free' function is
      specified, and will not if it is NULL. However, this can lead
      kunit_alloc_resource() to leak memory (if no 'free' function is passed
      in), or kunit_add_resource() to incorrectly kfree() memory which was
      allocated by some other means (on the stack, as part of a larger
      allocation, etc), if a 'free' function is provided.
      
      Instead, always kfree() if the resource was allocated with
      kunit_alloc_resource(), and never kfree() if it was passed into
      kunit_add_resource() by the user. (If the user of kunit_add_resource()
      wishes the resource be kfree()ed, they can call kfree() on the resource
      from within the 'free' function.
      
      This is implemented by adding a 'should_free' member to
      struct kunit_resource and setting it appropriately. To facilitate this,
      the various resource add/alloc functions have been refactored somewhat,
      making them all call a __kunit_add_resource() helper after setting the
      'should_free' member appropriately. In the process, all other functions
      have been made static inline functions.
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Tested-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      ad69172e
  2. 02 May, 2022 4 commits
  3. 27 Apr, 2022 1 commit
  4. 05 Apr, 2022 2 commits
    • David Gow's avatar
      kunit: Make kunit_remove_resource() idempotent · 59729170
      David Gow authored
      The kunit_remove_resource() function is used to unlink a resource from
      the list of resources in the test, making it no longer show up in
      kunit_find_resource().
      
      However, this could lead to a race condition if two threads called
      kunit_remove_resource() on the same resource at the same time: the
      resource would be removed from the list twice (causing a crash at the
      second list_del()), and the refcount for the resource would be
      decremented twice (instead of once, for the reference held by the
      resource list).
      
      Fix both problems, the first by using list_del_init(), and the second by
      checking if the resource has already been removed using list_empty(),
      and only decrementing its refcount if it has not.
      
      Also add a KUnit test for the kunit_remove_resource() function which
      tests this behaviour.
      Reported-by: default avatarDaniel Latypov <dlatypov@google.com>
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      59729170
    • David Gow's avatar
      list: test: Test the hlist structure · 1ff522b6
      David Gow authored
      Add KUnit tests to the hlist linked-list structure which is used by
      hashtables. This should give coverage of every function and macro in
      list.h, as well as (combined with the KUnit tests for the hash
      functions) get very close to having tests for the hashtable structure.
      
      The tests here mirror the existing list tests, and are found in a new
      suite titled 'hlist'.
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      1ff522b6
  5. 04 Apr, 2022 18 commits
  6. 03 Apr, 2022 8 commits
  7. 02 Apr, 2022 3 commits
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-for-v5.18-2022-04-02' of... · be2d3ece
      Linus Torvalds authored
      Merge tag 'perf-tools-for-v5.18-2022-04-02' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull more perf tools updates from Arnaldo Carvalho de Melo:
      
       - Avoid SEGV if core.cpus isn't set in 'perf stat'.
      
       - Stop depending on .git files for building PERF-VERSION-FILE, used in
         'perf --version', fixing some perf tools build scenarios.
      
       - Convert tracepoint.py example to python3.
      
       - Update UAPI header copies from the kernel sources: socket,
         mman-common, msr-index, KVM, i915 and cpufeatures.
      
       - Update copy of libbpf's hashmap.c.
      
       - Directly return instead of using local ret variable in
         evlist__create_syswide_maps(), found by coccinelle.
      
      * tag 'perf-tools-for-v5.18-2022-04-02' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf python: Convert tracepoint.py example to python3
        perf evlist: Directly return instead of using local ret variable
        perf cpumap: More cpu map reuse by merge.
        perf cpumap: Add is_subset function
        perf evlist: Rename cpus to user_requested_cpus
        perf tools: Stop depending on .git files for building PERF-VERSION-FILE
        tools headers cpufeatures: Sync with the kernel sources
        tools headers UAPI: Sync drm/i915_drm.h with the kernel sources
        tools headers UAPI: Sync linux/kvm.h with the kernel sources
        tools kvm headers arm64: Update KVM headers from the kernel sources
        tools arch x86: Sync the msr-index.h copy with the kernel sources
        tools headers UAPI: Sync asm-generic/mman-common.h with the kernel
        perf beauty: Update copy of linux/socket.h with the kernel sources
        perf tools: Update copy of libbpf's hashmap.c
        perf stat: Avoid SEGV if core.cpus isn't set
      be2d3ece
    • Linus Torvalds's avatar
      Merge tag 'kbuild-fixes-v5.18' of... · d897b680
      Linus Torvalds authored
      Merge tag 'kbuild-fixes-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
      
      Pull Kbuild fixes from Masahiro Yamada:
      
       - Fix empty $(PYTHON) expansion.
      
       - Fix UML, which got broken by the attempt to suppress Clang warnings.
      
       - Fix warning message in modpost.
      
      * tag 'kbuild-fixes-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
        modpost: restore the warning message for missing symbol versions
        Revert "um: clang: Strip out -mno-global-merge from USER_CFLAGS"
        kbuild: Remove '-mno-global-merge'
        kbuild: fix empty ${PYTHON} in scripts/link-vmlinux.sh
        kconfig: remove stale comment about removed kconfig_print_symbol()
      d897b680
    • Linus Torvalds's avatar
      Merge tag 'mips_5.18_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux · 0b0fa57a
      Linus Torvalds authored
      Pull MIPS fixes from Thomas Bogendoerfer:
      
       - build fix for gpio
      
       - fix crc32 build problems
      
       - check for failed memory allocations
      
      * tag 'mips_5.18_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux:
        MIPS: crypto: Fix CRC32 code
        MIPS: rb532: move GPIOD definition into C-files
        MIPS: lantiq: check the return value of kzalloc()
        mips: sgi-ip22: add a check for the return of kzalloc()
      0b0fa57a