From: Colin Ian King <colin.king(a)canonical.com>
There is a spelling mistake eprintf error message, fix it.
Signed-off-by: Colin Ian King <colin.king(a)canonical.com>
---
tools/testing/selftests/x86/mpx-mini-test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/x86/mpx-mini-test.c b/tools/testing/selftests/x86/mpx-mini-test.c
index 50f7e9272481..bf1bb15b6fbe 100644
--- a/tools/testing/selftests/x86/mpx-mini-test.c
+++ b/tools/testing/selftests/x86/mpx-mini-test.c
@@ -1503,7 +1503,7 @@ void check_mpx_insns_and_tables(void)
exit(20);
}
if (successes != total_nr_tests) {
- eprintf("ERROR: succeded fewer than number of tries (%d != %d)\n",
+ eprintf("ERROR: succeeded fewer than number of tries (%d != %d)\n",
successes, total_nr_tests);
exit(21);
}
--
2.19.1
Hi Linus,
Please pull the following Kselftest update for Linux 4.21-rc1.
This Kselftest update for Linux 4.21-rc1 consists of:
- fixes, and improvements to the framework, and individual tests.
- a new media test for IR encoders from Sean Young.
- a new watchdog test option to find time left on a timer.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 651022382c7f8da46cb4872a545ee1da6d097d2a:
Linux 4.20-rc1 (2018-11-04 15:37:52 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-4.21-rc1
for you to fetch changes up to 283ac6d5fb2a47f12bcef7806b78acf6ad89907e:
selftests: Fix test errors related to lib.mk khdr target (2018-12-17
09:17:55 -0700)
----------------------------------------------------------------
linux-kselftest-4.21-rc1
This Kselftest update for Linux 4.21-rc1 consists of:
- fixes, and improvements to the framework, and individual tests.
- a new media test for IR encoders from Sean Young.
- a new watchdog test option to find time left on a timer.
----------------------------------------------------------------
Colin Ian King (1):
selftests: watchdog: fix spelling mistake "experies" -> "expires"
Dan Rue (2):
selftests: firmware: remove use of non-standard diff -Z option
selftests: firmware: add CONFIG_FW_LOADER_USER_HELPER_FALLBACK to
config
Daniel Díaz (1):
selftests: gpio: Find libmount with pkg-config if available
Dmitry V. Levin (1):
selftests: do not macro-expand failed assertion expressions
Jerry Hoemann (1):
selftests: watchdog: Add gettimeleft command line arg
Sean Young (1):
media: rc: self test for IR encoders and decoders
Shuah Khan (1):
selftests: Fix test errors related to lib.mk khdr target
Thomas Gleixner (1):
selftests/ftrace: Fix invalid SPDX identifiers
Tom Murphy (1):
fix dma-buf/udmabuf selftest
tools/testing/selftests/Makefile | 2 +
tools/testing/selftests/android/Makefile | 2 +-
tools/testing/selftests/drivers/dma-buf/Makefile | 2 +
tools/testing/selftests/drivers/dma-buf/udmabuf.c | 11 +-
tools/testing/selftests/firmware/config | 1 +
tools/testing/selftests/firmware/fw_filesystem.sh | 9 +-
.../ftrace/test.d/ftrace/func-filter-stacktrace.tc | 2 +-
.../selftests/ftrace/test.d/ftrace/func_cpumask.tc | 2 +-
tools/testing/selftests/ftrace/test.d/template | 2 +-
.../selftests/ftrace/test.d/tracer/wakeup.tc | 2 +-
.../selftests/ftrace/test.d/tracer/wakeup_rt.tc | 2 +-
tools/testing/selftests/futex/functional/Makefile | 1 +
tools/testing/selftests/gpio/Makefile | 16 +-
tools/testing/selftests/ir/.gitignore | 1 +
tools/testing/selftests/ir/Makefile | 5 +
tools/testing/selftests/ir/ir_loopback.c | 199
+++++++++++++++++++++
tools/testing/selftests/ir/ir_loopback.sh | 20 +++
tools/testing/selftests/kselftest_harness.h | 42 ++---
tools/testing/selftests/kvm/Makefile | 2 +-
tools/testing/selftests/lib.mk | 8 +-
.../selftests/networking/timestamping/Makefile | 1 +
tools/testing/selftests/tc-testing/bpf/Makefile | 1 +
tools/testing/selftests/vm/Makefile | 1 +
tools/testing/selftests/watchdog/watchdog-test.c | 13 +-
24 files changed, 301 insertions(+), 46 deletions(-)
create mode 100644 tools/testing/selftests/ir/.gitignore
create mode 100644 tools/testing/selftests/ir/Makefile
create mode 100644 tools/testing/selftests/ir/ir_loopback.c
create mode 100755 tools/testing/selftests/ir/ir_loopback.sh
----------------------------------------------------------------
At present this exposes a bug in do_proc_dointvec_minmax_conv() (it
fails to check for values that are too wide to fit in an int).
Signed-off-by: Zev Weiss <zev(a)bewilderbeest.net>
---
tools/testing/selftests/sysctl/sysctl.sh | 37 ++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
index 584eb8ea780a..a7d0da25975c 100755
--- a/tools/testing/selftests/sysctl/sysctl.sh
+++ b/tools/testing/selftests/sysctl/sysctl.sh
@@ -290,6 +290,40 @@ run_numerictests()
test_rc
}
+check_failure()
+{
+ echo -n "Testing that $1 fails as expected..."
+ reset_vals
+ TEST_STR="$1"
+ orig="$(cat $TARGET)"
+ echo -n "$TEST_STR" > $TARGET 2> /dev/null
+
+ # write should fail and $TARGET should retain its original value
+ if [ $? = 0 ] || [ "$(cat $TARGET)" != "$orig" ]; then
+ echo "FAIL" >&2
+ rc=1
+ else
+ echo "ok"
+ fi
+ test_rc
+}
+
+run_wideint_tests()
+{
+ # check negative and positive 64-bit values, with and without
+ # bits set in the lower 31, and with and without bit 31 (sign
+ # bit of a 32-bit int) set. None of these are representable
+ # in 32 bits, and hence all should fail.
+ check_failure 0x0000010000000000
+ check_failure 0x0000010080000000
+ check_failure 0x000001ff7fffffff
+ check_failure 0x000001ffffffffff
+ check_failure 0xffffffff7fffffff
+ check_failure 0xffffffffffffffff
+ check_failure 0xffffff0000000000
+ check_failure 0xffffff0080000000
+}
+
# Your test must accept digits 3 and 4 to use this
run_limit_digit()
{
@@ -556,6 +590,7 @@ sysctl_test_0001()
TEST_STR=$(( $ORIG + 1 ))
run_numerictests
+ run_wideint_tests
run_limit_digit
}
@@ -580,6 +615,7 @@ sysctl_test_0003()
TEST_STR=$(( $ORIG + 1 ))
run_numerictests
+ run_wideint_tests
run_limit_digit
run_limit_digit_int
}
@@ -592,6 +628,7 @@ sysctl_test_0004()
TEST_STR=$(( $ORIG + 1 ))
run_numerictests
+ run_wideint_tests
run_limit_digit
run_limit_digit_uint
}
--
2.20.1
Test files created by test_create*() tests will stay in the $efivarfs_mount
directory until next reboot.
When the tester tries to run this efivarfs test again on the same system, the
immutable characteristics in that directory with those previously generated
files will cause some "Permission denied" noises and a false-positive test
result to the test_create_read() test.
Remove those test files in the end of each test to solve this issue.
Link: https://bugs.launchpad.net/bugs/1809704
Signed-off-by: Po-Hsu Lin <po-hsu.lin(a)canonical.com>
---
tools/testing/selftests/efivarfs/efivarfs.sh | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tools/testing/selftests/efivarfs/efivarfs.sh b/tools/testing/selftests/efivarfs/efivarfs.sh
index a47029a..ea2e2a0 100755
--- a/tools/testing/selftests/efivarfs/efivarfs.sh
+++ b/tools/testing/selftests/efivarfs/efivarfs.sh
@@ -60,6 +60,12 @@ test_create()
echo "$file has invalid size" >&2
exit 1
fi
+
+ rm $file 2>/dev/null
+ if [ $? -ne 0 ]; then
+ chattr -i $file
+ rm $file
+ fi
}
test_create_empty()
@@ -72,12 +78,24 @@ test_create_empty()
echo "$file can not be created without writing" >&2
exit 1
fi
+
+ rm $file 2>/dev/null
+ if [ $? -ne 0 ]; then
+ chattr -i $file
+ rm $file
+ fi
}
test_create_read()
{
local file=$efivarfs_mount/$FUNCNAME-$test_guid
./create-read $file
+
+ rm $file 2>/dev/null
+ if [ $? -ne 0 ]; then
+ chattr -i $file
+ rm $file
+ fi
}
test_delete()
--
2.7.4
Hi Sean,
I started to see compile errors on ir test. Could you please take a look
and see if you can fix them.
ir_loopback.c:32:16: error: field ‘proto’ has incomplete type
enum rc_proto proto;
^~~~~
ir_loopback.c:37:4: error: ‘RC_PROTO_RC5’ undeclared here (not in a
function)
{ RC_PROTO_RC5, "rc-5", 0x1f7f, "rc-5" },
^~~~~~~~~~~~
ir_loopback.c:38:4: error: ‘RC_PROTO_RC5X_20’ undeclared here (not in a
function); did you mean ‘RC_PROTO_RC5’?
{ RC_PROTO_RC5X_20, "rc-5x-20", 0x1f7f3f, "rc-5" },
^~~~~~~~~~~~~~~~
RC_PROTO_RC5
ir_loopback.c:39:4: error: ‘RC_PROTO_RC5_SZ’ undeclared here (not in a
function); did you mean ‘RC_PROTO_RC5X_20’?
{ RC_PROTO_RC5_SZ, "rc-5-sz", 0x2fff, "rc-5-sz" },
^~~~~~~~~~~~~~~
RC_PROTO_RC5X_20
ir_loopback.c:40:4: error: ‘RC_PROTO_JVC’ undeclared here (not in a
function); did you mean ‘RC_PROTO_RC5’?
{ RC_PROTO_JVC, "jvc", 0xffff, "jvc" },
^~~~~~~~~~~~
RC_PROTO_RC5
ir_loopback.c:41:4: error: ‘RC_PROTO_SONY12’ undeclared here (not in a
function); did you mean ‘RC_PROTO_JVC’?
{ RC_PROTO_SONY12, "sony-12", 0x1f007f, "sony" },
^~~~~~~~~~~~~~~
RC_PROTO_JVC
ir_loopback.c:42:4: error: ‘RC_PROTO_SONY15’ undeclared here (not in a
function); did you mean ‘RC_PROTO_SONY12’?
{ RC_PROTO_SONY15, "sony-15", 0xff007f, "sony" },
^~~~~~~~~~~~~~~
RC_PROTO_SONY12
ir_loopback.c:43:4: error: ‘RC_PROTO_SONY20’ undeclared here (not in a
function); did you mean ‘RC_PROTO_SONY15’?
{ RC_PROTO_SONY20, "sony-20", 0x1fff7f, "sony" },
^~~~~~~~~~~~~~~
RC_PROTO_SONY15
ir_loopback.c:44:4: error: ‘RC_PROTO_NEC’ undeclared here (not in a
function); did you mean ‘RC_PROTO_JVC’?
{ RC_PROTO_NEC, "nec", 0xffff, "nec" },
^~~~~~~~~~~~
RC_PROTO_JVC
ir_loopback.c:45:4: error: ‘RC_PROTO_NECX’ undeclared here (not in a
function); did you mean ‘RC_PROTO_NEC’?
{ RC_PROTO_NECX, "nec-x", 0xffffff, "nec" },
^~~~~~~~~~~~~
RC_PROTO_NEC
ir_loopback.c:46:4: error: ‘RC_PROTO_NEC32’ undeclared here (not in a
function); did you mean ‘RC_PROTO_NECX’?
{ RC_PROTO_NEC32, "nec-32", 0xffffffff, "nec" },
^~~~~~~~~~~~~~
RC_PROTO_NECX
ir_loopback.c:47:4: error: ‘RC_PROTO_SANYO’ undeclared here (not in a
function); did you mean ‘RC_PROTO_SONY20’?
{ RC_PROTO_SANYO, "sanyo", 0x1fffff, "sanyo" },
^~~~~~~~~~~~~~
RC_PROTO_SONY20
ir_loopback.c:48:4: error: ‘RC_PROTO_RC6_0’ undeclared here (not in a
function); did you mean ‘RC_PROTO_RC5_SZ’?
{ RC_PROTO_RC6_0, "rc-6-0", 0xffff, "rc-6" },
^~~~~~~~~~~~~~
RC_PROTO_RC5_SZ
ir_loopback.c:49:4: error: ‘RC_PROTO_RC6_6A_20’ undeclared here (not in
a function); did you mean ‘RC_PROTO_RC6_0’?
{ RC_PROTO_RC6_6A_20, "rc-6-6a-20", 0xfffff, "rc-6" },
^~~~~~~~~~~~~~~~~~
RC_PROTO_RC6_0
ir_loopback.c:50:4: error: ‘RC_PROTO_RC6_6A_24’ undeclared here (not in
a function); did you mean ‘RC_PROTO_RC6_6A_20’?
{ RC_PROTO_RC6_6A_24, "rc-6-6a-24", 0xffffff, "rc-6" },
^~~~~~~~~~~~~~~~~~
RC_PROTO_RC6_6A_20
ir_loopback.c:51:4: error: ‘RC_PROTO_RC6_6A_32’ undeclared here (not in
a function); did you mean ‘RC_PROTO_RC6_6A_24’?
{ RC_PROTO_RC6_6A_32, "rc-6-6a-32", 0xffffffff, "rc-6" },
^~~~~~~~~~~~~~~~~~
RC_PROTO_RC6_6A_24
ir_loopback.c:52:4: error: ‘RC_PROTO_RC6_MCE’ undeclared here (not in a
function); did you mean ‘RC_PROTO_RC6_0’?
{ RC_PROTO_RC6_MCE, "rc-6-mce", 0x00007fff, "rc-6" },
^~~~~~~~~~~~~~~~
RC_PROTO_RC6_0
ir_loopback.c:53:4: error: ‘RC_PROTO_SHARP’ undeclared here (not in a
function); did you mean ‘RC_PROTO_SANYO’?
{ RC_PROTO_SHARP, "sharp", 0x1fff, "sharp" },
^~~~~~~~~~~~~~
RC_PROTO_SANYO
ir_loopback.c: In function ‘main’:
ir_loopback.c:101:9: error: ‘LIRC_MODE_SCANCODE’ undeclared (first use
in this function); did you mean ‘LIRC_MODE_LIRCCODE’?
mode = LIRC_MODE_SCANCODE;
^~~~~~~~~~~~~~~~~~
LIRC_MODE_LIRCCODE
ir_loopback.c:101:9: note: each undeclared identifier is reported only
once for each function it appears in
thanks,
-- Shuah
If the cgroup destruction races with an exit() of a belonging
process(es), cg_kill_all() may fail. It's not a good reason to make
cg_destroy() fail and leave the cgroup in place, potentially causing
next test runs to fail.
Signed-off-by: Roman Gushchin <guro(a)fb.com>
Cc: Shuah Khan <shuah(a)kernel.org>
Cc: Tejun Heo <tj(a)kernel.org>
Cc: kernel-team(a)fb.com
Cc: linux-kselftest(a)vger.kernel.org
---
tools/testing/selftests/cgroup/cgroup_util.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 14c9fe284806..eba06f94433b 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -227,9 +227,7 @@ int cg_destroy(const char *cgroup)
retry:
ret = rmdir(cgroup);
if (ret && errno == EBUSY) {
- ret = cg_killall(cgroup);
- if (ret)
- return ret;
+ cg_killall(cgroup);
usleep(100);
goto retry;
}
--
2.19.2
Shuah,
I was recently investigating some errors coming out of our functional
tests and we, Dan and I, came up with a discussion that might not be new
for you, but, interests us, in defining how to better use kselftests as
a regression mechanism/tool in our LKFT (https://lkft.linaro.org).
David / Willem,
I'm only using udpgso as an example for what I'd like to ask Shuah. Feel
free to jump in in the discussion if you think its worth.
All,
Regarding: udpgso AND https://bugs.linaro.org/show_bug.cgi?id=3980
udpgso tests are failing in kernels bellow 4.18 because of 2 main reasons:
1) udp4_ufo_fragment does not seem to demand the GSO SKB to be > than
the MTU for older kernels (4th test case in udpgso.c).
2) setsockopt(...UDP_SEGMENT) support is not present for older kernels.
(commits "udp: generate gso with UDP_SEGMENT" and its fixes seem to be
needed).
With that explained, finally the question/discussion:
Shouldn't we enforce a versioning mechanism for tests that are testing
recently added features ? I mean, some of the tests inside udpgso
selftest are good enough for older kernels...
But, because we have no control over "kernel features" and "supported
test cases", we, Linaro, have to end up blacklisting all selftests that
have new feature oriented tests, because one or two test cases only.
This has already been solved in other functional tests projects:
allowing to check the running kernel version and deciding which test
cases to run.
Would that be something we should pursue ? (We could try to make patches
here and there, like this case, whenever we face this). Or... should we
stick with mainline/next only when talking about kselftest and forget
about LTS kernels ?
OBS: Situations like this are very time consuming before we can tell if
there was a regression or the older kernel did not support the test case.
Thank you for the attention.
Rafael
--
Rafael D. Tinoco
Linaro - Kernel Validation
From: Shuah Khan <shuah(a)kernel.org>
Commit b2d35fa5fc80 ("selftests: add headers_install to lib.mk") added
khdr target to run headers_install target from the main Makefile. The
logic uses KSFT_KHDR_INSTALL and top_srcdir as controls to initialize
variables and include files to run headers_install from the top level
Makefile. There are a few problems with this logic.
1. Exposes top_srcdir to all tests
2. Common logic impacts all tests
3. Uses KSFT_KHDR_INSTALL, top_srcdir, and khdr in an adhoc way. Tests
add "khdr" dependency in their Makefiles to TEST_PROGS_EXTENDED in
some cases, and STATIC_LIBS in other cases. This makes this framework
confusing to use.
The common logic that runs for all tests even when KSFT_KHDR_INSTALL
isn't defined by the test. top_srcdir is initialized to a default value
when test doesn't initialize it. It works for all tests without a sub-dir
structure and tests with sub-dir structure fail to build.
e.g: make -C sparc64/drivers/ or make -C drivers/dma-buf
../../lib.mk:20: ../../../../scripts/subarch.include: No such file or directory
make: *** No rule to make target '../../../../scripts/subarch.include'. Stop.
There is no reason to require all tests to define top_srcdir and there is
no need to require tests to add khdr dependency using adhoc changes to
TEST_* and other variables.
Fix it with a consistent use of KSFT_KHDR_INSTALL and top_srcdir from tests
that have the dependency on headers_install.
Change common logic to include khdr target define and "all" target with
dependency on khdr when KSFT_KHDR_INSTALL is defined.
Only tests that have dependency on headers_install have to define just
the KSFT_KHDR_INSTALL, and top_srcdir variables and there is no need to
specify khdr dependency in the test Makefiles.
Fixes: b2d35fa5fc80 ("selftests: add headers_install to lib.mk")
Cc: stable(a)vger.kernel.org
Signed-off-by: Shuah Khan <shuah(a)kernel.org>
---
tools/testing/selftests/android/Makefile | 2 +-
tools/testing/selftests/futex/functional/Makefile | 1 +
tools/testing/selftests/gpio/Makefile | 6 +++---
tools/testing/selftests/kvm/Makefile | 2 +-
tools/testing/selftests/lib.mk | 8 ++++----
tools/testing/selftests/networking/timestamping/Makefile | 1 +
tools/testing/selftests/tc-testing/bpf/Makefile | 1 +
tools/testing/selftests/vm/Makefile | 1 +
8 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile
index d9a725478375..72c25a3cb658 100644
--- a/tools/testing/selftests/android/Makefile
+++ b/tools/testing/selftests/android/Makefile
@@ -6,7 +6,7 @@ TEST_PROGS := run.sh
include ../lib.mk
-all: khdr
+all:
@for DIR in $(SUBDIRS); do \
BUILD_TARGET=$(OUTPUT)/$$DIR; \
mkdir $$BUILD_TARGET -p; \
diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
index ad1eeb14fda7..30996306cabc 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -19,6 +19,7 @@ TEST_GEN_FILES := \
TEST_PROGS := run.sh
top_srcdir = ../../../../..
+KSFT_KHDR_INSTALL := 1
include ../../lib.mk
$(TEST_GEN_FILES): $(HEADERS)
diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
index 46648427d537..07f572a1bd3f 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -10,8 +10,6 @@ TEST_PROGS_EXTENDED := gpio-mockup-chardev
GPIODIR := $(realpath ../../../gpio)
GPIOOBJ := gpio-utils.o
-include ../lib.mk
-
all: $(TEST_PROGS_EXTENDED)
override define CLEAN
@@ -19,7 +17,9 @@ override define CLEAN
$(MAKE) -C $(GPIODIR) OUTPUT=$(GPIODIR)/ clean
endef
-$(TEST_PROGS_EXTENDED):| khdr
+KSFT_KHDR_INSTALL := 1
+include ../lib.mk
+
$(TEST_PROGS_EXTENDED): $(GPIODIR)/$(GPIOOBJ)
$(GPIODIR)/$(GPIOOBJ):
diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index 01a219229238..52bfe5e76907 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -1,6 +1,7 @@
all:
top_srcdir = ../../../..
+KSFT_KHDR_INSTALL := 1
UNAME_M := $(shell uname -m)
LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/ucall.c lib/sparsebit.c
@@ -44,7 +45,6 @@ $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ)
all: $(STATIC_LIBS)
$(TEST_GEN_PROGS): $(STATIC_LIBS)
-$(STATIC_LIBS):| khdr
cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
cscope:
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 0a8e75886224..8b0f16409ed7 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -16,18 +16,18 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
+ifdef KSFT_KHDR_INSTALL
top_srcdir ?= ../../../..
include $(top_srcdir)/scripts/subarch.include
ARCH ?= $(SUBARCH)
-all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
-
.PHONY: khdr
khdr:
make ARCH=$(ARCH) -C $(top_srcdir) headers_install
-ifdef KSFT_KHDR_INSTALL
-$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr
+all: khdr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
+else
+all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
endif
.ONESHELL:
diff --git a/tools/testing/selftests/networking/timestamping/Makefile b/tools/testing/selftests/networking/timestamping/Makefile
index 14cfcf006936..c46c0eefab9e 100644
--- a/tools/testing/selftests/networking/timestamping/Makefile
+++ b/tools/testing/selftests/networking/timestamping/Makefile
@@ -6,6 +6,7 @@ TEST_PROGS := hwtstamp_config rxtimestamp timestamping txtimestamp
all: $(TEST_PROGS)
top_srcdir = ../../../../..
+KSFT_KHDR_INSTALL := 1
include ../../lib.mk
clean:
diff --git a/tools/testing/selftests/tc-testing/bpf/Makefile b/tools/testing/selftests/tc-testing/bpf/Makefile
index dc92eb271d9a..be5a5e542804 100644
--- a/tools/testing/selftests/tc-testing/bpf/Makefile
+++ b/tools/testing/selftests/tc-testing/bpf/Makefile
@@ -4,6 +4,7 @@ APIDIR := ../../../../include/uapi
TEST_GEN_FILES = action.o
top_srcdir = ../../../../..
+KSFT_KHDR_INSTALL := 1
include ../../lib.mk
CLANG ?= clang
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 6e67e726e5a5..e13eb6cc8901 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -25,6 +25,7 @@ TEST_GEN_FILES += virtual_address_range
TEST_PROGS := run_vmtests
+KSFT_KHDR_INSTALL := 1
include ../lib.mk
$(OUTPUT)/userfaultfd: LDLIBS += -lpthread
--
2.17.1
Hi Linus,
Please pull the following Kselftest update for Linux 4.20-rc7.
This Kselftest update for Linux 4.20-rc7 consists of a single fix for
seccomp test from Kees Cook.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 651022382c7f8da46cb4872a545ee1da6d097d2a:
Linux 4.20-rc1 (2018-11-04 15:37:52 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-4.20-rc7
for you to fetch changes up to 2bd61abead58c82714a1f6fa6beb0fd0df6a6d13:
selftests/seccomp: Remove SIGSTOP si_pid check (2018-12-11 17:57:30
-0700)
----------------------------------------------------------------
linux-kselftest-4.20-rc7
This Kselftest update for Linux 4.20-rc7 consists of a single fix for
seccomp test from Kees Cook.
----------------------------------------------------------------
Kees Cook (1):
selftests/seccomp: Remove SIGSTOP si_pid check
tools/testing/selftests/seccomp/seccomp_bpf.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------
From: Colin Ian King <colin.king(a)canonical.com>
There is a spelling mistake in the --gettimeleft help text, fix it.
Signed-off-by: Colin Ian King <colin.king(a)canonical.com>
---
tools/testing/selftests/watchdog/watchdog-test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index dac907a932ce..c2333c78cf04 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -78,7 +78,7 @@ static void usage(char *progname)
printf(" -T, --gettimeout Get the timeout\n");
printf(" -n, --pretimeout=T Set the pretimeout to T seconds\n");
printf(" -N, --getpretimeout Get the pretimeout\n");
- printf(" -L, --gettimeleft Get the time left until timer experies\n");
+ printf(" -L, --gettimeleft Get the time left until timer expires\n");
printf("\n");
printf("Parameters are parsed left-to-right in real-time.\n");
printf("Example: %s -d -t 10 -p 5 -e\n", progname);
--
2.19.1
Commit f149b3155744 ("signal: Never allocate siginfo for SIGKILL or SIGSTOP")
means that the seccomp selftest cannot check si_pid under SIGSTOP anymore.
Since it's believed[1] there are no other userspace things depending on the
old behavior, this removes the behavioral check in the selftest, since it's
more a "extra" sanity check (which turns out, maybe, not to have been
useful to test).
[1] https://lkml.kernel.org/r/CAGXu5jJaZAOzP1qFz66tYrtbuywqb+UN2SOA1VLHpCCOiYvY…
Reported-by: Tycho Andersen <tycho(a)tycho.ws>
Suggested-by: Eric W. Biederman <ebiederm(a)xmission.com>
Signed-off-by: Kees Cook <keescook(a)chromium.org>
---
Shuah, can you make sure that Linus gets this before v4.20 is released? Thanks!
---
tools/testing/selftests/seccomp/seccomp_bpf.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index e1473234968d..c9a2abf8be1b 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -2731,9 +2731,14 @@ TEST(syscall_restart)
ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
ASSERT_EQ(true, WIFSTOPPED(status));
ASSERT_EQ(SIGSTOP, WSTOPSIG(status));
- /* Verify signal delivery came from parent now. */
ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info));
- EXPECT_EQ(getpid(), info.si_pid);
+ /*
+ * There is no siginfo on SIGSTOP any more, so we can't verify
+ * signal delivery came from parent now (getpid() == info.si_pid).
+ * https://lkml.kernel.org/r/CAGXu5jJaZAOzP1qFz66tYrtbuywqb+UN2SOA1VLHpCCOiYvY…
+ * At least verify the SIGSTOP via PTRACE_GETSIGINFO.
+ */
+ EXPECT_EQ(SIGSTOP, info.si_signo);
/* Restart nanosleep with SIGCONT, which triggers restart_syscall. */
ASSERT_EQ(0, kill(child_pid, SIGCONT));
--
2.17.1
--
Kees Cook
If the cgroup destruction races with an exit() of a belonging
process(es), cg_kill_all() may fail. It's not a good reason to make
cg_destroy() fail and leave the cgroup in place, potentially causing
next test runs to fail.
Signed-off-by: Roman Gushchin <guro(a)fb.com>
Cc: Shuah Khan <shuah(a)kernel.org>
Cc: Tejun Heo <tj(a)kernel.org>
Cc: kernel-team(a)fb.com
Cc: linux-kselftest(a)vger.kernel.org
---
tools/testing/selftests/cgroup/cgroup_util.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 14c9fe284806..eba06f94433b 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -227,9 +227,7 @@ int cg_destroy(const char *cgroup)
retry:
ret = rmdir(cgroup);
if (ret && errno == EBUSY) {
- ret = cg_killall(cgroup);
- if (ret)
- return ret;
+ cg_killall(cgroup);
usleep(100);
goto retry;
}
--
2.17.2
On 11/28/18 12:56 PM, Rob Herring wrote:
>> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
>> index ad3fcad4d75b8..f309399deac20 100644
>> --- a/drivers/of/Kconfig
>> +++ b/drivers/of/Kconfig
>> @@ -15,6 +15,7 @@ if OF
>> config OF_UNITTEST
>> bool "Device Tree runtime unit tests"
>> depends on !SPARC
>> + depends on KUNIT
> Unless KUNIT has depends, better to be a select here.
That's just style or taste. I would prefer to use depends
instead of select, but that's also just my preference.
--
~Randy
arm64 has a feature called Top Byte Ignore, which allows to embed pointer
tags into the top byte of each pointer. Userspace programs (such as
HWASan, a memory debugging tool [1]) might use this feature and pass
tagged user pointers to the kernel through syscalls or other interfaces.
Right now the kernel is already able to handle user faults with tagged
pointers, due to these patches:
1. 81cddd65 ("arm64: traps: fix userspace cache maintenance emulation on a
tagged pointer")
2. 7dcd9dd8 ("arm64: hw_breakpoint: fix watchpoint matching for tagged
pointers")
3. 276e9327 ("arm64: entry: improve data abort handling of tagged
pointers")
When passing tagged pointers to syscalls, there's a special case of such a
pointer being passed to one of the memory syscalls (mmap, mprotect, etc.).
These syscalls don't do memory accesses but rather deal with memory
ranges, hence an untagged pointer is better suited.
This patchset extends tagged pointer support to non-memory syscalls. This
is done by reusing the untagged_addr macro to untag user pointers when the
kernel performs pointer checking to find out whether the pointer comes
from userspace (most notably in access_ok). The untagging is done only
when the pointer is being checked, the tag is preserved as the pointer
makes its way through the kernel.
One of the alternative approaches to untagging that was considered is to
completely strip the pointer tag as the pointer enters the kernel with
some kind of a syscall wrapper, but that won't work with the countless
number of different ioctl calls. With this approach we would need a custom
wrapper for each ioctl variation, which doesn't seem practical.
The following testing approaches has been taken to find potential issues
with user pointer untagging:
1. Static testing (with sparse [2] and separately with a custom static
analyzer based on Clang) to track casts of __user pointers to integer
types to find places where untagging needs to be done.
2. Dynamic testing: adding BUG_ON(has_tag(addr)) to find_vma() and running
a modified syzkaller version that passes tagged pointers to the kernel.
Based on the results of the testing the requried patches have been added
to the patchset.
This patchset has been merged into the Pixel 2 kernel tree and is now
being used to enable testing of Pixel 2 phones with HWASan.
This patchset is a prerequisite for ARM's memory tagging hardware feature
support [3].
Thanks!
[1] http://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html
[2] https://github.com/lucvoo/sparse-dev/commit/5f960cb10f56ec2017c128ef9d16060…
[3] https://community.arm.com/processors/b/blog/posts/arm-a-profile-architectur…
Changes in v8:
- Rebased onto 65102238 (4.20-rc1).
- Added a note to the cover letter on why syscall wrappers/shims that untag
user pointers won't work.
- Added a note to the cover letter that this patchset has been merged into
the Pixel 2 kernel tree.
- Documentation fixes, in particular added a list of syscalls that don't
support tagged user pointers.
Changes in v7:
- Rebased onto 17b57b18 (4.19-rc6).
- Dropped the "arm64: untag user address in __do_user_fault" patch, since
the existing patches already handle user faults properly.
- Dropped the "usb, arm64: untag user addresses in devio" patch, since the
passed pointer must come from a vma and therefore be untagged.
- Dropped the "arm64: annotate user pointers casts detected by sparse"
patch (see the discussion to the replies of the v6 of this patchset).
- Added more context to the cover letter.
- Updated Documentation/arm64/tagged-pointers.txt.
Changes in v6:
- Added annotations for user pointer casts found by sparse.
- Rebased onto 050cdc6c (4.19-rc1+).
Changes in v5:
- Added 3 new patches that add untagging to places found with static
analysis.
- Rebased onto 44c929e1 (4.18-rc8).
Changes in v4:
- Added a selftest for checking that passing tagged pointers to the
kernel succeeds.
- Rebased onto 81e97f013 (4.18-rc1+).
Changes in v3:
- Rebased onto e5c51f30 (4.17-rc6+).
- Added linux-arch@ to the list of recipients.
Changes in v2:
- Rebased onto 2d618bdf (4.17-rc3+).
- Removed excessive untagging in gup.c.
- Removed untagging pointers returned from __uaccess_mask_ptr.
Changes in v1:
- Rebased onto 4.17-rc1.
Changes in RFC v2:
- Added "#ifndef untagged_addr..." fallback in linux/uaccess.h instead of
defining it for each arch individually.
- Updated Documentation/arm64/tagged-pointers.txt.
- Dropped "mm, arm64: untag user addresses in memory syscalls".
- Rebased onto 3eb2ce82 (4.16-rc7).
Reviewed-by: Luc Van Oostenryck <luc.vanoostenryck(a)gmail.com>
Signed-off-by: Andrey Konovalov <andreyknvl(a)google.com>
Andrey Konovalov (8):
arm64: add type casts to untagged_addr macro
uaccess: add untagged_addr definition for other arches
arm64: untag user addresses in access_ok and __uaccess_mask_ptr
mm, arm64: untag user addresses in mm/gup.c
lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user
fs, arm64: untag user address in copy_mount_options
arm64: update Documentation/arm64/tagged-pointers.txt
selftests, arm64: add a selftest for passing tagged pointers to kernel
Documentation/arm64/tagged-pointers.txt | 25 +++++++++++--------
arch/arm64/include/asm/uaccess.h | 14 +++++++----
fs/namespace.c | 2 +-
include/linux/uaccess.h | 4 +++
lib/strncpy_from_user.c | 2 ++
lib/strnlen_user.c | 2 ++
mm/gup.c | 4 +++
tools/testing/selftests/arm64/.gitignore | 1 +
tools/testing/selftests/arm64/Makefile | 11 ++++++++
.../testing/selftests/arm64/run_tags_test.sh | 12 +++++++++
tools/testing/selftests/arm64/tags_test.c | 19 ++++++++++++++
11 files changed, 80 insertions(+), 16 deletions(-)
create mode 100644 tools/testing/selftests/arm64/.gitignore
create mode 100644 tools/testing/selftests/arm64/Makefile
create mode 100755 tools/testing/selftests/arm64/run_tags_test.sh
create mode 100644 tools/testing/selftests/arm64/tags_test.c
--
2.19.1.930.g4563a0d9d0-goog
If pkg-config is available, use it to define the CFLAGS and
LDLIBS needed for libmount; else, use the current hard-coded
paths and options.
Using pkg-config is very helpful for cross-compilation
environments, and is sometimes readily available on developer
boxes to ensure we get the right compiler/linker options for
the given package.
Signed-off-by: Daniel Díaz <daniel.diaz(a)linaro.org>
---
tools/testing/selftests/gpio/Makefile | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
index 46648427d537..f22b22aef7bf 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -1,7 +1,13 @@
# SPDX-License-Identifier: GPL-2.0
-CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
-LDLIBS += -lmount -I/usr/include/libmount
+MOUNT_CFLAGS := $(shell pkg-config --cflags mount 2>/dev/null)
+MOUNT_LDLIBS := $(shell pkg-config --libs mount 2>/dev/null)
+ifeq ($(MOUNT_LDLIBS),)
+MOUNT_LDLIBS := -lmount -I/usr/include/libmount
+endif
+
+CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ $(MOUNT_CFLAGS)
+LDLIBS += $(MOUNT_LDLIBS)
TEST_PROGS := gpio-mockup.sh
TEST_FILES := gpio-mockup-sysfs.sh
--
2.17.1
Your CC list is so huge that vger.kernel.org dropped all of your postings.
That CC list is not reasonable at all, trim it down to the most minimum
set. Probably 2 or 3 mailing lists, primarily netdev, and maybe a small
handful of specific developers.
Nothing more.
Hi,
The test outputs of those failures in seccomp_bpf as below:
---
m3ulcb:/opt/kselftest/seccomp# ./seccomp_bpf 61
[ RUN ] global.syscall_restart
seccomp_bpf.c:2754:global.syscall_restart:Expected 0x200 (512) == msg (256)
global.syscall_restart: Test terminated by assertion
[ FAIL ] global.syscall_restart
m3ulcb:/opt/kselftest/seccomp# seccomp_bpf.c:2685:global.syscall_restart:Expected 0 (0) == nanosleep(&timeout, ((void *)0)) (-1)
seccomp_bpf.c:2686:global.syscall_restart:Call to nanosleep() failed (errno 38)
seccomp_bpf.c:2690:global.syscall_restart:Expected 1 (1) == read(pipefd[0], &buf, 1) (0)
seccomp_bpf.c:2691:global.syscall_restart:Failed final read() from parent
seccomp_bpf.c:2693:global.syscall_restart:Expected '!' (33) == buf (46)
seccomp_bpf.c:2694:global.syscall_restart:Failed to get final data from read()
m3ulcb:/opt/kselftest/seccomp# ./seccomp_bpf 53
[ RUN ] global.detect_seccomp_filter_flags
seccomp_bpf.c:2104:global.detect_seccomp_filter_flags:Expected 14 (14) == (*__errno_location ()) (22)
seccomp_bpf.c:2106:global.detect_seccomp_filter_flags:Failed to detect that a known-good filter flag (0x4) is supported!
seccomp_bpf.c:2115:global.detect_seccomp_filter_flags:Expected 14 (14) == (*__errno_location ()) (22)
seccomp_bpf.c:2117:global.detect_seccomp_filter_flags:Failed to detect that all known-good filter flags (0x7) are supported!
global.detect_seccomp_filter_flags: Test failed at step #6
[ FAIL ] global.detect_seccomp_filter_flags
m3ulcb:/opt/kselftest/seccomp# ./seccomp_bpf 64
[ RUN ] global.get_metadata
seccomp_bpf.c:2914:global.get_metadata:Expected sizeof(md) (16) == ptrace(0x420d, pid, sizeof(md), &md) (-1)
global.get_metadata: Test terminated by assertion
[ FAIL ] global.get_metadata
---
Although I am not so familiar with SECCOMP and BPF, I checked some related documents and codes.
About the failures above, what the most confused me is that why it always give ENOSYS.
Am I missing something?
Thanks in advance.
PS:
I didn't run "make kselftest-merge" before compiling the kernel that I'm using.
---
The Test Environment:
- Kernel version: v4.14.0
The following configs were enabled.
- CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
- CONFIG_SECCOMP_FILTER=y
- CONFIG_SECCOMP=y
Best regards
Liu
On Wed, Nov 28, 2018 at 12:56 PM Rob Herring <robh(a)kernel.org> wrote:
>
> On Wed, Nov 28, 2018 at 1:38 PM Brendan Higgins
> <brendanhiggins(a)google.com> wrote:
> >
> > Migrate tests without any cleanup, or modifying test logic in anyway to
> > run under KUnit using the KUnit expectation and assertion API.
>
> Nice! You beat me to it. This is probably going to conflict with what
> is in the DT tree for 4.21. Also, please Cc the DT list for
> drivers/of/ changes.
Oh, I thought you were asking me to do it :-) In any case, I am happy to.
Oh yeah, sorry about not CC'ing the list.
Cheers
Hi,
This series separates tests using the RTC devices between the one
testing driver agnostic kernel facilities (timers) and the others that
are testing device drivers and hardware.
Then, rtctest is reworked to use the test harness and be much more
robust. Skipping tests is now easier and tests will not block
indefinitively.
I'm planning to send more improvements later this cycle.
Alexandre Belloni (4):
selftests: timers: move PIE tests out of rtctest
selftests: timers: rtcpie: restore previous PIE rate
selftests: move RTC tests to rtc subfolder
selftests: rtc: rework rtctest
MAINTAINERS | 2 +-
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/rtc/.gitignore | 2 +
tools/testing/selftests/rtc/Makefile | 9 +
tools/testing/selftests/rtc/rtctest.c | 238 +++++++++++
.../rtctest_setdate.c => rtc/setdate.c} | 0
tools/testing/selftests/timers/.gitignore | 3 +-
tools/testing/selftests/timers/Makefile | 4 +-
tools/testing/selftests/timers/rtcpie.c | 134 ++++++
tools/testing/selftests/timers/rtctest.c | 403 ------------------
10 files changed, 388 insertions(+), 408 deletions(-)
create mode 100644 tools/testing/selftests/rtc/.gitignore
create mode 100644 tools/testing/selftests/rtc/Makefile
create mode 100644 tools/testing/selftests/rtc/rtctest.c
rename tools/testing/selftests/{timers/rtctest_setdate.c => rtc/setdate.c} (100%)
create mode 100644 tools/testing/selftests/timers/rtcpie.c
delete mode 100644 tools/testing/selftests/timers/rtctest.c
--
2.17.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
If the cgroup destruction races with an exit() of a belonging
process(es), cg_kill_all() may fail. It's not a good reason to make
cg_destroy() fail and leave the cgroup in place, potentially causing
next test runs to fail.
Signed-off-by: Roman Gushchin <guro(a)fb.com>
Cc: Shuah Khan <shuah(a)kernel.org>
Cc: Tejun Heo <tj(a)kernel.org>
Cc: kernel-team(a)fb.com
Cc: linux-kselftest(a)vger.kernel.org
---
tools/testing/selftests/cgroup/cgroup_util.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 14c9fe284806..eba06f94433b 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -227,9 +227,7 @@ int cg_destroy(const char *cgroup)
retry:
ret = rmdir(cgroup);
if (ret && errno == EBUSY) {
- ret = cg_killall(cgroup);
- if (ret)
- return ret;
+ cg_killall(cgroup);
usleep(100);
goto retry;
}
--
2.17.2
This patch set proposes KUnit, a lightweight unit testing and mocking
framework for the Linux kernel.
Unlike Autotest and kselftest, KUnit is a true unit testing framework;
it does not require installing the kernel on a test machine or in a VM
and does not require tests to be written in userspace running on a host
kernel. Additionally, KUnit is fast: From invocation to completion KUnit
can run several dozen tests in under a second. Currently, the entire
KUnit test suite for KUnit runs in under a second from the initial
invocation (build time excluded).
KUnit is heavily inspired by JUnit, Python's unittest.mock, and
Googletest/Googlemock for C++. KUnit provides facilities for defining
unit test cases, grouping related test cases into test suites, providing
common infrastructure for running tests, mocking, spying, and much more.
## What's so special about unit testing?
A unit test is supposed to test a single unit of code in isolation,
hence the name. There should be no dependencies outside the control of
the test; this means no external dependencies, which makes tests orders
of magnitudes faster. Likewise, since there are no external dependencies,
there are no hoops to jump through to run the tests. Additionally, this
makes unit tests deterministic: a failing unit test always indicates a
problem. Finally, because unit tests necessarily have finer granularity,
they are able to test all code paths easily solving the classic problem
of difficulty in exercising error handling code.
## Is KUnit trying to replace other testing frameworks for the kernel?
No. Most existing tests for the Linux kernel are end-to-end tests, which
have their place. A well tested system has lots of unit tests, a
reasonable number of integration tests, and some end-to-end tests. KUnit
is just trying to address the unit test space which is currently not
being addressed.
## More information on KUnit
There is a bunch of documentation near the end of this patch set that
describes how to use KUnit and best practices for writing unit tests.
For convenience I am hosting the compiled docs here:
https://google.github.io/kunit-docs/third_party/kernel/docs/
## Changes Since Last Version
- Updated patchset to apply cleanly on 4.19.
- Stripped down patchset to focus on just the core features (I dropped
mocking, spying, and the MMIO stuff for now; you can find these
patches here: https://kunit-review.googlesource.com/c/linux/+/1132),
as suggested by Rob.
- Cleaned up some of the commit messages and tweaked commit order a
bit based on suggestions.
--
2.19.1.568.g152ad8e336-goog
Hello Andrew Jones,
The patch 14c47b7530e2: "kvm: selftests: introduce ucall" from Sep
18, 2018, leads to the following static checker warning:
./tools/testing/selftests/kvm/lib/ucall.c:61 ucall_init()
warn: always true condition '(gpa >= 0) => (0-u64max >= 0)'
./tools/testing/selftests/kvm/lib/ucall.c
28 void ucall_init(struct kvm_vm *vm, ucall_type_t type, void *arg)
29 {
30 ucall_type = type;
31 sync_global_to_guest(vm, ucall_type);
32
33 if (type == UCALL_PIO)
34 return;
35
36 if (type == UCALL_MMIO) {
37 vm_paddr_t gpa, start, end, step;
vm_paddr_t is a u64.
38 bool ret;
39
40 if (arg) {
41 gpa = (vm_paddr_t)arg;
42 ret = ucall_mmio_init(vm, gpa);
43 TEST_ASSERT(ret, "Can't set ucall mmio address to %lx", gpa);
44 return;
45 }
46
47 /*
48 * Find an address within the allowed virtual address space,
49 * that does _not_ have a KVM memory region associated with it.
50 * Identity mapping an address like this allows the guest to
51 * access it, but as KVM doesn't know what to do with it, it
52 * will assume it's something userspace handles and exit with
53 * KVM_EXIT_MMIO. Well, at least that's how it works for AArch64.
54 * Here we start with a guess that the addresses around two
55 * thirds of the VA space are unmapped and then work both down
56 * and up from there in 1/6 VA space sized steps.
57 */
58 start = 1ul << (vm->va_bits * 2 / 3);
59 end = 1ul << vm->va_bits;
60 step = 1ul << (vm->va_bits / 6);
61 for (gpa = start; gpa >= 0; gpa -= step) {
^^^^^^^^
So this doesn't work.
62 if (ucall_mmio_init(vm, gpa & ~(vm->page_size - 1)))
63 return;
64 }
65 for (gpa = start + step; gpa < end; gpa += step) {
66 if (ucall_mmio_init(vm, gpa & ~(vm->page_size - 1)))
67 return;
68 }
69 TEST_ASSERT(false, "Can't find a ucall mmio address");
70 }
71 }
regards,
dan carpenter
when CONFIG_TEST_SYSCTL=y, there is no "/sys/module/test_sysctl/"
when CONFIG_TEST_SYSCTL=m, checking /sys/module/test_sysctl/ is
before kernel module loading
you'll get below error message
root@intel-x86-64:/tmp/sysctl# ./sysctl.sh
Checking production write strict setting ... ok
./sysctl.sh: /sys/module/test_sysctl/ not present
You must have the following enabled in your kernel:
This patch will fix this issue.
when CONFIG_TEST_SYSCTL=y, it has no chance to check "/sys/module/test_sysctl/"
when CONFIG_TEST_SYSCTL=m, it will load kernel module first before checking sys
interface.
Signed-off-by: Lei Yang <Lei.Yang(a)windriver.com>
---
tools/testing/selftests/sysctl/sysctl.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
index 584eb8e..08dc995 100755
--- a/tools/testing/selftests/sysctl/sysctl.sh
+++ b/tools/testing/selftests/sysctl/sysctl.sh
@@ -120,6 +120,7 @@ test_reqs()
function load_req_mod()
{
+ trap "test_modprobe" EXIT
if [ ! -d $DIR ]; then
if ! modprobe -q -n $TEST_DRIVER; then
echo "$0: module $TEST_DRIVER not found [SKIP]"
@@ -770,7 +771,6 @@ function parse_args()
test_reqs
allow_user_defaults
check_production_sysctl_writes_strict
-test_modprobe
load_req_mod
trap "test_finish" EXIT
--
1.9.1
The listed bpf test case failed due to,
libbpf: object file doesn't contain bpf program
We are cross compiling, installing selftests on device under test
and running tests by using run_kselftest.sh script file.
selftests: bpf: test_maps
libbpf: object file doesn't contain bpf program
Failed to load SK_SKB parse prog
not ok 1..3 selftests: bpf: test_maps [FAIL]
selftests: bpf: test_progs
libbpf: object file doesn't contain bpf program
libbpf: object file doesn't contain bpf program
libbpf: object file doesn't contain bpf program
libbpf: object file doesn't contain bpf program
libbpf: ./test_tcp_estats.o doesn't provide kernel version
libbpf: object file doesn't contain bpf program
selftests: bpf: test_tcpbpf_user
libbpf: object file doesn't contain bpf program
FAILED: load_bpf_file failed for: test_tcpbpf_kern.o
not ok 1..10 selftests: bpf: test_tcpbpf_user [FAIL]
selftests: bpf: test_tcpnotify_user
libbpf: object file doesn't contain bpf program
FAILED: load_bpf_file failed for: test_tcpnotify_kern.o
not ok 1..21 selftests: bpf: test_tcpnotify_user [FAIL]
selftests: bpf: test_flow_dissector.sh
bpffs not mounted. Mounting...
libbpf: object file doesn't contain bpf program
./flow_dissector_load: bpf_prog_load bpf_flow.o
selftests: test_flow_dissector [FAILED]
Do you see problem when running on target devices ?
Best regards
Naresh Kamboju