#!/bin/sh
set -eux

usage () { echo>&2 "Usage: yosys-testuite"; exit 1; }
[ $# -eq 0 ] || usage

# Get number of CPUs from /proc/cpuinfo to run tests in parallell as
# during build, to avoid timeout on ppc64el, see
# <URL: https://lists.debian.org/debian-powerpc/2026/05/msg00003.html >.
NJOBS=$(grep -c ^processor /proc/cpuinfo) 

echo "INFO: Running yosys tests with -j${NJOBS} on $(dpkg --print-architecture)" 

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

make -j${NJOBS} vanilla-test CONFIG=gcc
