fix: handle EINTR correctly in get_cpu_mask_from_sysfs
[librseq.git] / tests / run_param_test_cxx.tap
CommitLineData
d268885a 1#!/bin/bash
90702366 2# SPDX-License-Identifier: MIT
f2d7b530 3# SPDX-FileCopyrightText: 2020 EfficiOS Inc.
d268885a
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_cxx "${args[@]}" -r ${REPS} -t ${NR_THREADS} "${EXTRA_ARGS[@]}"
31 ok $? "Running test ${test_name}"
32
33 "$RSEQ_TESTS_BUILDDIR"/param_test_compare_twice_cxx "${args[@]}" -r ${REPS} -t ${NR_THREADS} "${EXTRA_ARGS[@]}"
34 ok $? "Running compare-twice test ${test_name}"
35}
36
37function 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 "${@}"
48}
49
50function do_tests_loops()
51{
52 local nr_loops="$1"
53
54 do_tests -1 "${nr_loops}"
55 do_tests -2 "${nr_loops}"
56 do_tests -3 "${nr_loops}"
57 do_tests -4 "${nr_loops}"
58 do_tests -5 "${nr_loops}"
59 do_tests -6 "${nr_loops}"
60 do_tests -7 "${nr_loops}"
61 do_tests -8 "${nr_loops}"
62 do_tests -9 "${nr_loops}"
63}
64
65function do_tests_inject()
66{
67 local args=("$@")
68
69 do_tests -7 -1 "${@}"
70 do_tests -8 -1 "${@}"
71 do_tests -9 -1 "${@}"
72}
73
74
75"$RSEQ_TESTS_BUILDDIR"/param_test -c
76if [[ $? == 2 ]]; then
77 plan_skip_all "The rseq syscall is unavailable"
78else
79 plan_tests $(( 2 * 7 * 37 ))
80fi
81
82diag "Default parameters"
83do_tests
84
85diag "Loop injection: 10000 loops"
86do_tests_loops 10000
87
88diag "Yield injection (25%)"
89do_tests_inject -m 4 -y
90
91diag "Yield injection (50%)"
92do_tests_inject -m 2 -y
93
94diag "Yield injection (100%)"
95do_tests_inject -m 1 -y
96
97diag "Kill injection (25%)"
98do_tests_inject -m 4 -k
99
100diag "Kill injection (50%)"
101do_tests_inject -m 2 -k
102
103diag "Kill injection (100%)"
104do_tests_inject -m 1 -k
105
106diag "Sleep injection (1ms, 25%)"
107do_tests_inject -m 4 -s 1
108
109diag "Sleep injection (1ms, 50%)"
110do_tests_inject -m 2 -s 1
111
112diag "Sleep injection (1ms, 100%)"
113do_tests_inject -m 1 -s 1
This page took 0.045862 seconds and 4 git commands to generate.