Commit 17eac6c2 authored by Shuah Khan's avatar Shuah Khan

selftests: Add kselftest-all and kselftest-install targets

Add kselftest-all target to build tests from the top level
Makefile. This is to simplify kselftest use-cases for CI and
distributions where build and test systems are different.

Current kselftest target builds and runs tests on a development
system which is a developer use-case.

Add kselftest-install target to install tests from the top level
Makefile. This is to simplify kselftest use-cases for CI and
distributions where build and test systems are different.

This change addresses requests from developers and testers to add
support for installing kselftest from the main Makefile.

In addition, make the install directory the same when install is
run using "make kselftest-install" or by running kselftest_install.sh.
Also fix the INSTALL_PATH variable conflict between main Makefile and
selftests Makefile.
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
Acked-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 54ecb8f7
...@@ -1237,9 +1237,8 @@ PHONY += kselftest ...@@ -1237,9 +1237,8 @@ PHONY += kselftest
kselftest: kselftest:
$(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
PHONY += kselftest-clean kselftest-%: FORCE
kselftest-clean: $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
$(Q)$(MAKE) -C $(srctree)/tools/testing/selftests clean
PHONY += kselftest-merge PHONY += kselftest-merge
kselftest-merge: kselftest-merge:
......
...@@ -171,9 +171,12 @@ run_pstore_crash: ...@@ -171,9 +171,12 @@ run_pstore_crash:
# 1. output_dir=kernel_src # 1. output_dir=kernel_src
# 2. a separate output directory is specified using O= KBUILD_OUTPUT # 2. a separate output directory is specified using O= KBUILD_OUTPUT
# 3. a separate output directory is specified using KBUILD_OUTPUT # 3. a separate output directory is specified using KBUILD_OUTPUT
# Avoid conflict with INSTALL_PATH set by the main Makefile
# #
INSTALL_PATH ?= $(BUILD)/install KSFT_INSTALL_PATH ?= $(BUILD)/kselftest_install
INSTALL_PATH := $(abspath $(INSTALL_PATH)) KSFT_INSTALL_PATH := $(abspath $(KSFT_INSTALL_PATH))
# Avoid changing the rest of the logic here and lib.mk.
INSTALL_PATH := $(KSFT_INSTALL_PATH)
ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
install: all install: all
...@@ -203,6 +206,7 @@ ifdef INSTALL_PATH ...@@ -203,6 +206,7 @@ ifdef INSTALL_PATH
echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \ echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
echo "cd $$TARGET" >> $(ALL_SCRIPT); \ echo "cd $$TARGET" >> $(ALL_SCRIPT); \
echo -n "run_many" >> $(ALL_SCRIPT); \ echo -n "run_many" >> $(ALL_SCRIPT); \
echo -n "Emit Tests for $$TARGET\n"; \
$(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \ $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
echo "" >> $(ALL_SCRIPT); \ echo "" >> $(ALL_SCRIPT); \
echo "cd \$$ROOT" >> $(ALL_SCRIPT); \ echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
......
...@@ -24,12 +24,12 @@ main() ...@@ -24,12 +24,12 @@ main()
echo "$0: Installing in specified location - $install_loc ..." echo "$0: Installing in specified location - $install_loc ..."
fi fi
install_dir=$install_loc/kselftest install_dir=$install_loc/kselftest_install
# Create install directory # Create install directory
mkdir -p $install_dir mkdir -p $install_dir
# Build tests # Build tests
INSTALL_PATH=$install_dir make install KSFT_INSTALL_PATH=$install_dir make install
} }
main "$@" main "$@"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment