Merge "Fix standalone tests for cygwin"
diff --git a/tests/standalone/builtin-macros/run.sh b/tests/standalone/builtin-macros/run.sh
index d897f60..27a11a7 100644
--- a/tests/standalone/builtin-macros/run.sh
+++ b/tests/standalone/builtin-macros/run.sh
@@ -13,10 +13,13 @@
}
# Read all the built-in macros, and assign them to our own variables.
+# For cygwin/mingw, don't use $NULL defined in parent run.sh to NUL, because
+# NUL can't be used as input. The non-existance /dev/null works well.
MACRO_LINES=$($CC $CFLAGS -dM -E - < /dev/null | sort -u | tr ' ' '^^^' | tr '"' '~')
for LINE in $MACRO_LINES; do
- LINE=$(echo "$LINE" | tr '^^^' ' ')
+ # for cygwin, it's important to remove trailing '\r' as well
+ LINE=$(echo "$LINE" | tr '^^^' ' ' | tr '\r' ' ')
VARNAME=$(echo "$LINE" | cut -d' ' -f 2)
VARVALUE=$(echo "$LINE" | cut -d' ' -f 3)
diff --git a/tests/standalone/run.sh b/tests/standalone/run.sh
index 01fa0b8..4bbd3fb 100755
--- a/tests/standalone/run.sh
+++ b/tests/standalone/run.sh
@@ -184,6 +184,11 @@
}
fi
+if [ "$HOST_OS" = "cygwin" ] ; then
+ NULL="NUL"
+else
+ NULL="/dev/null"
+fi
# Probe a given sub-directory and see if it contains valid test files.
# $1: sub-directory path
@@ -262,7 +267,7 @@
panic "Missing compiler, please fix your prefix definition: $GCC"
fi
- GCC=$(which $GCC 2>/dev/null)
+ GCC=$(which $GCC 2>$NULL)
if [ -z "$GCC" -o ! -f "$GCC" ]; then
panic "Bad compiler path: ${PREFIX}gcc"
fi
@@ -299,13 +304,13 @@
PREFIX=${CLANG%%clang}
# Find *-ld in the same directory eventaully usable as ${PREFIX}-ld
- GNU_LD=$(cd $CLANGDIR && ls *-ld)
+ GNU_LD=$(cd $CLANGDIR && ls *-ld${HOST_EXE})
GNU_LD=$CLANGDIR/$GNU_LD
if [ ! -f "$GNU_LD" ]; then
panic "Missing linker in the same directory as clang/clang++: $CLANGDIR"
fi
- PREFIX=${GNU_LD%ld}
+ PREFIX=${GNU_LD%ld${HOST_EXE}}
CC=$CLANG
CXX=${CLANG%clang}clang++
@@ -409,7 +414,7 @@
case $TEST_TYPE in
script)
(
- export PREFIX CC CXX CFLAGS CXXFLAGS LDFLAGS VERBOSE ABI
+ export PREFIX CC CXX CFLAGS CXXFLAGS LDFLAGS VERBOSE ABI NULL
run cd "$BUILD_DIR" && run_script $SCRIPT
)
RET=$?
@@ -417,14 +422,14 @@
c_executable)
(
- run cd "$BUILD_DIR" && run $CC $LDFLAGS $CFLAGS -o /dev/null $SOURCES
+ run cd "$BUILD_DIR" && run $CC $LDFLAGS $CFLAGS -o $NULL $SOURCES
)
RET=$?
;;
cxx_executable)
(
- run cd "$BUILD_DIR" && run $CXX $LDFLAGS $CXXFLAGS -o /dev/null $SOURCES
+ run cd "$BUILD_DIR" && run $CXX $LDFLAGS $CXXFLAGS -o $NULL $SOURCES
)
RET=$?
;;