Commit | Line | Data |
---|---|---|
d268885a MJ |
1 | #!/bin/bash |
2 | # SPDX-License-Identifier: GPL-2.0+ or MIT | |
3 | ||
4 | SH_TAP=1 | |
5 | ||
6 | if [ "x${RSEQ_TESTS_SRCDIR:-}" != "x" ]; then | |
7 | UTILSSH="$RSEQ_TESTS_SRCDIR/utils/utils.sh" | |
8 | else | |
9 | UTILSSH="$(dirname "$0")/utils/utils.sh" | |
10 | fi | |
11 | ||
12 | # shellcheck source=./utils/utils.sh | |
13 | source "$UTILSSH" | |
14 | ||
15 | ||
16 | EXTRA_ARGS=("${@}") | |
17 | ||
18 | REPS=1000 | |
19 | NR_CPUS=$(nproc) | |
20 | NR_THREADS=$((6 * NR_CPUS)) | |
21 | ||
22 | ||
23 | function do_test() | |
24 | { | |
25 | local test_name=$1 | |
26 | shift | |
27 | local args=("$@") | |
28 | ||
29 | "$RSEQ_TESTS_BUILDDIR"/param_test_cxx "${args[@]}" -r ${REPS} -t ${NR_THREADS} "${EXTRA_ARGS[@]}" | |
30 | ok $? "Running test ${test_name}" | |
31 | ||
32 | "$RSEQ_TESTS_BUILDDIR"/param_test_compare_twice_cxx "${args[@]}" -r ${REPS} -t ${NR_THREADS} "${EXTRA_ARGS[@]}" | |
33 | ok $? "Running compare-twice test ${test_name}" | |
34 | } | |
35 | ||
36 | function do_tests() | |
37 | { | |
38 | local args=("$@") | |
39 | ||
40 | do_test "spinlock" -T s "${@}" | |
41 | do_test "list" -T l "${@}" | |
42 | do_test "buffer" -T b "${@}" | |
43 | do_test "buffer with barrier" -T b -M "${@}" | |
44 | do_test "memcpy" -T m "${@}" | |
45 | do_test "memcpy with barrier" -T m -M "${@}" | |
46 | do_test "increment" -T i "${@}" | |
47 | } | |
48 | ||
49 | function do_tests_loops() | |
50 | { | |
51 | local nr_loops="$1" | |
52 | ||
53 | do_tests -1 "${nr_loops}" | |
54 | do_tests -2 "${nr_loops}" | |
55 | do_tests -3 "${nr_loops}" | |
56 | do_tests -4 "${nr_loops}" | |
57 | do_tests -5 "${nr_loops}" | |
58 | do_tests -6 "${nr_loops}" | |
59 | do_tests -7 "${nr_loops}" | |
60 | do_tests -8 "${nr_loops}" | |
61 | do_tests -9 "${nr_loops}" | |
62 | } | |
63 | ||
64 | function do_tests_inject() | |
65 | { | |
66 | local args=("$@") | |
67 | ||
68 | do_tests -7 -1 "${@}" | |
69 | do_tests -8 -1 "${@}" | |
70 | do_tests -9 -1 "${@}" | |
71 | } | |
72 | ||
73 | ||
74 | "$RSEQ_TESTS_BUILDDIR"/param_test -c | |
75 | if [[ $? == 2 ]]; then | |
76 | plan_skip_all "The rseq syscall is unavailable" | |
77 | else | |
78 | plan_tests $(( 2 * 7 * 37 )) | |
79 | fi | |
80 | ||
81 | diag "Default parameters" | |
82 | do_tests | |
83 | ||
84 | diag "Loop injection: 10000 loops" | |
85 | do_tests_loops 10000 | |
86 | ||
87 | diag "Yield injection (25%)" | |
88 | do_tests_inject -m 4 -y | |
89 | ||
90 | diag "Yield injection (50%)" | |
91 | do_tests_inject -m 2 -y | |
92 | ||
93 | diag "Yield injection (100%)" | |
94 | do_tests_inject -m 1 -y | |
95 | ||
96 | diag "Kill injection (25%)" | |
97 | do_tests_inject -m 4 -k | |
98 | ||
99 | diag "Kill injection (50%)" | |
100 | do_tests_inject -m 2 -k | |
101 | ||
102 | diag "Kill injection (100%)" | |
103 | do_tests_inject -m 1 -k | |
104 | ||
105 | diag "Sleep injection (1ms, 25%)" | |
106 | do_tests_inject -m 4 -s 1 | |
107 | ||
108 | diag "Sleep injection (1ms, 50%)" | |
109 | do_tests_inject -m 2 -s 1 | |
110 | ||
111 | diag "Sleep injection (1ms, 100%)" | |
112 | do_tests_inject -m 1 -s 1 |