-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrunTests.sh
More file actions
executable file
·41 lines (34 loc) · 817 Bytes
/
Copy pathrunTests.sh
File metadata and controls
executable file
·41 lines (34 loc) · 817 Bytes
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
#!/bin/sh
exec <tests.txt
fails=0
while read line
do
# Run program with input $line
ulimit -t 10
output=`echo "$line\\n^C" | ./factoring.exe 1` 2> /dev/null
if [ "$?" = "137" ]; then
echo "\tFailed test '$line' because: TLE(10)"
continue
fi
if [ "$output" = "fail" ]; then
continue
fi
result=1
resultstr="1"
for i in $output; do
# Check for prime number
#isPrime=$(echo $i | ./checkForPrime.bsh)
#if [ "$isPrime" = "$i is not prime" ]; then
# echo "\tFailed test '$line' because: $isPrime"
# break
#fi
resultstr="$resultstr*$i"
result=$(echo "$result*$i" | bc)
done
# Check the multiplied output against the input value
if [ $result != $line ]; then
echo "\tFailed test '$line' because: ($resultstr=$result) != $line"
fails=$(echo "$fails+1" | bc)
fi
done
return $fails