From ec43ab469dec9b18a3393be9f51790a09f5d7948 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 3 May 2019 09:29:26 +0100 Subject: testsuite: allow tests to work on Microsoft Windows Signed-off-by: Ron Yorston --- testsuite/busybox.tests | 19 +++++++++++++++---- testsuite/runtest | 18 ++++++++++++++++-- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/testsuite/busybox.tests b/testsuite/busybox.tests index beb17440c..a671fa082 100755 --- a/testsuite/busybox.tests +++ b/testsuite/busybox.tests @@ -7,11 +7,22 @@ . ./testing.sh test -f "$bindir/.config" && . "$bindir/.config" -ln -s `which busybox` unknown +if [ -f $bindir/busybox.exe ]; then + # Copy rather than link busybox.exe: we can only make hard + # links which can't be deleted because Windows sees the + # executable as running. + suffix=".exe" + lncmd="cp" +else + suffix="" + lncmd="ln -s" +fi + +$lncmd `which busybox` unknown$suffix testing "busybox as unknown name" "./unknown 2>&1" \ "unknown: applet not found\n" "" "" -rm unknown +rm unknown$suffix # We need busybox --help to be enabled for the rest of tests test x"$CONFIG_BUSYBOX" = x"y" \ @@ -23,7 +34,7 @@ optional FEATURE_VERBOSE_USAGE testing "busybox --help busybox" "true | busybox --help busybox 2>&1 | cat" "$HELPDUMP\n" "" "" SKIP= -ln -s `which busybox` busybox-suffix +$lncmd `which busybox` busybox-suffix$suffix for i in busybox ./busybox-suffix do testing "$i" "$i 2>&1 | cat" "$HELPDUMP\n" "" "" @@ -42,6 +53,6 @@ do testing "$i --help unknown" "$i --help unknown 2>&1" \ "unknown: applet not found\n" "" "" done -rm busybox-suffix +rm busybox-suffix$suffix exit $FAILCOUNT diff --git a/testsuite/runtest b/testsuite/runtest index 44f9cd1a1..9f9e8d3bd 100755 --- a/testsuite/runtest +++ b/testsuite/runtest @@ -99,6 +99,20 @@ if [ x"$1" = x"-v" ]; then shift fi +if [ -f $bindir/busybox.exe ]; then + suffix=".exe" + lnflag="" + + # Some tests require /bin/echo and /bin/true exist + test ! -d /tmp && mkdir /tmp + test ! -d /bin && mkdir /bin + test ! -f /bin/echo.exe && cp "$bindir/busybox.exe" /bin/echo.exe + test ! -f /bin/true.exe && cp "$bindir/busybox.exe" /bin/true.exe +else + suffix="" + lnflag="-s" +fi + implemented=$( printf "busybox " # always implemented "$bindir/busybox" 2>&1 | @@ -128,7 +142,7 @@ for i in $implemented; do # Note: if $LINKSDIR/applet exists, we do not overwrite it. # Useful if one wants to run tests against a standard utility, # not an applet. - ln -s "$bindir/busybox" "$LINKSDIR/$i" 2>/dev/null + ln $lnflag "$bindir/busybox$suffix" "$LINKSDIR/$i$suffix" 2>/dev/null done # Set up option flags so tests can be selective. @@ -146,7 +160,7 @@ for applet in $applets; do # Is this a new-style test? if [ -f "$applet.tests" ]; then - if [ ! -e "$LINKSDIR/$applet" ]; then + if [ ! -e "$LINKSDIR/$applet$suffix" ]; then # (avoiding bash'ism "${applet:0:4}") if ! echo "$applet" | grep "^all_" >/dev/null; then echo "SKIPPED: $applet (not built)" -- cgit v1.2.3-55-g6feb