#!/bin/sh -e

# prepare before test

cp -rf scripts TestSuite oraclesdmrg "$AUTOPKGTEST_TMP"
cd "$AUTOPKGTEST_TMP"
mkdir -p src
cp -f /usr/bin/dmrg $(find /usr/lib -name observe -type f) src

# Limit the number of threads in OpenMP
OMP_NUM_THREADS=$(test $(nproc) -gt 4 && echo 4 || echo $(nproc))
export OMP_NUM_THREADS
echo "Limiting the number of OpenMP thread via OMP_NUM_THREADS=$OMP_NUM_THREADS"

# run test

cd "$AUTOPKGTEST_TMP"/TestSuite
rm -Rf tests/
cp -f batchDollarized.pbs.sample batchDollarized.pbs
./ci.pl -n "$1-$2" -S bash

# compare test results with oracles reference

./postCi.pl -g "$AUTOPKGTEST_TMP"/oraclesdmrg/oracles/tests -n '$1-$2'
