[PATCH 1/3] testsuite: warning when bash is not in use.

Natanael Copa ncopa at alpinelinux.org
Tue Aug 19 06:24:43 UTC 2014


On Mon, 18 Aug 2014 00:11:10 -0300
Guilherme Maciel Ferreira <guilherme.maciel.ferreira at gmail.com> wrote:

> The test suite scripts fail with "Bad substitution" error when using a shell
> other than Bash. This patch adds an alert to the user, to remind him to change
> its /bin/sh symlink.

Wouldn't it be better to do:
diff --git a/testsuite/runtest b/testsuite/runtest
index 51575d9..35968b1 100755
--- a/testsuite/runtest
+++ b/testsuite/runtest
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Usage:
 # runtest [applet1] [applet2...]
 

Or even better, fix the script to be posix compliant?

> 
> Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira at gmail.com>
> ---
>  Makefile.custom |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/Makefile.custom b/Makefile.custom
> index f8a1283..706e795 100644
> --- a/Makefile.custom
> +++ b/Makefile.custom
> @@ -51,6 +51,9 @@ ifneq ($(strip $(DO_INSTALL_LIBS)),n)
>  	done
>  endif
>  
> +# Get the real shell to check if bash is used, otherwise some test may fail
> +SHELL_IN_USE := $(shell readlink $(SHELL))
> +
>  # Not very elegant: copies testsuite to objdir...
>  # (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
>  .PHONY: check
> @@ -59,6 +62,10 @@ ifeq ($(CONFIG_UNIT_TEST),y)
>  UNIT_CMD = ./busybox unit
>  endif
>  check test: busybox busybox.links
> +	@if [ x"$(SHELL_IN_USE)" != x"/bin/bash" ]; then \
> +		echo "WARNING: The $(SHELL) is a symlink to $(SHELL_IN_USE), but test" \
> +		     "suite requires /bin/bash to run properly."; \
> +	fi
>  	$(UNIT_CMD)
>  	test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
>  	bindir=$(objtree) srcdir=$(srctree)/testsuite \



More information about the busybox mailing list