3 # This script runs through all the known tests by performing a test sweep.
4 # It should claim that all tests succeeded for a new build/configuration/etc.
5 # to be considered successful.
7 # The way to add tests to the full test set is to add full paths to the
8 # "TESTKIT_TEST_SUITE" variable. This can be done in your personal
9 # testkit.config file or in an exported variable set prior to running
12 # Author: Chris Koeritz
14 export TESTKIT_DIR="$( \cd "$(\dirname "$0")" && \pwd )" # obtain the script's working directory.
17 TIME_START="$(date +"%s")"
19 source prepare_tools.sh prepare_tools.sh
21 # if that didn't work, complain.
22 if [ -z "$TESTKIT_SENTINEL" ]; then echo Please run prepare_tools.sh before testing.; exit 3; fi
23 source "$TESTKIT_ROOT/library/establish_environment.sh"
29 if [ "$verbosity" == "--help" -o "$verbosity" == "-help" -o "$verbosity" == "-h" ]; then
30 echo "$(basename $0): Runs the available suite of tests."
32 echo " $(basename $0) {summary | [full]}"
34 echo "By default, the report will be a 'full' listing that includes all test"
35 echo "run logging. If 'summary' is passed as the first parameter, then only"
36 echo "the test results will be displayed."
40 if [ "$verbosity" == "summary" ]; then
46 # clean up any conglomerated log file.
47 \rm -f "$CONGLOMERATED_TESTKIT_OUTPUT"
51 # define the sets of tests we'd like to run.
54 netbadge_integrations/basic_integrations_test.sh \
59 if [ ! -z "$AUTOBUILD_RUNNING" ]; then
60 # only add some tests for automated, testing, bootstrap builds based on their needs.
68 # now that all tests have been defined, we build up our total list of tests.
70 echo Full set of tests:
71 for ((test_iter=0; $test_iter < ${#TESTKIT_TEST_SUITE[*]}; test_iter++)); do
72 echo "$(expr $test_iter + 1): ${TESTKIT_TEST_SUITE[$test_iter]}"
79 REG_TEMP="$TEST_TEMP/run_$(date +"%Y_%m_%d")"
80 if [ ! -d "$REG_TEMP" ]; then
84 # go to the top of the hierarchy.
87 for ((test_iter=0; $test_iter < ${#TESTKIT_TEST_SUITE[*]}; test_iter++)); do
88 echo -e "\n======================================================================"
90 echo "Now running test $(expr $test_iter + 1): ${TESTKIT_TEST_SUITE[$test_iter]}"
91 output_file="$(mktemp $REG_TEMP/test_log.XXXXXX)"
92 echo " Test output file: $output_file"
95 #hmmm: no real way to check for errors in the general case, unless we define a
96 # set of sentinels for this. not done yet.
98 # echo "==============" >"$output_file"
99 # echo "Log state prior to test:" >>"$output_file"
100 # check_logs_for_errors >>"$output_file"
101 # echo "==============" >>"$output_file"
103 if [ $VERBOSE -ne 1 ]; then
104 bash "${TESTKIT_TEST_SUITE[$test_iter]}" >>"$output_file" 2>&1
107 bash "${TESTKIT_TEST_SUITE[$test_iter]}" 2>&1 | tee -a "$output_file"
108 retval=${PIPESTATUS[0]}
111 if [ $retval -ne 0 ]; then
113 echo "FAILURE: exit code $retval for test ${TESTKIT_TEST_SUITE[$test_iter]}"
114 TEST_RESULTS[$test_iter]="FAIL"
116 echo "OK: successful test run for test ${TESTKIT_TEST_SUITE[$test_iter]}"
117 TEST_RESULTS[$test_iter]="OKAY"
120 #hmmm: same comment re error checking... define some tags to look for!
121 # echo "==============" >>"$output_file"
122 # echo "Log state after test:" >>"$output_file"
123 # check_logs_for_errors >>"$output_file"
124 # echo "==============" >>"$output_file"
128 # final analysis--how did the test run do?
130 echo -e "\n\nResults table for this test run:\n"
131 for ((test_iter=0; $test_iter < ${#TESTKIT_TEST_SUITE[*]}; test_iter++)); do
132 num=$(expr $test_iter + 1)
133 if [ $num -lt 10 ]; then num="0$num"; fi
134 echo "$num: ${TEST_RESULTS[$test_iter]} -- ${TESTKIT_TEST_SUITE[$test_iter]}"
138 # figure out how long things took.
139 TIME_END="$(date +"%s")"
140 duration="$(($TIME_END - $TIME_START))"
141 # prepare to print duration in hours and minutes.
142 minutes="$(($duration / 60))"
143 hours="$(($minutes / 60))"
144 # grab out the hours we calculated from the minutes sum.
145 minutes="$(($minutes - $hours * 60))"
146 if (($minutes < 10)); then minutes="0$minutes"; fi
147 if (($hours < 10)); then hours="0$hours"; fi
148 echo "Total testing duration: $hours:$minutes hh:mm ($duration seconds total)"
150 if [ $FAIL_COUNT -ne 0 ]; then
151 echo "FAILURE: $FAIL_COUNT Tests Failed out of ${#TESTKIT_TEST_SUITE[*]} Tests."
154 echo "OK: All ${#TESTKIT_TEST_SUITE[*]} Tests Ran Successfully."