-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration-test.sh
executable file
·47 lines (35 loc) · 1.21 KB
/
integration-test.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
#!/usr/bin/env bash
set -euo pipefail
cargo build --release
export PATH="$PWD/target/release:$PATH"
channel1=$(mktemp --dry-run)
mkfifo $channel1
channel2=$(mktemp --dry-run)
mkfifo $channel2
file=$(mktemp)
echo "step: acquire write-lock"
cat $channel1 | fcntl-tool write-lock --file $file &
sleep 0.2 # give time for locking
echo "step: test for write-lock"
fcntl-tool test-lock --file $file
fcntl-tool test-lock --file $file | grep -q ExclusiveWrite
echo "step: releasing write-lock"
echo > $channel1 # send enter/newline
sleep 0.2 # give time for releasing the lock
echo "step: test for unlocked"
fcntl-tool test-lock --file $file
fcntl-tool test-lock --file $file | grep -q Unlocked
echo "step: acquire read-lock #1"
cat $channel1 | fcntl-tool read-lock --file $file &
echo "step: acquire read-lock #2"
cat $channel2 | fcntl-tool read-lock --file $file &
sleep 0.2 # wait so that the tool is actually scheduled and can get the lock
echo "step: test for SharedLock"
fcntl-tool test-lock --file $file
fcntl-tool test-lock --file $file | grep -q SharedRead
echo > $channel1 # send enter/newline
echo > $channel2 # send enter/newline
sleep 0.2 # give time for releasing the locks
rm -f $channel1
rm -f $channel2
rm -f $file