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}" | |
369688a5 MD |
35 | |
36 | "$RSEQ_TESTS_BUILDDIR"/param_test_mm_cid "${args[@]}" -r ${REPS} -t ${NR_THREADS} "${EXTRA_ARGS[@]}" | |
04bb9984 MD |
37 | res=$? |
38 | skip $(($res != 2 )) "Running mm_cid test ${test_name}" 1 || { | |
39 | ok $res "Running mm_cid test ${test_name}" | |
40 | } | |
369688a5 MD |
41 | |
42 | "$RSEQ_TESTS_BUILDDIR"/param_test_mm_cid_compare_twice "${args[@]}" -r ${REPS} -t ${NR_THREADS} "${EXTRA_ARGS[@]}" | |
04bb9984 MD |
43 | res=$? |
44 | skip $(($res != 2)) "Running compare-twice mm_cid test ${test_name}" 1 || { | |
45 | ok $res "Running compare-twice mm_cid test ${test_name}" | |
46 | } | |
544cdc88 MJ |
47 | } |
48 | ||
49 | function do_tests() | |
50 | { | |
51 | local args=("$@") | |
52 | ||
53 | do_test "spinlock" -T s "${@}" | |
54 | do_test "list" -T l "${@}" | |
55 | do_test "buffer" -T b "${@}" | |
56 | do_test "buffer with barrier" -T b -M "${@}" | |
57 | do_test "memcpy" -T m "${@}" | |
58 | do_test "memcpy with barrier" -T m -M "${@}" | |
59 | do_test "increment" -T i "${@}" | |
5368dcb4 | 60 | do_test "membarrier" -T r "${@}" |
544cdc88 MJ |
61 | } |
62 | ||
63 | function do_tests_loops() | |
64 | { | |
65 | local nr_loops="$1" | |
66 | ||
67 | do_tests -1 "${nr_loops}" | |
68 | do_tests -2 "${nr_loops}" | |
69 | do_tests -3 "${nr_loops}" | |
70 | do_tests -4 "${nr_loops}" | |
71 | do_tests -5 "${nr_loops}" | |
72 | do_tests -6 "${nr_loops}" | |
73 | do_tests -7 "${nr_loops}" | |
74 | do_tests -8 "${nr_loops}" | |
75 | do_tests -9 "${nr_loops}" | |
76 | } | |
77 | ||
78 | function do_tests_inject() | |
79 | { | |
80 | local args=("$@") | |
81 | ||
82 | do_tests -7 -1 "${@}" | |
83 | do_tests -8 -1 "${@}" | |
84 | do_tests -9 -1 "${@}" | |
85 | } | |
86 | ||
87 | ||
d1cdec98 MJ |
88 | "$RSEQ_TESTS_BUILDDIR"/param_test -c |
89 | if [[ $? == 2 ]]; then | |
90 | plan_skip_all "The rseq syscall is unavailable" | |
91 | else | |
369688a5 | 92 | plan_tests $(( 4 * 8 * 37 )) |
d1cdec98 | 93 | fi |
544cdc88 MJ |
94 | |
95 | diag "Default parameters" | |
96 | do_tests | |
97 | ||
98 | diag "Loop injection: 10000 loops" | |
99 | do_tests_loops 10000 | |
100 | ||
101 | diag "Yield injection (25%)" | |
102 | do_tests_inject -m 4 -y | |
103 | ||
104 | diag "Yield injection (50%)" | |
105 | do_tests_inject -m 2 -y | |
106 | ||
107 | diag "Yield injection (100%)" | |
108 | do_tests_inject -m 1 -y | |
109 | ||
110 | diag "Kill injection (25%)" | |
111 | do_tests_inject -m 4 -k | |
112 | ||
113 | diag "Kill injection (50%)" | |
114 | do_tests_inject -m 2 -k | |
115 | ||
116 | diag "Kill injection (100%)" | |
117 | do_tests_inject -m 1 -k | |
118 | ||
119 | diag "Sleep injection (1ms, 25%)" | |
120 | do_tests_inject -m 4 -s 1 | |
121 | ||
122 | diag "Sleep injection (1ms, 50%)" | |
123 | do_tests_inject -m 2 -s 1 | |
124 | ||
125 | diag "Sleep injection (1ms, 100%)" | |
126 | do_tests_inject -m 1 -s 1 |