1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0+ or MIT 3 4NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l` 5 6EXTRA_ARGS=${@} 7 8OLDIFS="$IFS" 9IFS=$'\n' 10TEST_LIST=( 11 "-T s" 12 "-T l" 13 "-T b" 14 "-T b -M" 15 "-T m" 16 "-T m -M" 17 "-T i" 18 "-T r" 19) 20 21TEST_NAME=( 22 "spinlock" 23 "list" 24 "buffer" 25 "buffer with barrier" 26 "memcpy" 27 "memcpy with barrier" 28 "increment" 29 "membarrier" 30) 31IFS="$OLDIFS" 32 33REPS=1000 34SLOW_REPS=100 35NR_THREADS=$((6*${NR_CPUS})) 36 37function do_tests() 38{ 39 local i=0 40 while [ "$i" -lt "${#TEST_LIST[@]}" ]; do 41 echo "Running test ${TEST_NAME[$i]}" 42 ./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1 43 echo "Running compare-twice test ${TEST_NAME[$i]}" 44 ./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1 45 46 echo "Running mm_cid test ${TEST_NAME[$i]}" 47 ./param_test_mm_cid ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1 48 echo "Running mm_cid compare-twice test ${TEST_NAME[$i]}" 49 ./param_test_mm_cid_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1 50 let "i++" 51 done 52} 53 54echo "Default parameters" 55do_tests 56 57echo "Loop injection: 10000 loops" 58 59OLDIFS="$IFS" 60IFS=$'\n' 61INJECT_LIST=( 62 "1" 63 "2" 64 "3" 65 "4" 66 "5" 67 "6" 68 "7" 69 "8" 70 "9" 71) 72IFS="$OLDIFS" 73 74NR_LOOPS=10000 75 76i=0 77while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do 78 echo "Injecting at <${INJECT_LIST[$i]}>" 79 do_tests -${INJECT_LIST[i]} ${NR_LOOPS} 80 let "i++" 81done 82NR_LOOPS= 83 84function inject_blocking() 85{ 86 OLDIFS="$IFS" 87 IFS=$'\n' 88 INJECT_LIST=( 89 "7" 90 "8" 91 "9" 92 ) 93 IFS="$OLDIFS" 94 95 NR_LOOPS=-1 96 97 i=0 98 while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do 99 echo "Injecting at <${INJECT_LIST[$i]}>" 100 do_tests -${INJECT_LIST[i]} -1 ${@} 101 let "i++" 102 done 103 NR_LOOPS= 104} 105 106echo "Yield injection (25%)" 107inject_blocking -m 4 -y 108 109echo "Yield injection (50%)" 110inject_blocking -m 2 -y 111 112echo "Yield injection (100%)" 113inject_blocking -m 1 -y 114 115echo "Kill injection (25%)" 116inject_blocking -m 4 -k 117 118echo "Kill injection (50%)" 119inject_blocking -m 2 -k 120 121echo "Kill injection (100%)" 122inject_blocking -m 1 -k 123 124echo "Sleep injection (1ms, 25%)" 125inject_blocking -m 4 -s 1 126 127echo "Sleep injection (1ms, 50%)" 128inject_blocking -m 2 -s 1 129 130echo "Sleep injection (1ms, 100%)" 131inject_blocking -m 1 -s 1 132