-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestbin
22 lines (19 loc) · 835 Bytes
/
testbin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
TIMEOUT=240
## Generic testing script for OCaml programs. Should be invoked as
# testbin XXX YYY scores.out
# or
# testbin XXX YYY scores.out SHOW_OUTPUT
echo -e "<pre>"
if [ ! -f ocamlbin ]; then
echo -e "Compilation failed. No tests run."
exit 0
fi
(if [ -n "$4" ]; then
./timeout3 -t $TIMEOUT ./ocamlbin -linux -scores $3 -feedback feedback.txt --grade || echo -e "Cannot run code because of infinite loop or raised exception."
else
./timeout3 -t $TIMEOUT ./ocamlbin -linux -scores $3 -feedback feedback.txt --grade &> /dev/null || echo -e "Cannot run code because of infinite loop or raised exception."
fi 2> /dev/null) # stderr redirect to prevent "Terminated" message from being printed.
chmod 0770 $3 feedback.txt 2> /dev/null
cat feedback.txt 2> /dev/null
echo -e "</pre>"