#!/bin/sh
set -eu

mode=${1:-stable}

set --
case "$mode" in
	stable)
		for test_path in src/cmd/ksh93/tests/*.sh
		do
			test_name=${test_path##*/}
			case "$test_name" in
				io.sh | variables.sh)
					continue
					;;
			esac
			set -- "$@" "$test_name"
		done
		;;
	flaky)
		set -- io.sh variables.sh
		;;
	*)
		echo "Unknown test mode: $mode" >&2
		exit 2
		;;
esac

test_root="$AUTOPKGTEST_TMP/install-root"

install -D -m 0644 \
	/usr/include/ksh/shopt.h \
	"$test_root/src/cmd/ksh93/shopt.h"

hosttype=$(bin/package host type)

HOSTTYPE="$hosttype" \
INSTALLROOT="$test_root" \
PACKAGEROOT="$PWD" \
LD_LIBRARY_PATH= \
KSH=/usr/bin/ksh93 \
SHCOMP=/usr/bin/shcomp93 \
bin/shtests --no-time "$@"
