#!/bin/sh
set -eux

usage () { echo>&2 "Usage: yosys-testuite TESTDIR"; exit 1; }
[ $# -ge 1 ] || usage; testdir=$1; shift

mkdir -p "$testdir"

#YOSYS_TARBALL=${YOSYS_TARBALL:-/usr/src/yosys/yosys.tar*}
#[ ! -e "$testdir"/kernel/yosys.h ] || find "$testdir" -mindepth 1 -delete
#
#echo>&2 -n Unpacking...
#tar -xf $YOSYS_TARBALL --strip-components=1 -C "$testdir"
#echo done

cd "$testdir"

ln -sf /usr/bin/yosys .
ln -sf /usr/bin/yosys-abc .
ln -sf /usr/bin/yosys-config .

sed -i 's/^test:.*/test: $(EXTRA_TARGETS)/' Makefile

make test CONFIG=gcc ABCPULL=0
