-
Notifications
You must be signed in to change notification settings - Fork 0
/
kbuild-env.sh
executable file
·106 lines (94 loc) · 2.66 KB
/
kbuild-env.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
#Tools environment
export KCI_ROOT=`pwd`
export KBUILDCONFIG=$KCI_ROOT/kbconfig
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabi-
export CCACHE=ccache
#Infer default paths from the environment
if [[ $WORKSPACE == '' ]]
then
echo "Warn: Workspace environment not set ?"
exit
else
export BUILD_ROOT=$WORKSPACE/kernel
fi
export RESULTS_DIR=$WORKSPACE/results
rm -fr $RESULTS_DIR
mkdir $RESULTS_DIR
export WORKING_DIR=$WORKSPACE/working
rm -fr $WORKING_DIR
mkdir $WORKING_DIR
export TITAN_DIR=$WORKING_DIR/Titan
export TDESCPATH=$TITAN_DIR/test_descriptors
export TUSER_SETTINGS=$TITAN_DIR/settings/user-settings.xml
export TSELECTED_TESTS=$TITAN_DIR/settings/titan-selectedtests.xml
export TLOGPATH=$TITAN_DIR/logs
export TREPORTPATH=$TITAN_DIR/reports
#Test result generation
function log_init_testsuite {
echo "###Begin Testsuite: $*"
filename=$RESULTS_DIR/"$1.$2".xml
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" >$filename
echo "<testsuite errors=\"0\" failures=\"0\" hostname=\"Jenkins\" name=\"$1.$2\" tests=\"0\" time=\"0\">" >>$filename
}
#Param1=test module name
function log_finish_testsuite {
echo "###End Testsuite: $*"
filename=$RESULTS_DIR/"$1.$2".xml
#tccount=`grep -c \"testcase classname\" $1.xml`
#tfcount=`grep -c \"failure message\" $1.xml`
echo "</testsuite>" >>$filename
}
#Param1=test module name
#Param2=test suite name
#Param3=test case name
function log_init_testcase {
echo "####Begin Test: $1 $2 $3"
filename=$RESULTS_DIR/"$1.$2".xml
start_time=`date +%s`
echo "<testcase classname=\"$1.$2\" name=\"$3\" " >>$filename
}
#Param1=test module name
#Param2=test suite name
#Param3=test case name
#Param4=time to execute
#Param5(optional)=failure message
function log_finish_testcase {
filename=$RESULTS_DIR/"$1.$2".xml
current_time=`date +%s`
diff=$(($current_time - $start_time))
echo "time=\"$diff\"> " >>$filename
if [ -n "$5" ]
then
echo "<failure message=\"$5\" /></testcase>" >>$filename
echo "####End Test: $1 $2 $3:Fail: $5"
else
echo "</testcase>" >>$filename
echo "####End Test: $1 $2 $3:Pass"
fi
}
#Param1=test suite name
#Param2=test module name
#Param3=txt file to be converted to Junit format
function txt_to_junit {
log_init_testsuite $1 $2
while read VLINE
do
tcv=${VLINE#*;};
tcn=${VLINE%;*};
log_init_testcase $1 $2 $tcn
if [ $tcv == 'P' ]
then
log_finish_testcase $1 $2 $tcn 10
else
log_finish_testcase $1 $2 $tcn 10 "Testcase failure"
fi
done < $3
log_finish_testsuite $1 $2
}
export -f log_init_testsuite
export -f log_finish_testsuite
export -f log_init_testcase
export -f log_finish_testcase
export -f txt_to_junit