diff options
-rw-r--r-- | package/mksh/Makefile | 9 | ||||
-rwxr-xr-x | package/mksh/files/test.sh | 85 |
2 files changed, 94 insertions, 0 deletions
diff --git a/package/mksh/Makefile b/package/mksh/Makefile index 7595dff9d..becfd5003 100644 --- a/package/mksh/Makefile +++ b/package/mksh/Makefile @@ -14,6 +14,9 @@ PKG_SITES:= $(MASTER_SITE_MIRBSD:distfiles/=dist/mir/mksh/) PKG_DFLT_MKSH:= y if !ADK_TOOLCHAIN_ONLY && !ADK_TARGET_WITHOUT_MMU +PKG_SUBPKGS:= MKSH MKSH_TEST +PKGSD_MKSH_TEST:= install testsuite + DISTFILES:= $(PKG_NAME)-R$(PKG_VERSION).tgz WRKDIST= $(WRKDIR)/$(PKG_NAME) @@ -22,6 +25,7 @@ include $(ADK_TOPDIR)/mk/package.mk $(eval $(call HOST_template,MKSH,mksh,$(PKG_VERSION)-$(PKG_RELEASE))) $(eval $(call PKG_template,MKSH,mksh,$(PKG_VERSION)-$(PKG_RELEASE),,$(PKG_DESCR),$(PKG_SECTION))) +$(eval $(call PKG_template,MKSH_TEST,mksh-test,$(PKG_VERSION)-$(PKG_RELEASE),,$(PKGSD_MKSH_TEST),$(PKG_SECTION))) TARGET_CPPFLAGS+= -DMKSHRC_PATH=\"/etc/mkshrc\" @@ -50,5 +54,10 @@ mksh-install: $(INSTALL_DIR) $(IDIR_MKSH)/bin $(INSTALL_BIN) $(WRKBUILD)/mksh $(IDIR_MKSH)/bin +mksh-test-install: + $(INSTALL_DIR) $(IDIR_MKSH_TEST)/opt/mksh + $(CP) $(WRKBUILD)/* $(IDIR_MKSH_TEST)/opt/mksh + $(INSTALL_BIN) ./files/test.sh $(IDIR_MKSH_TEST)/opt/mksh + include $(ADK_TOPDIR)/mk/host-bottom.mk include $(ADK_TOPDIR)/mk/pkg-bottom.mk diff --git a/package/mksh/files/test.sh b/package/mksh/files/test.sh new file mode 100755 index 000000000..6b6a6c439 --- /dev/null +++ b/package/mksh/files/test.sh @@ -0,0 +1,85 @@ +#!/bin/mksh +LC_ALL=C PATH='/usr/sbin:/bin:/sbin:/usr/bin'; export LC_ALL PATH +test -n "$KSH_VERSION" || exit 1 +set -A check_categories -- shell:legacy-no int:32 +pflag='/opt/mksh/mksh' +sflag='/opt/mksh/check.t' +usee=0 Pflag=0 Sflag=0 uset=0 vflag=1 xflag=0 +while getopts "C:e:fPp:QSs:t:v" ch; do case $ch { +(C) check_categories[${#check_categories[*]}]=$OPTARG ;; +(e) usee=1; eflag=$OPTARG ;; +(f) check_categories[${#check_categories[*]}]=fastbox ;; +(P) Pflag=1 ;; +(+P) Pflag=0 ;; +(p) pflag=$OPTARG ;; +(Q) vflag=0 ;; +(+Q) vflag=1 ;; +(S) Sflag=1 ;; +(+S) Sflag=0 ;; +(s) sflag=$OPTARG ;; +(t) uset=1; tflag=$OPTARG ;; +(v) vflag=1 ;; +(+v) vflag=0 ;; +(*) xflag=1 ;; +} +done +shift $((OPTIND - 1)) +set -A args -- '/opt/mksh/check.pl' -p "$pflag" +x= +for y in "${check_categories[@]}"; do +x=$x,$y +done +if [[ -n $x ]]; then +args[${#args[*]}]=-C +args[${#args[*]}]=${x#,} +fi +if (( usee )); then +args[${#args[*]}]=-e +args[${#args[*]}]=$eflag +fi +(( Pflag )) && args[${#args[*]}]=-P +if (( uset )); then +args[${#args[*]}]=-t +args[${#args[*]}]=$tflag +fi +(( vflag )) && args[${#args[*]}]=-v +(( xflag )) && args[${#args[*]}]=-x # force usage by synerr +if [[ -n $TMPDIR && -d $TMPDIR/. ]]; then +args[${#args[*]}]=-T +args[${#args[*]}]=$TMPDIR +fi +print Testing mksh for conformance: +fgrep -e MirOS: -e MIRBSD "$sflag" +print "This shell is actually:\n\t$KSH_VERSION" +print 'test.sh built for mksh R51 2015/07/10' +cstr='$os = defined $^O ? $^O : "unknown";' +cstr="$cstr"'print $os . ", Perl version " . $];' +for perli in perl no; do +if [[ $perli = no ]]; then +print Cannot find a working Perl interpreter, aborting. +exit 1 +fi +print "Trying Perl interpreter '$perli'..." +perlos=$($perli -e "$cstr") +rv=$? +print "Errorlevel $rv, running on '$perlos'" +if (( rv )); then +print "=> not using" +continue +fi +if [[ -n $perlos ]]; then +print "=> using it" +break +fi +done +(( Sflag )) || echo + $perli "${args[@]}" -s "$sflag" "$@" +(( Sflag )) || exec $perli "${args[@]}" -s "$sflag" "$@" +# use of the -S option for check.t split into multiple chunks +rv=0 +for s in "$sflag".*; do +echo + $perli "${args[@]}" -s "$s" "$@" +$perli "${args[@]}" -s "$s" "$@" +rc=$? +(( rv = rv ? rv : rc )) +done +exit $rv |