-
Notifications
You must be signed in to change notification settings - Fork 0
/
fishsharks_test.sh
executable file
·69 lines (60 loc) · 1.14 KB
/
fishsharks_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
EXE="fishsharks_mic"
ERROR=0
if [ $# -lt 5 ]
then
printf "ERROR: # of INPUT\n\n"
printf "./fishsharks_test.sh <S> <E> <N> <M> <SEED>\n \
<S>: FROM TREAD\n \
<E>: TO THREAD \n \
<N>: SIZE OF MATRIX NxN\n \
<M>: # OF LOOPS\n \
<SEED>: SEED ROOT\n\n"
exit
fi
from=${1:?INSERT FROM}
if ! [[ "$from" =~ ^[0-9]+$ ]]
then
printf "ERROR: FROM INPUT\n"
ERROR=1
fi
to=${2:?INSERT TO}
if ! [[ "$to" =~ ^[0-9]+$ ]]
then
printf "ERROR: TO INPUT\n"
ERROR=1
fi
N=${3:?INSERT N}
if ! [[ "$N" =~ ^[0-9]+$ ]]
then
printf "ERROR: N INPUT\n"
ERROR=1
fi
M=${4:?INSERT M}
if ! [[ "$M" =~ ^[0-9]+$ ]]
then
printf "ERROR: M INPUT\n"
ERROR=1
fi
SEED=${5:?INSERT SEED}
if ! [[ "$SEED" =~ ^[0-9]+$ ]]
then
printf "ERROR: SEED INPUT\n"
ERROR=1
fi
if [ $from -gt $to ]
then
printf "ERROR: FROM > TO\n"
ERROR=1
fi
if [ $ERROR -eq 0 ]
then
echo "./$EXE $N <TH> $M $SEED 1 0" > test.txt
for i in $(seq $from $to); do
echo "./$EXE $N $i $M $SEED 1 0"
echo "TH: $i" >> test.txt
./$EXE $N $i $M $SEED 1 0 >> test.txt
done
else
exit
fi