#!/bin/bash set -u #------------------------------------------------------------------------------ # VersionInfo='$Id: //guest/tom_tyler/sw/main/install_sdp/dev/bin/r#21 $ $Change: 31778 $' #------------------------------------------------------------------------------ # 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 declare -i ErrorCount=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 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 "$DevRoot"/sdp/test/bsw/run_cli_tests.sh -cd "$DevBin" -no_env -e -g "$TestGroup" else AllTestGroups=$(grep -Ev '^$|^\s|^#' cli_tests.cfg |cut -d'|' -f1|uniq|grep -v ^BSW|tr '\n' ',') "$DevRoot"/sdp/test/bsw/run_cli_tests.sh -cd "$DevBin" -no_env -e -g "$AllTestGroups" 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|Running|See|SUCCESS|Success|TEST_EXIT_CODE|Update|Upgraded|Upgrading|TG|Verified):' | grep -a -Ev '^exit: 0' | grep -a -v '^EXIT_CODE: 0'