forked from or-fusion/OptimizationModelComparisons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_problem.sh
executable file
·43 lines (38 loc) · 940 Bytes
/
run_problem.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
#!/bin/bash
#
# NOTE: We want to run final tests with a timeout value of 10m
# but for development purposes we may use a shorter limit.
#
if [ "$TEST_TIMEOUT" == "" ]; then
timelimit="10m"
else
timelimit="${TEST_TIMEOUT}s"
fi
trap '{ echo "You pressed Ctrl-C. Time to quit." ; exit 1; }' INT
function run_problem ()
{
local name=$1
shift
local command=$1
shift
local size=("$@")
echo "size,${name},status" > ${name}.csv
for i in "${size[@]}"
do
echo "NAME $name SIZE $i"
timeout $timelimit time -p sh -c "${command//'$i'/$i}" > test${name}.${i}.out 2>&1
retval=$?
status="ok"
if [ "$retval" -eq "124" ]; then
status="timeout"
elif [ "$retval" -ne "0" ]; then
status="error"
fi
echo "Status: ${status} ($retval)"
tmp=`grep user "test${name}.${i}.out" | awk '{print $2}'`
if [ "$tmp" == "" ]; then
tmp="0"
fi;
echo "$i,$tmp,$status" >> ${name}.csv
done
}