Commit ccba8b64 authored by Mathieu Desnoyers's avatar Mathieu Desnoyers Committed by Thomas Gleixner

rseq/selftests: Provide Makefile, scripts, gitignore

A run_param_test.sh script runs many variants of the parametrizable
tests.

Wire up the rseq Makefile, add directory entry into MAINTAINERS file.
Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dave Watson <davejwatson@fb.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: linux-kselftest@vger.kernel.org
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: Chris Lameter <cl@linux.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Andrew Hunter <ahh@google.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Paul Turner <pjt@google.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ben Maurer <bmaurer@fb.com>
Cc: linux-api@vger.kernel.org
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lkml.kernel.org/r/20180602124408.8430-17-mathieu.desnoyers@efficios.com
parent c960e990
...@@ -11986,6 +11986,7 @@ S: Supported ...@@ -11986,6 +11986,7 @@ S: Supported
F: kernel/rseq.c F: kernel/rseq.c
F: include/uapi/linux/rseq.h F: include/uapi/linux/rseq.h
F: include/trace/events/rseq.h F: include/trace/events/rseq.h
F: tools/testing/selftests/rseq/
RFKILL RFKILL
M: Johannes Berg <johannes@sipsolutions.net> M: Johannes Berg <johannes@sipsolutions.net>
......
...@@ -28,6 +28,7 @@ TARGETS += powerpc ...@@ -28,6 +28,7 @@ TARGETS += powerpc
TARGETS += proc TARGETS += proc
TARGETS += pstore TARGETS += pstore
TARGETS += ptrace TARGETS += ptrace
TARGETS += rseq
TARGETS += seccomp TARGETS += seccomp
TARGETS += sigaltstack TARGETS += sigaltstack
TARGETS += size TARGETS += size
......
basic_percpu_ops_test
basic_test
basic_rseq_op_test
param_test
param_test_benchmark
param_test_compare_twice
# SPDX-License-Identifier: GPL-2.0+ OR MIT
CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
LDLIBS += -lpthread
# Own dependencies because we only want to build against 1st prerequisite, but
# still track changes to header files and depend on shared object.
OVERRIDE_TARGETS = 1
TEST_GEN_PROGS = basic_test basic_percpu_ops_test param_test \
param_test_benchmark param_test_compare_twice
TEST_GEN_PROGS_EXTENDED = librseq.so
TEST_PROGS = run_param_test.sh
include ../lib.mk
$(OUTPUT)/librseq.so: rseq.c rseq.h rseq-*.h
$(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@
$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
$(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
$(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
rseq.h rseq-*.h
$(CC) $(CFLAGS) -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
$(OUTPUT)/param_test_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
rseq.h rseq-*.h
$(CC) $(CFLAGS) -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0+ or MIT
EXTRA_ARGS=${@}
OLDIFS="$IFS"
IFS=$'\n'
TEST_LIST=(
"-T s"
"-T l"
"-T b"
"-T b -M"
"-T m"
"-T m -M"
"-T i"
)
TEST_NAME=(
"spinlock"
"list"
"buffer"
"buffer with barrier"
"memcpy"
"memcpy with barrier"
"increment"
)
IFS="$OLDIFS"
REPS=1000
SLOW_REPS=100
function do_tests()
{
local i=0
while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
echo "Running test ${TEST_NAME[$i]}"
./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
echo "Running compare-twice test ${TEST_NAME[$i]}"
./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
let "i++"
done
}
echo "Default parameters"
do_tests
echo "Loop injection: 10000 loops"
OLDIFS="$IFS"
IFS=$'\n'
INJECT_LIST=(
"1"
"2"
"3"
"4"
"5"
"6"
"7"
"8"
"9"
)
IFS="$OLDIFS"
NR_LOOPS=10000
i=0
while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do
echo "Injecting at <${INJECT_LIST[$i]}>"
do_tests -${INJECT_LIST[i]} ${NR_LOOPS}
let "i++"
done
NR_LOOPS=
function inject_blocking()
{
OLDIFS="$IFS"
IFS=$'\n'
INJECT_LIST=(
"7"
"8"
"9"
)
IFS="$OLDIFS"
NR_LOOPS=-1
i=0
while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do
echo "Injecting at <${INJECT_LIST[$i]}>"
do_tests -${INJECT_LIST[i]} -1 ${@}
let "i++"
done
NR_LOOPS=
}
echo "Yield injection (25%)"
inject_blocking -m 4 -y
echo "Yield injection (50%)"
inject_blocking -m 2 -y
echo "Yield injection (100%)"
inject_blocking -m 1 -y
echo "Kill injection (25%)"
inject_blocking -m 4 -k
echo "Kill injection (50%)"
inject_blocking -m 2 -k
echo "Kill injection (100%)"
inject_blocking -m 1 -k
echo "Sleep injection (1ms, 25%)"
inject_blocking -m 4 -s 1
echo "Sleep injection (1ms, 50%)"
inject_blocking -m 2 -s 1
echo "Sleep injection (1ms, 100%)"
inject_blocking -m 1 -s 1
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