Fix: Warnings about #if checks of undefined tokens
[librseq.git] / tests / run_param_test_cxx.tap
CommitLineData
d268885a
MJ
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+ or MIT
3
4SH_TAP=1
5
6if [ "x${RSEQ_TESTS_SRCDIR:-}" != "x" ]; then
7 UTILSSH="$RSEQ_TESTS_SRCDIR/utils/utils.sh"
8else
9 UTILSSH="$(dirname "$0")/utils/utils.sh"
10fi
11
12# shellcheck source=./utils/utils.sh
13source "$UTILSSH"
14
15
16EXTRA_ARGS=("${@}")
17
18REPS=1000
19NR_CPUS=$(nproc)
20NR_THREADS=$((6 * NR_CPUS))
21
22
23function 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
36function 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
49function 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
64function 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
75if [[ $? == 2 ]]; then
76 plan_skip_all "The rseq syscall is unavailable"
77else
78 plan_tests $(( 2 * 7 * 37 ))
79fi
80
81diag "Default parameters"
82do_tests
83
84diag "Loop injection: 10000 loops"
85do_tests_loops 10000
86
87diag "Yield injection (25%)"
88do_tests_inject -m 4 -y
89
90diag "Yield injection (50%)"
91do_tests_inject -m 2 -y
92
93diag "Yield injection (100%)"
94do_tests_inject -m 1 -y
95
96diag "Kill injection (25%)"
97do_tests_inject -m 4 -k
98
99diag "Kill injection (50%)"
100do_tests_inject -m 2 -k
101
102diag "Kill injection (100%)"
103do_tests_inject -m 1 -k
104
105diag "Sleep injection (1ms, 25%)"
106do_tests_inject -m 4 -s 1
107
108diag "Sleep injection (1ms, 50%)"
109do_tests_inject -m 2 -s 1
110
111diag "Sleep injection (1ms, 100%)"
112do_tests_inject -m 1 -s 1
This page took 0.048591 seconds and 4 git commands to generate.