forked from cxl-micron-reskit/famfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pcq_create.sh
executable file
·88 lines (70 loc) · 1.79 KB
/
pcq_create.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
86
#!/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
if [ -z "$DEV" ]; then
DEV=/dev/dax0.0
fi
while (( $# > 0)); do
flag="$1"
shift
case "$flag" in
(-d|--device)
DEV=$1
shift;
;;
(-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
MKFS="sudo mkfs.famfs $DEV $MPT"
sudo umount $MPT
sudo $MKFS -f $DEV
${CLI} mount $DEV $MPT
set -x
DIR="$MPT/pcq0"
# Create some queues
${CLI} mkdir $DIR || fail "failed to mkdir $DIR"
${PCQ} --create -D -v --bsize 1024 --nbuckets 1024 $DIR/q0 || fail "basic pcq create 0"
${PCQ} --create -v --bsize 64 --nbuckets 1K $DIR/q1 || fail "basic pcq create 1"
${PCQ} --create -v --bsize 64K --nbuckets 512 $DIR/q2 || fail "basic pcq create 2"
${PCQ} --create -v --bsize 512K --nbuckets 1k $DIR/q3 || fail "basic pcq create 3"
${PCQ} --create -v --bsize 256K --nbuckets 256 $DIR/q4 || fail "basic pcq create 4"
# 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