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