-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-lab4-b.sh
executable file
·47 lines (36 loc) · 1.11 KB
/
test-lab4-b.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
#!/bin/bash
##########################################
# this file contains:
# mr-wc test
###########################################
DIR=$1
# rm $DIR/* >> /dev/null 2>&1
rm $DIR/*
cd $DIR
MRCOORDINATOR=../mr_coordinator
MRWORKER=../mr_worker
timeout -k 2s 16s $MRCOORDINATOR 9876 ../novels/*.txt &
pid=$!
# give the coordinator time to create the sockets.
sleep 1
# start multiple workers.
timeout -k 1s 12s $MRWORKER 9876 ./ &
timeout -k 1s 12s $MRWORKER 9876 ./ &
timeout -k 1s 12s $MRWORKER 9876 ./ &
timeout -k 1s 12s $MRWORKER 9876 ./ &
# wait for the coordinator to exit.
wait $pid
# since workers are required to exit when a job is completely finished,
# and not before, that means the job has finished.
sort mr-out* | grep . > mr-wc-all
sort ../novels/mr-wc-correct > ../novels/lcoal-mr-wc-correct # in case of WSL
# which tofrodos >> /dev/null || sudo apt-get install tofrodos # in case of UNIX/DOS encoding
find ../novels -type f -exec fromdos {} \;
if cmp mr-wc-all ../novels/lcoal-mr-wc-correct
then
echo "Passed mr-wc-distributed test."
else
exit
fi
# wait for remaining workers and coordinator to exit.
wait