Commit b3429139 authored by Rohit Gupta's avatar Rohit Gupta

fixed bugs in autotests script

parent 7a499d23
...@@ -34,7 +34,7 @@ cd $tdir ...@@ -34,7 +34,7 @@ cd $tdir
#\param $10 -> number of runs #\param $10 -> number of runs
#\param $11 -> pre_compile program execution #\param $11 -> pre_compile program execution
#\param $12 -> class of the test case (compilation, execution) #\param $12 -> class of the test case (compilation, execution)
#\param $13 -> output of compilation program that needs to be found for test case to pass
test_compile() { test_compile() {
xUnit_start xUnit_start
...@@ -51,6 +51,7 @@ test_compile() { ...@@ -51,6 +51,7 @@ test_compile() {
nruns=${10} nruns=${10}
pre_compile_prog=${11} pre_compile_prog=${11}
class=${12} class=${12}
compile_prog_out=${13}
build_dir=$tdir/$1/build build_dir=$tdir/$1/build
exec_file=$build_dir/$6 exec_file=$build_dir/$6
...@@ -94,7 +95,7 @@ test_compile() { ...@@ -94,7 +95,7 @@ test_compile() {
}>> $log_file 2>&1 }>> $log_file 2>&1
echo "</COMPILATION LOG>" >> $log_file 2>&1 echo "</COMPILATION LOG>" >> $log_file 2>&1
if [ "$class" == "compilation" ]; then if [ "$class" == "compilation" ]; then
if [ -s "$compile_prog_array_index" ] ; then if [ -s "$compile_prog_array_index" ] || [ -s "$compile_prog_out" ] ; then
echo_success "$test_case_name $compile_prog_array_index compiled" echo_success "$test_case_name $compile_prog_array_index compiled"
xUnit_success "compilation" "$test_case_name.$compile_prog_array_index" "PASS" "$run_index" xUnit_success "compilation" "$test_case_name.$compile_prog_array_index" "PASS" "$run_index"
else else
...@@ -284,12 +285,43 @@ else ...@@ -284,12 +285,43 @@ else
fi fi
fi fi
} }
print_help() {
echo_info '
This program runs automated test case system for OpenAirInterface
You should have ubuntu 14.xx, updated, and the Linux kernel >= 3.14
Options
-h | --help
This help
-g | --run-group
Run test cases in a group. For example, ./run_exec_autotests "0101* 010102"
'
}
main () { main () {
RUN_GROUP=0
test_case_list=""
until [ -z "$1" ]
do
case "$1" in
-g | --run-group)
RUN_GROUP=1
test_case_list=$2
"Will execute test cases only in group $test_case_list"
shift 2;;
-h | --help)
print_help
exit 1;;
*)
print_help
echo_fatal "Unknown option $1"
break;;
esac
done
xml_conf="$OPENAIR_DIR/cmake_targets/autotests/test_case_list.xml" xml_conf="$OPENAIR_DIR/cmake_targets/autotests/test_case_list.xml"
test_case_list=`xmlstarlet sel -T -t -m /xml/testCaseList/testCase -s D:N:- "@id" -v "@id" -n $xml_conf` test_case_list=`xmlstarlet sel -T -t -m /xml/testCaseList/testCase -s A:N:- "@id" -v "@id" -n $xml_conf`
echo "test_case_list = $test_case_list" echo "test_case_list = $test_case_list"
...@@ -310,7 +342,8 @@ for search_expr in "${test_case_array[@]}" ...@@ -310,7 +342,8 @@ for search_expr in "${test_case_array[@]}"
search_expr_true=`xmlstarlet sel -t -v "/xml/testCaseList/testCase[@id='$search_expr']/search_expr_true" $xml_conf` search_expr_true=`xmlstarlet sel -t -v "/xml/testCaseList/testCase[@id='$search_expr']/search_expr_true" $xml_conf`
search_expr_false=`xmlstarlet sel -t -v "/xml/testCaseList/testCase[@id='$search_expr']/search_expr_false" $xml_conf` search_expr_false=`xmlstarlet sel -t -v "/xml/testCaseList/testCase[@id='$search_expr']/search_expr_false" $xml_conf`
nruns=`xmlstarlet sel -t -v "/xml/testCaseList/testCase[@id='$search_expr']/nruns" $xml_conf` nruns=`xmlstarlet sel -t -v "/xml/testCaseList/testCase[@id='$search_expr']/nruns" $xml_conf`
compile_prog_out=`xmlstarlet sel -t -v "/xml/testCaseList/testCase[@id='$search_expr']/compile_prog_out" $xml_conf`
echo "class = $class" echo "class = $class"
echo "name = $name" echo "name = $name"
echo "Description = $desc" echo "Description = $desc"
...@@ -343,7 +376,7 @@ for search_expr in "${test_case_array[@]}" ...@@ -343,7 +376,7 @@ for search_expr in "${test_case_array[@]}"
#echo "arg1 = ${search_array_true[0]}" #echo "arg1 = ${search_array_true[0]}"
#echo " arg2 = ${search_array_true[1]}" #echo " arg2 = ${search_array_true[1]}"
if [ "$class" == "compilation" ]; then if [ "$class" == "compilation" ]; then
test_compile "$name" "$compile_prog" "$compile_prog_args" "$pre_exec" "$pre_exec_args" "$main_exec" "$main_exec_args" "search_array_true[@]" "$search_expr_false" "$nruns" "$pre_compile_prog" "$class" test_compile "$name" "$compile_prog" "$compile_prog_args" "$pre_exec" "$pre_exec_args" "$main_exec" "$main_exec_args" "search_array_true[@]" "$search_expr_false" "$nruns" "$pre_compile_prog" "$class" "$compile_prog_out"
elif "$class" == "execution" ]; then elif "$class" == "execution" ]; then
test_compile_and_run "$name" "$compile_prog" "$compile_prog_args" "$pre_exec" "$pre_exec_args" "$main_exec" "$main_exec_args" "search_array_true[@]" "$search_expr_false" "$nruns" "$pre_compile_prog" "$class" test_compile_and_run "$name" "$compile_prog" "$compile_prog_args" "$pre_exec" "$pre_exec_args" "$main_exec" "$main_exec_args" "search_array_true[@]" "$search_expr_false" "$nruns" "$pre_compile_prog" "$class"
else else
...@@ -356,7 +389,7 @@ for search_expr in "${test_case_array[@]}" ...@@ -356,7 +389,7 @@ for search_expr in "${test_case_array[@]}"
} }
main main "$@"
xUnit_write "$results_file" xUnit_write "$results_file"
......
<xml> <xml>
<testCaseList> <testCaseList>
<testCase id="010101" > <testCase id="010101" >
<class>compilation</class> <class>compilation</class>
<desc>Build oaisim.Rel8</desc> <desc>Build oaisim.Rel8</desc>
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
<pre_compile_prog></pre_compile_prog> <pre_compile_prog></pre_compile_prog>
<compile_prog>nasmesh</compile_prog> <compile_prog>nasmesh</compile_prog>
<compile_prog_args></compile_prog_args> <compile_prog_args></compile_prog_args>
<compile_prog_out>CMakeFiles/nasmesh/nasmesh.ko</compile_prog_out>
<pre_exec></pre_exec> <pre_exec></pre_exec>
<pre_exec_args></pre_exec_args> <pre_exec_args></pre_exec_args>
<main_exec></main_exec> <main_exec></main_exec>
...@@ -155,6 +156,9 @@ ...@@ -155,6 +156,9 @@
</testCase> </testCase>
</testCaseList> </testCaseList>
</xml> </xml>
......
...@@ -33,12 +33,12 @@ xUnit_fail() { ...@@ -33,12 +33,12 @@ xUnit_fail() {
currtime=$(date +%s.%N) currtime=$(date +%s.%N)
time=$(echo "$currtime - $XUNIT_START" | bc -l) time=$(echo "$currtime - $XUNIT_START" | bc -l)
xml="<testcase classname='$class' name='$test_case' run='$run_index' time='$time' RESULT='$result'></testcase>" xml="<testcase classname='$class' name='$test_case' run='$run_index' time='$time' RESULT='$result'></testcase>"
XUNIT_TESTCASES_XML="$XUNIT_TESTCASES_XML \n$xml" XUNIT_TESTCASES_XML="$xml \n$XUNIT_TESTCASES_XML"
XUNIT_FAILED=$((XUNIT_FAILED+1)) XUNIT_FAILED=$((XUNIT_FAILED+1))
} }
## Call this after the testcase finished successfully. ## Call this after the testcase finished successfully.
# \sa xUnit_fail() # \sa xUnit_success()
# \pre xUnit_start() must have been called before # \pre xUnit_start() must have been called before
# \param $1 classname # \param $1 classname
# \param $2 testcase name # \param $2 testcase name
...@@ -52,7 +52,7 @@ xUnit_success() { ...@@ -52,7 +52,7 @@ xUnit_success() {
currtime=$(date +%s.%N) currtime=$(date +%s.%N)
time=$(echo "$currtime - $XUNIT_START" | bc -l) time=$(echo "$currtime - $XUNIT_START" | bc -l)
xml="<testcase classname='$class' name='$test_case' run='$run_index' time='$time' RESULT='$result'></testcase>" xml="<testcase classname='$class' name='$test_case' run='$run_index' time='$time' RESULT='$result'></testcase>"
XUNIT_TESTCASES_XML="$XUNIT_TESTCASES_XML \n$xml" XUNIT_TESTCASES_XML="$xml \n$XUNIT_TESTCASES_XML"
XUNIT_SUCCESS=$((XUNIT_SUCCESS+1)) XUNIT_SUCCESS=$((XUNIT_SUCCESS+1))
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment