2 # Include this file in your shell script by using:
7 # we don't quote $TEXT in case it contains newlines; newlines
8 # aren't allowed in test output. However, we set -f so that
9 # at least shell glob characters aren't processed.
16 if [ -n "$BASH_VERSION" ]; then
17 trap 'echo "! ${BASH_SOURCE[0]}:${LINENO} ${BASH_COMMAND} FAILED"' ERR
22 WVCALLER_FILE=${BASH_SOURCE[2]}
23 WVCALLER_LINE=${BASH_LINENO[1]}
29 WVCALLER_FILE="unknown"
38 TEXT=$(_wvtextclean "$2")
40 if [ "$CODE" -ne 0 ]; then
43 echo "! $WVCALLER_FILE:$WVCALLER_LINE $TEXT $OK" >&2
44 if [ "$CODE" -ne 0 ]; then
74 _wvcheck 1 "NOT($TEXT)"
78 _wvcheck 0 "NOT($TEXT)"
94 _wvcheck $(_wvgetrv [ "$#" -eq 2 ]) "exactly 2 arguments"
99 _wvcheck $(_wvgetrv [ "$1" = "$2" ]) "'$1' = '$2'"
106 _wvcheck $(_wvgetrv [ "$#" -eq 2 ]) "exactly 2 arguments"
107 echo "Comparing:" >&2
111 _wvcheck $(_wvgetrv [ "$1" != "$2" ]) "'$1' != '$2'"
119 _wvcheck $(_wvgetrv [ $RC -eq 0 ]) "return code($RC) == 0"
127 _wvcheck $(_wvgetrv [ $RC -ne 0 ]) "return code($RC) != 0"
135 echo "Testing \"$* ($OMK_RULES)\" in $WVCALLER_FILE:" >&2
137 local dir=test.$(echo $* | tr -s '[[:blank:]]' _ | tr "A-Z" "a-z")
140 WVPASS cd "$WV_BASE_DIR/$dir"
141 WVPASS cp "$OMK_TESTSROOT"/../rules/$OMK_RULES/* .
142 WVPASS cp "$OMK_TESTSROOT"/../snippets/Makefile.rules.$OMK_RULES Makefile.rules
143 WVPASS cp "$OMK_TESTSROOT/../leaf-makefile/Makefile" .
148 WVPASS cp "$OMK_TESTSROOT/../leaf-makefile/Makefile" .
149 for i in `find -L . -mindepth 2 -name Makefile.omk`; do
151 WVPASS cp Makefile "${d}/Makefile"
157 CC=$(make omk-get-var VAR=CC|sed -ne '/^CC=/ s///p')
158 if ! which ${CC%% *} > /dev/null; then
159 echo "Warning: '$CC' not found - skipping the test"
163 if [[ $OMK_RULES = sysless-keil16x ]] && ! which cygpath; then
164 echo "Warning: cygpath command not found - skipping the test"
168 if [[ $OMK_RULES = sysless-keil51 ]] && ! which l51; then
169 echo "Warning: l51 command not found - skipping the test"
174 OMK_TESTSROOT=${OMK_TESTSROOT:-$(readlink --canonicalize $(dirname $0))}
175 OMK_RULES=${OMK_RULES:-linux} # When run manually, we use linux rules
177 if [[ -f "${OMK_TESTSROOT}/${OMK_RULES}.env" ]]; then
178 WVPASS . "${OMK_TESTSROOT}/${OMK_RULES}.env"
183 [[ -z "$RTEMS_MAKEFILE_PATH" ]] && exit 0
186 [[ -z "$WRENV" ]] && exit 0
190 echo "Testing \"$OMK_RULES rules\" in $(basename $0):" >&2
191 testdir="tmp/$(basename $0 .sh).$OMK_RULES"
192 [[ -d "$testdir" ]] && WVPASS rm -rf "$testdir"
193 WVPASS mkdir -p "$testdir"
195 WVPASS cp "$OMK_TESTSROOT"/../rules/$OMK_RULES/* .
196 WVPASS cp "$OMK_TESTSROOT"/../snippets/Makefile.rules.$OMK_RULES Makefile.rules
197 WVPASS cp "$OMK_TESTSROOT/../leaf-makefile/Makefile" .
200 export MAKEFLAGS="--include-dir=$OMK_TESTSROOT/../snippets"