#!/bin/bash
set -u
#------------------------------------------------------------------------------
# VersionInfo='$Id: //guest/tom_tyler/sw/main/install_sdp/dev/bin/r#24 $ $Change: 32064 $'
#------------------------------------------------------------------------------
# Usage:
# To see a list of test groups:
#
# $ ./r ls
#
# To run any single test group, specify the test group name (as displayed by
# 'r ls'). For example, to run the Usage test group, do:
#
# $ ./r Usage
#
# To run all tests groups, do:
#
# $ ./r
#
# Test groups prefixed with "BSW" are excluded; they can only be called if
# referenced explicitly by name, e.g. as:
#
# $ ./r BSWLocalInstallEmpty
#
# Optional: By default, the test suite aborts operation after the first
# test failure due to the '-e' option passed to run_cli_tests.sh. To run
# all tests even if there are failures, set the KEEP_GOING environment
# variable to 1. To do that for just a single run of the test suite, set
# the shell variable and call the command in a single command, like this:
#
# $ KEEP_GOING=1 r LocalInstallInitDataConfigChg
#
# To make it sticky, just do:
#
# $ export KEEP_DOING=1
#
# ... and then all subsequent calls to 'r' will keep going despite failures.
declare -i ErrorCount=0
declare -i KeepGoingAfterFail=0
declare TestGroup=
declare AllTestGroups=
declare DevBin=${DEV_HOME:-}
declare DevRoot=
function msg () { echo -e "$*"; }
function errmsg () { msg "\\nError: ${1:-Unknown Error}\\n"; ErrorCount+=1; }
function bail () { errmsg "${1:-Unknown Error}"; exit "$ErrorCount"; }
if [[ -z "$DevBin" ]]; then
if [[ -d /opt/perforce/.dev/bin ]]; then
DevBin=/opt/perforce/.dev/bin
elif [[ -d /opt/perforce/dev/bin ]]; then
DevBin=/opt/perforce/dev/bin
else
bail "Error: Could not determine DevBin value; neither /opt/perforce/.dev/bin nor /opt/perforce/dev/bin exist. Aborting."
fi
fi
[[ "${KEEP_GOING:-0}" == 1 ]] && KeepGoingAfterFail=1
DevRoot=${DevBin%/*}
if [[ "${1:-}" ]]; then
case "$1" in
ls|list)
grep -Ev '^$|^\s|^#' cli_tests.cfg |cut -d'|' -f1|uniq|grep -v ^BSW
exit 0
;;
*)
TestGroup="$1"
;;
esac
fi
cd "$DevBin" || bail "Could not do: cd $DevBin"
# When starting a new test run, which could be a single test group or the entire set,
# first blast the /root/install_sdp directory which will contain logs from prior
# runs. All install_sdp.sh script logs from the current run appear in this folder.
rm -rf /root/install_sdp
if [[ -n "$TestGroup" ]]; then
if [[ "$KeepGoingAfterFail" -eq 0 ]]; then
"$DevRoot"/sdp/test/bsw/run_cli_tests.sh -cd "$DevBin" -no_env -e -g "$TestGroup"
else
"$DevRoot"/sdp/test/bsw/run_cli_tests.sh -cd "$DevBin" -no_env -g "$TestGroup"
fi
else
AllTestGroups=$(grep -Ev '^$|^\s|^#' cli_tests.cfg |cut -d'|' -f1|uniq|grep -v ^BSW|tr '\n' ',')
if [[ "$KeepGoingAfterFail" -eq 0 ]]; then
"$DevRoot"/sdp/test/bsw/run_cli_tests.sh -cd "$DevBin" -no_env -e -g "$AllTestGroups"
else
"$DevRoot"/sdp/test/bsw/run_cli_tests.sh -cd "$DevBin" -no_env -g "$AllTestGroups"
fi
fi
msg "Summary:"
grep -a -E '^(PASS|FAIL) Test ' /tmp/run_cli_tests.log
### TO DO: Consider moving this logic to scan for unreported errors into the run_cli_tests.sh script itself.
msg "Scan for unreported errors:"
grep -a -E '^\w+:' /tmp/run_cli_tests.log | grep -a -Ev '^(C|Calling|Comments|DEBUG|DESC.*|Diagnostics|Error|EXAMPLE.*|Executing|Get|Hit|https|info|Installing|License|localhost|NO_OP|OPTION.*|PASS|passwd|Protections|Result|Running|See|SUCCESS|Success|Summary|TEST_EXIT_CODE|TriggeredBy|Update|Upgraded|Upgrading|TG|Verified):' | grep -a -Ev '^exit: 0' | grep -a -v '^EXIT_CODE: 0'
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #24 | 32064 | C. Thomas Tyler | Refined scan for unreported errors. | ||
| #23 | 32059 | C. Thomas Tyler | Refined scan for unreported errors. | ||
| #22 | 31944 | C. Thomas Tyler | Added KEEP_GOING option. | ||
| #21 | 31778 | C. Thomas Tyler | Fixed logic to avoid calling BSW tests. | ||
| #20 | 31758 | C. Thomas Tyler | Fixed issues with DevHome value. | ||
| #19 | 31757 | C. Thomas Tyler | Referenced new DevHome setting. | ||
| #18 | 31756 | C. Thomas Tyler | Adaptation for Battle School Workshop environment. | ||
| #17 | 31680 | C. Thomas Tyler |
Added special 'BSW' to test suite for Battle School purposes; this is excluded from routine SDP regression test suite runs as it is is used only for Battle School. |
||
| #16 | 31663 | C. Thomas Tyler |
Changed 'grep' commands that process large log files to pass in '-a' to avoid issues with non-ASCII text files. |
||
| #15 | 31283 | C. Thomas Tyler | Refined scan for unreported errors. | ||
| #14 | 31266 | C. Thomas Tyler | Refined unreported error scan. | ||
| #13 | 31238 | C. Thomas Tyler | Enhanced unreported error scan. | ||
| #12 | 31237 | C. Thomas Tyler |
Change filetype, +k, and added keyword tags. Enhanced scan for unreported errors. |
||
| #11 | 30798 | C. Thomas Tyler | Added usage comment block. | ||
| #10 | 30777 | C. Thomas Tyler | Refined scan for unreported errors. | ||
| #9 | 30772 | C. Thomas Tyler | Adjusted to blast install directory for each test run. | ||
| #8 | 30764 | C. Thomas Tyler | Refined scan for unreported errors. | ||
| #7 | 30761 | C. Thomas Tyler | Improved scanning for unreported errors to eliminate false positives. | ||
| #6 | 30749 | C. Thomas Tyler | Added test group support. | ||
| #5 | 30737 | C. Thomas Tyler | Adjusted scan for unreported errors. | ||
| #4 | 30724 | C. Thomas Tyler | Revised error scan to show only unreported errors. | ||
| #3 | 30706 | C. Thomas Tyler |
Adapted to directory change. Enhanced error scan. |
||
| #2 | 30704 | C. Thomas Tyler | Added summary and error scan of log. | ||
| #1 | 30693 | C. Thomas Tyler | Added dev utils and tests. |