1. 19 11月, 2020 1 次提交
  2. 07 10月, 2020 1 次提交
  3. 01 9月, 2020 1 次提交
    • G
      selftests: more general make nesting support · f69237e1
      Greg Thelen 提交于
      selftests can be built from the toplevel kernel makefile (e.g. make
      kselftest-all) or directly (make -C tools/testing/selftests all).
      
      The toplevel kernel makefile explicitly disables implicit rules with
      "MAKEFLAGS += -rR", which is passed to tools/testing/selftests.  Some
      selftest makefiles require implicit make rules, which is why
      commit 67d8712d ("selftests: Fix build failures when invoked from
      kselftest target") reenables implicit rules by clearing MAKEFLAGS if
      MAKELEVEL=1.
      
      So far so good.  However, if the toplevel makefile is called from an
      outer makefile then MAKELEVEL will be elevated, which breaks the
      MAKELEVEL equality test.
      Example wrapped makefile error:
        $ cat ~/Makefile
        all:
        	$(MAKE) defconfig
        	$(MAKE) kselftest-all
        $ make -sf ~/Makefile
          futex_wait_timeout.c /src/tools/testing/selftests/kselftest_harness.h   /src/tools/testing/selftests/kselftest.h ../include/futextest.h ../include/atomic.h ../include/logging.h -lpthread -lrt -o /src/tools/testing/selftests/futex/functional/futex_wait_timeout
        make[4]: futex_wait_timeout.c: Command not found
      
      Rather than checking $(MAKELEVEL), check for $(LINK.c), which is a more
      direct side effect of "make -R".  This enables arbitrary makefile
      nesting.
      Signed-off-by: NGreg Thelen <gthelen@google.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      f69237e1
  4. 08 8月, 2020 1 次提交
  5. 21 7月, 2020 1 次提交
    • B
      tc-testing: Add tdc to kselftests · 2b9843fb
      Briana Oursler 提交于
      Add tdc to existing kselftest infrastructure so that it can be run with
      existing kselftests. TDC now generates objects in objdir/kselftest
      without cluttering main objdir, leaves source directory clean, and
      installs correctly in kselftest_install, properly adding itself to
      run_kselftest.sh script.
      
      Add tc-testing as a target of selftests/Makefile. Create tdc.sh to run
      tdc.py targets with correct arguments. To support single target from
      selftest/Makefile, combine tc-testing/bpf/Makefile and
      tc-testing/Makefile. Move action.c up a directory to tc-testing/.
      
      Tested with:
       make O=/tmp/{objdir} TARGETS="tc-testing" kselftest
       cd /tmp/{objdir}
       cd kselftest
       cd tc-testing
       ./tdc.sh
      
       make -C tools/testing/selftests/ TARGETS=tc-testing run_tests
      
       make TARGETS="tc-testing" kselftest
       cd tools/testing/selftests
       ./kselftest_install.sh /tmp/exampledir
       My VM doesn't run all the kselftests so I commented out all except my
       target and net/pmtu.sh then:
       cd /tmp/exampledir && ./run_kselftest.sh
      Co-developed-by: NDavide Caratti <dcaratti@redhat.com>
      Signed-off-by: NDavide Caratti <dcaratti@redhat.com>
      Signed-off-by: NBriana Oursler <briana.oursler@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2b9843fb
  6. 29 6月, 2020 1 次提交
    • P
      selftests/fpu: Add an FPU selftest · 4185b3b9
      Petteri Aimonen 提交于
      Add a selftest for the usage of FPU code in kernel mode.
      
      Currently only implemented for x86. In the future, kernel FPU testing
      could be unified between the different architectures supporting it.
      
       [ bp:
      
        - Split out from a conglomerate patch, put comments over statements.
        - run the test only on debugfs write.
        - Add bare-minimum run_test_fpu.sh, run 1000 iterations on all CPUs
          by default.
        - Add conditionally -msse2 so that clang doesn't generate library
          calls.
        - Use cc-option to detect gcc 7.1 not supporting -mpreferred-stack-boundary=3 (amluto).
        - Document stuff so that we don't forget.
        - Fix:
           ld: lib/test_fpu.o: in function `test_fpu_get':
           >> test_fpu.c:(.text+0x16e): undefined reference to `__sanitizer_cov_trace_cmpd'
           >> ld: test_fpu.c:(.text+0x1a7): undefined reference to `__sanitizer_cov_trace_cmpd'
           ld: test_fpu.c:(.text+0x1e0): undefined reference to `__sanitizer_cov_trace_cmpd'
        ]
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NPetteri Aimonen <jpa@git.mail.kapsi.fi>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
      Link: https://lkml.kernel.org/r/20200624114646.28953-3-bp@alien8.de
      4185b3b9
  7. 17 6月, 2020 1 次提交
    • C
      tests: add close_range() tests · 2c5db60e
      Christian Brauner 提交于
      This adds basic tests for the new close_range() syscall.
      - test that no invalid flags can be passed
      - test that a range of file descriptors is correctly closed
      - test that a range of file descriptors is correctly closed if there there
        are already closed file descriptors in the range
      - test that max_fd is correctly capped to the current fdtable maximum
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Jann Horn <jannh@google.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Dmitry V. Levin <ldv@altlinux.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Florian Weimer <fweimer@redhat.com>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: linux-api@vger.kernel.org
      Cc: linux-kselftest@vger.kernel.org
      2c5db60e
  8. 20 5月, 2020 1 次提交
    • V
      selftests: introduce gen_tar Makefile target · a5f30467
      Veronika Kabatova 提交于
      The gen_kselftest_tar.sh always packages *all* selftests and doesn't
      pass along any variables to `make install` to influence what should be
      built. This can result in an early error on the command line ("Unknown
      tarball format TARGETS=XXX"), or unexpected test failures as the
      tarball contains tests people wanted to skip on purpose.
      
      Since the makefile already contains all the logic, we can add a target
      for packaging. Keep the default .gz target the script uses, and actually
      extend the supported formats by using tar's autodetection.
      
      To not break current workflows, keep the gen_kselftest_tar.sh script as
      it is, with an added suggestion to use the makefile target instead.
      Signed-off-by: NVeronika Kabatova <vkabatov@redhat.com>
      Reviewed-by: NStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      a5f30467
  9. 30 3月, 2020 1 次提交
  10. 25 3月, 2020 1 次提交
    • C
      selftests: add pid namespace ENOMEM regression test · 6952a4f6
      Christian Brauner 提交于
      We recently regressed (cf. [1] and its corresponding fix in [2]) returning
      ENOMEM when trying to create a process in a pid namespace whose init
      process/child subreaper has already died. This has caused confusion at
      least once before that (cf. [3]). Let's add a simple regression test to
      catch this in the future.
      
      [1]: 49cb2fc4 ("fork: extend clone3() to support setting a PID")
      [2]: b26ebfe1 ("pid: Fix error return value in some cases")
      [3]: 35f71bc0 ("fork: report pid reservation failure properly")
      Cc: Corey Minyard <cminyard@mvista.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Adrian Reber <areber@redhat.com>
      Cc: Dmitry Safonov <0x7f454c46@gmail.com>
      Cc: Andrei Vagin <avagin@gmail.com>
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      6952a4f6
  11. 24 3月, 2020 1 次提交
  12. 14 3月, 2020 1 次提交
  13. 11 2月, 2020 1 次提交
  14. 24 1月, 2020 1 次提交
  15. 18 1月, 2020 1 次提交
    • A
      selftests: add openat2(2) selftests · b28a10ae
      Aleksa Sarai 提交于
      Test all of the various openat2(2) flags. A small stress-test of a
      symlink-rename attack is included to show that the protections against
      ".."-based attacks are sufficient.
      
      The main things these self-tests are enforcing are:
      
        * The struct+usize ABI for openat2(2) and copy_struct_from_user() to
          ensure that upgrades will be handled gracefully (in addition,
          ensuring that misaligned structures are also handled correctly).
      
        * The -EINVAL checks for openat2(2) are all correctly handled to avoid
          userspace passing unknown or conflicting flag sets (most
          importantly, ensuring that invalid flag combinations are checked).
      
        * All of the RESOLVE_* semantics (including errno values) are
          correctly handled with various combinations of paths and flags.
      
        * RESOLVE_IN_ROOT correctly protects against the symlink rename(2)
          attack that has been responsible for several CVEs (and likely will
          be responsible for several more).
      
      Cc: Shuah Khan <shuah@kernel.org>
      Signed-off-by: NAleksa Sarai <cyphar@cyphar.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      b28a10ae
  16. 14 1月, 2020 1 次提交
    • D
      selftests/timens: Add Time Namespace test for supported clocks · 61c57676
      Dmitry Safonov 提交于
      A test to check that all supported clocks work on host and inside
      a new time namespace. Use both ways to get time: through VDSO and
      by entering the kernel with implicit syscall.
      
      Introduce a new timens directory in selftests framework for
      the next timens tests.
      
      Output on success:
       1..10
       ok 1 Passed for CLOCK_BOOTTIME (syscall)
       ok 2 Passed for CLOCK_BOOTTIME (vdso)
       ok 3 Passed for CLOCK_BOOTTIME_ALARM (syscall)
       ok 4 Passed for CLOCK_BOOTTIME_ALARM (vdso)
       ok 5 Passed for CLOCK_MONOTONIC (syscall)
       ok 6 Passed for CLOCK_MONOTONIC (vdso)
       ok 7 Passed for CLOCK_MONOTONIC_COARSE (syscall)
       ok 8 Passed for CLOCK_MONOTONIC_COARSE (vdso)
       ok 9 Passed for CLOCK_MONOTONIC_RAW (syscall)
       ok 10 Passed for CLOCK_MONOTONIC_RAW (vdso)
       # Pass 10 Fail 0 Xfail 0 Xpass 0 Skip 0 Error 0
      
      Output with lack of permissions:
       1..10
       not ok 1 # SKIP need to run as root
      
      Output without support of time namespaces:
       1..10
       not ok 1 # SKIP Time namespaces are not supported
      Co-developed-by: NAndrei Vagin <avagin@openvz.org>
      Signed-off-by: NAndrei Vagin <avagin@gmail.com>
      Signed-off-by: NDmitry Safonov <dima@arista.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20191112012724.250792-29-dima@arista.com
      
      61c57676
  17. 11 1月, 2020 1 次提交
  18. 07 1月, 2020 1 次提交
    • C
      selftests: fix build behaviour on targets' failures · 5f70bde2
      Cristian Marussi 提交于
      Currently, when some of the KSFT subsystems fails to build, the toplevel
      KSFT Makefile just keeps carrying on with the build process.
      
      This behaviour is expected and desirable especially in the context of a CI
      system running KSelfTest, since it is not always easy to guarantee that the
      most recent and esoteric dependencies are respected across all KSFT TARGETS
      in a timely manner.
      
      Unfortunately, as of now, this holds true only if the very last of the
      built subsystems could have been successfully compiled: if the last of
      those subsystem instead failed to build, such failure is taken as the whole
      outcome of the Makefile target and the complete build/install process halts
      even though many other preceding subsytems were in fact already built
      successfully.
      
      Fix the KSFT Makefile behaviour related to all/install targets in order
      to fail as a whole only when the all/install targets have failed for all
      of the requested TARGETS, while succeeding when at least one of TARGETS
      has been successfully built.
      Signed-off-by: NCristian Marussi <cristian.marussi@arm.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      5f70bde2
  19. 05 12月, 2019 1 次提交
  20. 29 11月, 2019 1 次提交
  21. 08 11月, 2019 3 次提交
  22. 22 10月, 2019 1 次提交
  23. 17 10月, 2019 1 次提交
    • S
      selftests: Fix O= and KBUILD_OUTPUT handling for relative paths · 303e6218
      Shuah Khan 提交于
      Fix O= and KBUILD_OUTPUT handling for relative paths.
      
      export KBUILD_OUTPUT=../kselftest_size
      make TARGETS=size kselftest-all
      
      or
      
      make O=../kselftest_size TARGETS=size kselftest-all
      
      In both of these cases, targets get built in ../kselftest_size which is
      a one level up from the size test directory.
      
      make[1]: Entering directory '/mnt/data/lkml/kselftest_size'
      make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \
              ARCH=x86 -C ../../.. headers_install
        INSTALL ../kselftest_size/usr/include
      gcc -static -ffreestanding -nostartfiles -s    get_size.c  -o ../kselftest_size/size/get_size
      /usr/bin/ld: cannot open output file ../kselftest_size/size/get_size: No such file or directory
      collect2: error: ld returned 1 exit status
      make[3]: *** [../lib.mk:138: ../kselftest_size/size/get_size] Error 1
      make[2]: *** [Makefile:143: all] Error 2
      make[1]: *** [/mnt/data/lkml/linux_5.4/Makefile:1221: kselftest-all] Error 2
      make[1]: Leaving directory '/mnt/data/lkml/kselftest_size'
      make: *** [Makefile:179: sub-make] Error 2
      
      Use abs_objtree exported by the main Makefile.
      Reported-by: NTim Bird <Tim.Bird@sony.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      Tested-by: NTim Bird <tim.bird@sony.com>
      Acked-by: NTim Bird <tim.bird@sony.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      303e6218
  24. 02 10月, 2019 3 次提交
  25. 20 8月, 2019 1 次提交
  26. 10 7月, 2019 1 次提交
  27. 15 5月, 2019 1 次提交
  28. 09 5月, 2019 1 次提交
    • S
      selftests: fix install target to use default install path · c3c59928
      Shuah Khan 提交于
      Install target fails when INSTALL_PATH is undefined. Fix install target
      to use "output_dir/install as the default install location. "output_dir"
      is either the root of selftests directory under kernel source tree or
      output directory specified by O= or KBUILD_OUTPUT.
      
      e.g:
      make -C tools/testing/selftests install
      <installs under tools/testing/selftests/install>
      
      make O=/tmp/kselftest -C tools/testing/selftests install
      <installs under /tmp/kselftest/install>
      
      export KBUILD_OUTPUT=/tmp/kselftest
      make -C tools/testing/selftests install
      <installs under /tmp/kselftest/install>
      
      In addition, add "all" target as dependency to "install" to build and
      install using a single command.
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      c3c59928
  29. 26 4月, 2019 4 次提交
    • K
      selftests: Remove KSFT_TAP_LEVEL · f41c322f
      Kees Cook 提交于
      Since sub-testing can now be detected by indentation level, this removes
      KSFT_TAP_LEVEL so that subtests report their TAP header for later parsing.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      f41c322f
    • K
      selftests: Move test output to diagnostic lines · 5c069b6d
      Kees Cook 提交于
      This changes the selftest output so that each test's output is prefixed
      with "# " as a TAP "diagnostic line".
      
      This creates a bit of a kernel-specific TAP dialect where the diagnostics
      precede the results. The TAP spec isn't entirely clear about this, though,
      so I think it's the correct solution so as to keep interactive runs making
      sense. If the output _followed_ the result line in the spec-suggested
      YAML form, each test would dump all of its output at once instead of as
      it went, making debugging harder.
      
      This does, however, solve the recursive TAP output problem, as sub-tests
      will simply be prefixed by "# ". Parsing sub-tests becomes a simple
      problem of just removing the first two characters of a given top-level
      test's diagnostic output, and parsing the results.
      
      Note that the shell construct needed to both get an exit code from
      the first command in a pipe and still filter the pipe (to add the "# "
      prefix) uses a POSIX solution rather than the bash "pipefail" option
      which is not supported by dash.
      
      Since some test environments may have a very minimal set of utilities
      available, the new prefixing code will fall back to doing line-at-a-time
      prefixing if perl and/or stdbuf are not available.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      5c069b6d
    • K
      selftests: Extract logic for multiple test runs · bf660782
      Kees Cook 提交于
      This moves the logic for running multiple tests into a single "run_many"
      function of runner.sh. Both "run_tests" and "emit_tests" are modified to
      use it. Summary handling is now controlled by the "per_test_logging"
      shell flag.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      bf660782
    • K
      selftests: Use runner.sh for emit targets · d4e59a53
      Kees Cook 提交于
      This reuses the new runner.sh for the emit targets instead of manually
      running each test via run_kselftest.sh.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      d4e59a53
  30. 23 4月, 2019 1 次提交
    • S
      selftests: build and run gpio when output directory is the src dir · d917fb87
      Shuah Khan 提交于
      Build and run gpio when output directory is the src dir.  gpio has
      dependency on tools/gpio and builds tools/gpio objects in the src
      directory in all cases making the src repo dirty even when object
      relocation is specified.
      
      This fixes the following commands from generating gpio objects in
      the source repository:
      
      make O=dir kselftest
      export KBUILD_OUTPUT=dir; make kselftest
      make O=dir -C tools/testing/selftests
      expoert KBUILD_OUTPUT=dir; make -C tools/testing/selftests
      
      The following commands still build gpio objects in the source repo
      (gpio Makefile needs to fixed):
      make O=dir kselftest TARGETS="gpio"
      export KBUILD_OUTPUT=dir; make kselftest TARGETS="gpio"
      make O=dir -C tools/testing/selftests TARGETS="gpio"
      expoert KBUILD_OUTPUT=dir; make -C tools/testing/selftests TARGETS="gpio"
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      d917fb87
  31. 20 4月, 2019 1 次提交
    • S
      selftests: fix headers_install circular dependency · 8ce72dc3
      Shuah Khan 提交于
      "make kselftest" fails with "Circular Makefile.o <- prepare dependency
      dropped." error, when lib.mk invokes "make headers_install".
      
      Make level 0: Main make calls selftests run_tests target
      ...
      Make level n: selftests lib.mk invokes main make's headers_install
      
      The secondary level make inherits builtin-rules which will use the rule
      to generate Makefile.o  and runs into "Circular Makefile.o <- prepare
      dependency dropped." error, and kselftest compile fails.
      
      Invoke headers_install target with --no-builtin-rules to avoid circular
      error.
      
      In addition, lib.mk installs headers in the default HDR_PATH, even when
      build relocation is requested with O= or export KBUILD_OUTPUT. Fix the
      problem by passing in INSTALL_HDR_PATH. The headers are installed under
      the specified output "dir/usr".
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      8ce72dc3
  32. 18 4月, 2019 1 次提交
  33. 06 3月, 2019 1 次提交