#!/bin/bash

# Dec 19, 2025
# Kevin C. O'Kane

rm -f key.dat data.dat

cat /dev/null > nohup.out

echo "Mumps and MDH validation routines"

chmod u+x *.mps

make -B -j 8

echo "y" | mumps-sql-db-create

echo " misc tests"

checkout < checkout.input

if (($? > 0)); then echo "execution error checkout.mps"; exit; fi

echo "new tests"

new01

if (($? > 0)); then echo "execution error new01.mps"; exit; fi

new02

if (($? > 0)); then echo "execution error new02.mps"; exit; fi

new03

if (($? > 0)); then echo "execution error new03.mps"; exit; fi

echo " local $order tests"

lclOrder

if (($? > 0)); then echo "execution lclOrder.mps error"; exit; fi

echo " perl backref test"

backref < backref.input

if (($? > 0)); then echo "execution backref.mps error"; exit; fi

echo " functions test"

fcns < fcns.input

if (($? > 0)); then echo "*** fcns.mps execution error"; exit; fi

echo " for loop tests"

for1

if (($? > 0)); then echo "execution error for1.mps"; exit; fi

for2

if (($? > 0)); then echo "execution error for2.mps"; exit; fi

for3

if (($? > 0)); then echo "execution error for3.mps"; exit; fi

echo " operator tests"

ops

if (($? > 0)); then echo "execution error ops.mps"; exit; fi

echo " goto and do tests"

go1

if (($? > 0)); then echo "execution error go1.mps"; exit; fi

echo " global stress test"

globals1

if (($? > 0)); then echo "execution error globals1.mps"; exit; fi

echo " zfunctions test"

zfunctions

if (($? > 0)); then echo "execution error zfunctions.mps"; exit; fi

echo "query qlength qsubscript"

qtst

if (($? > 0)); then echo "execution error qtst.mps"; exit; fi

echo "kill test"

./kill

if (($? > 0)); then echo "execution error kill.mps"; exit; fi

echo " subroutine tests"

# s6
# 
# if (($? > 0)); then echo "execution error s6.mps"; exit; fi

pieceTests

if (($? > 0)); then echo "execution error pieceTests.mps"; exit; fi

interp1

if (($? > 0)); then echo "execution error interp1.mps"; exit; fi

interp2

if (($? > 0)); then echo "execution error interp2.mps"; exit; fi

numTests

if (($? > 0)); then echo "execution error numTests.mps"; exit; fi

# echo "extract xxxxx"
extractTests
# echo "xxxxxxxxxxxxxx"

if (($? > 0)); then echo "execution error extractTests.mps"; exit; fi

# optional if readonly module exists
#	echo "readonly test - expect sum of 100 with garbled lines"
#	rm key.dat data.dat
#	./readonlysetup.mps
#	./readonly.mps &
#	./readonly.mps &
#	./readonly.mps &
#	./readonly.mps &
#	wait

if (($? > 0)); then echo "execution error"; exit; fi

