-
Notifications
You must be signed in to change notification settings - Fork 9
/
pcq_send.sh
executable file
·86 lines (69 loc) · 2.03 KB
/
pcq_send.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
cwd=$(pwd)
# Defaults
VG=""
SCRIPTS=scripts
BIN=debug
VALGRIND_ARG="valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes"
DURATION=30
if [ -z "$MPT" ]; then
MPT=/mnt/famfs
fi
while (( $# > 0)); do
flag="$1"
shift
case "$flag" in
(-b|--bin)
BIN=$1
shift
;;
(-s|--scripts)
SCRIPTS=$1
source_root=$1;
shift;
;;
(-v|--valgrind)
# no argument to -v; just setup for Valgrind
VG=${VALGRIND_ARG}
;;
(-t|--time)
DURATION=$1
;;
*)
echo "Unrecognized command line arg: $flag"
;;
esac
done
CLI="sudo $VG $BIN/famfs"
TEST="pcq_send"
STATUSFILE=./pcqstatus.txt
PCQ="sudo $VG $BIN/pcq "
pcq="$VG $BIN/pcq "
ST="--statusfile $STATUSFILE"
source scripts/test_funcs.sh
set -x
DIR="$MPT/pcq0"
# Create some queues
# Set ownership to the non-privileged caller of this script, so tests run a non-root
# This is important because root can write even without write permissions and we
# want to enforce producer/consumer roles via appropriate file permissions
id=$(id -un)
grp=$(id -gn)
sudo chown $id:$grp $DIR
sudo chown -R $id:$grp $DIR
sudo ${PCQ} -setperm p $DIR/q0 || fail "setperm q0"
sudo ${PCQ} -setperm p $DIR/q1 || fail "setperm q1"
sudo ${PCQ} -setperm p $DIR/q2 || fail "setperm q2"
sudo ${PCQ} -setperm p $DIR/q3 || fail "setperm q3"
sudo ${PCQ} -setperm p $DIR/q4 || fail "setperm q4"
# Do a timed run on each queue
echo "$DURATION second run in progress on q0..."
${pcq} -p -s 1 --time $DURATION $DIR/q0 || fail "send$DURATION seconds q0"
echo "$DURATION second run in progress on q1..."
${pcq} -p -s 1 --time $DURATION $DIR/q1 || fail "send $DURATION seconds q1"
echo "$DURATION second run in progress on q2..."
${pcq} -p -s 1 --time $DURATION $DIR/q2 || fail "send $DURATION seconds q2"
echo "$DURATION second run in progress on q3..."
${pcq} -p -s 1 --time $DURATION $DIR/q3 || fail "send $DURATION seconds q3"
echo "$DURATION second run in progress on q4..."
${pcq} -p -s 1 --time $DURATION $DIR/q4 || fail "send $DURATION seconds q4"