-
Notifications
You must be signed in to change notification settings - Fork 21
/
testing
executable file
·84 lines (75 loc) · 1.75 KB
/
testing
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Copyright (C) Rishabh Iyer, John T. Halloran, and Kai Wei
# Licensed under the Open Software License version 3.0
# See COPYING or http://opensource.org/licenses/OSL-3.0
#!/bin/bash
############### jensen build/test functions
function buildCMTK {
# compile jensen binaries
CURR=$(pwd)
if [ ! -d build ]
then
echo "Creating build directory $CURR/build"
mkdir build
fi
cd build
cmake ..
make
cd $CURR
}
function testCMTK {
CURR=$(pwd)
RESULTSDIR="$CURR/results"
if [ ! -d $RESULTSDIR ]
then
echo "Creating results directory $RESULTSDIR"
mkdir $RESULTSDIR
fi
CMTKHEADER="src/jensen.h"
# check whether DEBUG is defined in jensen header file
DEBUG=$(grep -c "\#define DEBUG" $CMTKHEADER)
if((DEBUG == 0))
then
echo "Adding debug flag to jensen.h"
sed -i 's/#define CMTK/#define CMTK\n\n#define DEBUG\n/' $CMTKHEADER
fi
if [ ! -d build ]
then
echo "Error: build directory does not exist, please run build first"
exit 1
fi
# run test suite
cd build
for t in TestL1SmoothSVMLoss TestL2SmoothSVMLoss TestL1ProbitLoss TestL2ProbitLoss TestL1LogisticLoss TestL2LogisticLoss TestL1LeastSquaresLoss TestL2LeastSquaresLoss TestL1HuberSVMLoss TestL2HuberSVMLoss
do
if [ -e $t ]
then
echo "Running $t"
./$t | tee $RESULTSDIR/${t}_output.txt
else
echo "Binary $t not available in build, skipping"
fi
done
cd $CURR
}
#############################################################
# check number of input arguments
# assume build is first argument, test is second argument
if (( "$#" == 2 ))
then
BUILD=$1
TEST=$2
elif (( "$#" == 1 ))
then
BUILD=$1
else
BUILD=0
TEST=0
fi
if ((BUILD))
then
buildCMTK
fi
if ((TEST))
then
testCMTK
fi