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