|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# This program and the accompanying materials are |
| 4 | +# made available under the terms of the Eclipse Public License v2.0 which accompanies |
| 5 | +# this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html |
| 6 | +# |
| 7 | +# SPDX-License-Identifier: EPL-2.0 |
| 8 | +# |
| 9 | +# Copyright Contributors to the Zowe Project. |
| 10 | + |
| 11 | +# Start with_any_paramter -> prints output (diff style) |
| 12 | +# rc of this = number of errors found |
| 13 | + |
| 14 | +print= |
| 15 | +errors=0 |
| 16 | + |
| 17 | +if [ ! -z "${1}" ]; then |
| 18 | + print='1' |
| 19 | +fi |
| 20 | + |
| 21 | +LAUNCHER='../bin/zowe_launcher' |
| 22 | +ABS_PATH=$(cd .; pwd) |
| 23 | + |
| 24 | +TEST_FILES='./files' |
| 25 | +ZOWE="${TEST_FILES}/zowe.runtime.dev.null.yaml" |
| 26 | +ZOWE_EMPTY="${TEST_FILES}/zowe.empty.yaml" |
| 27 | +ABS_ZOWE="${ABS_PATH}/${ZOWE}" |
| 28 | +ABS_ZOWE2="${ABS_PATH}/././././////./////${ZOWE}" |
| 29 | + |
| 30 | +run_launcher() { |
| 31 | + # trim via awk |
| 32 | + config=$(echo "$1" | awk '{$1=$1};1') |
| 33 | + haInstance=$(echo "$2" | awk '{$1=$1};1') |
| 34 | + textMatch=$(echo "$3" | awk '{$1=$1};1') |
| 35 | + desc=$(echo "$4" | awk '{$1=$1};1') |
| 36 | + debug=$(echo "$5" | awk '{$1=$1};1') |
| 37 | + |
| 38 | + export ZLDEBUG= |
| 39 | + if [ ! -z "${debug}" ]; then |
| 40 | + export ZLDEBUG='ON' |
| 41 | + fi |
| 42 | + |
| 43 | + export CONFIG="${config}" |
| 44 | + # Filter out the long line when printing |
| 45 | + if [ -n "${print}" ]; then |
| 46 | + result=$($LAUNCHER "${haInstance}" 2>&1 | grep -v "INFO -- If you cant see '500'") |
| 47 | + else |
| 48 | + result=$($LAUNCHER "${haInstance}" 2>&1) |
| 49 | + fi |
| 50 | + |
| 51 | + [ ! -z "${desc}" ] && [ ! -z "${print}" ] && echo "+ >>> ${desc}" |
| 52 | + [ ! -z "${print}" ] && echo "+ > CONFIG=${config}" |
| 53 | + [ ! -z "${haInstance}" ] && [ ! -z "${print}" ] && echo "+ > haInstance=${haInstance}" |
| 54 | + |
| 55 | + [ ! -z "${print}" ] && echo "${result}" |
| 56 | + |
| 57 | + if [ ! -z "${textMatch}" ]; then |
| 58 | + findText=$(echo "${result}" | grep "${textMatch}" ) |
| 59 | + if [ -z "${findText}" ]; then |
| 60 | + echo "- > Not found: ${textMatch}" |
| 61 | + errors=`expr $errors + 1` |
| 62 | + else |
| 63 | + [ ! -z "${print}" ] && echo "+ > Found: ${textMatch}" |
| 64 | + fi |
| 65 | + fi |
| 66 | + |
| 67 | + [ ! -z "${print}" ] && echo "" |
| 68 | +} |
| 69 | + |
| 70 | +IFS='|' |
| 71 | +while read config haInstace textMatch desc debug; do |
| 72 | + # Skip the first line |
| 73 | + if [ "${config}" != "CONFIG " ]; then |
| 74 | + run_launcher $config $haInstace $textMatch $desc $debug |
| 75 | + fi |
| 76 | +done <<EOF |
| 77 | +CONFIG | HA-INSTANCE | TEXT-TO-FIND | DESCRIPTION | ZLDEBUG |
| 78 | + | | PANIC! readJson got null pathElement | No config leads to PANIC! |
| 79 | +FILE(${ZOWE_EMPTY}) | | ZWEL0318E - failed to get root node in YAML | Empty config leads to ZWEL0318E |
| 80 | +${ABS_ZOWE} | | ZWEL0021I Zowe Launcher starting | Check the basic message ZWEL0021I |
| 81 | +${ZOWE} | | INFO ZWEL0023I Zowe YAML config file is 'FILE(${ZOWE})' | ZWEL0023I wrapped by FILE() |
| 82 | +FILE(${ZOWE}) | | INFO ZWEL0023I Zowe YAML config file is 'FILE(${ZOWE})' | Same as previous test |
| 83 | +${ABS_ZOWE} | | INFO ZWEL0023I Zowe YAML config file is 'FILE(${ABS_ZOWE})' | ZWEL0023I wrapped by FILE() |
| 84 | +${ABS_ZOWE2} | | INFO ZWEL0023I Zowe YAML config file is 'FILE(${ABS_ZOWE2})' | Should be able to read the file |
| 85 | +FILE(${ZOWE}) | LPAR123 | ZWEL0024I HA_INSTANCE_ID is 'lpar123' | HaInstance should be sanitazed |
| 86 | +PARMLIB(ZOWE.TEST-1.A(A)) | hello | ZWEL0023I Zowe YAML config file is 'PARMLIB(ZOWE.TEST-1.A(A))' | Parmlib does not exist, but it should be in ZWEL00203I |
| 87 | +PARMLIB(ZOWE.TEST-1.A) | world | ZWEL0068E PARMLIB() entries must have a member name | Should detect missing member |
| 88 | +PARMLIB(ZOWE.TEST-1.A() | | ZWEL0068E PARMLIB() entries must have a member name | Should detect missing member |
| 89 | +PARMLIB(ZOWE.TEST-1.A()) | | ZWEL0068E PARMLIB() entries must have a member name | Should detect missing member |
| 90 | +EOF |
| 91 | + |
| 92 | +exit $errors |
0 commit comments