aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>2018-06-02 08:44:08 -0400
committerThomas Gleixner <tglx@linutronix.de>2018-06-06 05:58:35 -0400
commitccba8b64452b8dbf2c9670de026d00f519bb5da0 (patch)
tree8517ee4dabc504cb2beac0af1474cf868c6332e0 /tools
parentc960e9909d33b9780534729afc42493328ca3e18 (diff)
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: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Thomas 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
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/Makefile1
-rw-r--r--tools/testing/selftests/rseq/.gitignore6
-rw-r--r--tools/testing/selftests/rseq/Makefile30
-rw-r--r--tools/testing/selftests/rseq/run_param_test.sh121
4 files changed, 158 insertions, 0 deletions
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 32aafa92074c..593fb44c9cd4 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -28,6 +28,7 @@ TARGETS += powerpc
28TARGETS += proc 28TARGETS += proc
29TARGETS += pstore 29TARGETS += pstore
30TARGETS += ptrace 30TARGETS += ptrace
31TARGETS += rseq
31TARGETS += seccomp 32TARGETS += seccomp
32TARGETS += sigaltstack 33TARGETS += sigaltstack
33TARGETS += size 34TARGETS += size
diff --git a/tools/testing/selftests/rseq/.gitignore b/tools/testing/selftests/rseq/.gitignore
new file mode 100644
index 000000000000..cc610da7e369
--- /dev/null
+++ b/tools/testing/selftests/rseq/.gitignore
@@ -0,0 +1,6 @@
1basic_percpu_ops_test
2basic_test
3basic_rseq_op_test
4param_test
5param_test_benchmark
6param_test_compare_twice
diff --git a/tools/testing/selftests/rseq/Makefile b/tools/testing/selftests/rseq/Makefile
new file mode 100644
index 000000000000..c30c52e1d0d2
--- /dev/null
+++ b/tools/testing/selftests/rseq/Makefile
@@ -0,0 +1,30 @@
1# SPDX-License-Identifier: GPL-2.0+ OR MIT
2CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
3LDLIBS += -lpthread
4
5# Own dependencies because we only want to build against 1st prerequisite, but
6# still track changes to header files and depend on shared object.
7OVERRIDE_TARGETS = 1
8
9TEST_GEN_PROGS = basic_test basic_percpu_ops_test param_test \
10 param_test_benchmark param_test_compare_twice
11
12TEST_GEN_PROGS_EXTENDED = librseq.so
13
14TEST_PROGS = run_param_test.sh
15
16include ../lib.mk
17
18$(OUTPUT)/librseq.so: rseq.c rseq.h rseq-*.h
19 $(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@
20
21$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
22 $(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
23
24$(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
25 rseq.h rseq-*.h
26 $(CC) $(CFLAGS) -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
27
28$(OUTPUT)/param_test_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
29 rseq.h rseq-*.h
30 $(CC) $(CFLAGS) -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
diff --git a/tools/testing/selftests/rseq/run_param_test.sh b/tools/testing/selftests/rseq/run_param_test.sh
new file mode 100644
index 000000000000..3acd6d75ff9f
--- /dev/null
+++ b/tools/testing/selftests/rseq/run_param_test.sh
@@ -0,0 +1,121 @@
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+ or MIT
3
4EXTRA_ARGS=${@}
5
6OLDIFS="$IFS"
7IFS=$'\n'
8TEST_LIST=(
9 "-T s"
10 "-T l"
11 "-T b"
12 "-T b -M"
13 "-T m"
14 "-T m -M"
15 "-T i"
16)
17
18TEST_NAME=(
19 "spinlock"
20 "list"
21 "buffer"
22 "buffer with barrier"
23 "memcpy"
24 "memcpy with barrier"
25 "increment"
26)
27IFS="$OLDIFS"
28
29REPS=1000
30SLOW_REPS=100
31
32function do_tests()
33{
34 local i=0
35 while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
36 echo "Running test ${TEST_NAME[$i]}"
37 ./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
38 echo "Running compare-twice test ${TEST_NAME[$i]}"
39 ./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
40 let "i++"
41 done
42}
43
44echo "Default parameters"
45do_tests
46
47echo "Loop injection: 10000 loops"
48
49OLDIFS="$IFS"
50IFS=$'\n'
51INJECT_LIST=(
52 "1"
53 "2"
54 "3"
55 "4"
56 "5"
57 "6"
58 "7"
59 "8"
60 "9"
61)
62IFS="$OLDIFS"
63
64NR_LOOPS=10000
65
66i=0
67while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do
68 echo "Injecting at <${INJECT_LIST[$i]}>"
69 do_tests -${INJECT_LIST[i]} ${NR_LOOPS}
70 let "i++"
71done
72NR_LOOPS=
73
74function inject_blocking()
75{
76 OLDIFS="$IFS"
77 IFS=$'\n'
78 INJECT_LIST=(
79 "7"
80 "8"
81 "9"
82 )
83 IFS="$OLDIFS"
84
85 NR_LOOPS=-1
86
87 i=0
88 while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do
89 echo "Injecting at <${INJECT_LIST[$i]}>"
90 do_tests -${INJECT_LIST[i]} -1 ${@}
91 let "i++"
92 done
93 NR_LOOPS=
94}
95
96echo "Yield injection (25%)"
97inject_blocking -m 4 -y
98
99echo "Yield injection (50%)"
100inject_blocking -m 2 -y
101
102echo "Yield injection (100%)"
103inject_blocking -m 1 -y
104
105echo "Kill injection (25%)"
106inject_blocking -m 4 -k
107
108echo "Kill injection (50%)"
109inject_blocking -m 2 -k
110
111echo "Kill injection (100%)"
112inject_blocking -m 1 -k
113
114echo "Sleep injection (1ms, 25%)"
115inject_blocking -m 4 -s 1
116
117echo "Sleep injection (1ms, 50%)"
118inject_blocking -m 2 -s 1
119
120echo "Sleep injection (1ms, 100%)"
121inject_blocking -m 1 -s 1