#!/bin/bash

SCRIPTFLAGS=
while [ $# -gt 0 ]; do
case $1 in
"-coverage") SCRIPTFLAGS+=" -coverage"; shift 1 ;;
"-rt2") SCRIPTFLAGS=" -rt2"; shift 1 ;;
*) echo "Usage: $0 [-rt2] [-coverage]"; exit 1 ;;
esac
done

echo "Batch execution of OOP tests: creating 1 report for each script file"
echo "You must have a symlink in this directory named perl and pointing to perl 5.6.0 or higher"

# OOP_negtest needs to be run with OOP enabled ('-k' flag) and memory leaks need to be ignored
echo "./perl ../Tools/SAtester.pl $SCRIPTFLAGS -oop -imemleaks -log OOP_negtest.report OOP_negtest.script"
./perl ../Tools/SAtester.pl $SCRIPTFLAGS -oop -imemleaks -log OOP_negtest.report OOP_negtest.script

# NonOOP_negtest needs to be run with OOP disabled (no '-k' flag)
echo "./perl ../Tools/SAtester.pl $SCRIPTFLAGS -log NonOOP_negtest.report NonOOP_negtest.script"
./perl ../Tools/SAtester.pl $SCRIPTFLAGS -log NonOOP_negtest.report NonOOP_negtest.script

echo "Finished. Reports are generated with .report extension."

