#!/bin/sh

# Requires variables: LAUNCH_EXIT_CODE, STDERR_FN
# Produces variables: TEST_PASSED, RESULT_COMMENT, ERROR_LEVEL

if [ `grep -E 'Assertion' <"$STDERR_FN" | wc -l` -gt 0 ]; then
    TEST_PASSED=0
    RESULT_COMMENT="Assertion failed"
    ERROR_LEVEL=3
elif [ `grep -E 'RTS fatal' <"$STDERR_FN" | wc -l` -gt 0 ]; then
    TEST_PASSED=0
    RESULT_COMMENT="RTS fatal"
    ERROR_LEVEL=2
elif [ `grep -E 'RTS err' <"$STDERR_FN" | wc -l` -gt 0 ]; then
    TEST_PASSED=0
    RESULT_COMMENT="RTS err"
    ERROR_LEVEL=1
elif [ $LAUNCH_EXIT_CODE -ne 0 ]; then
    TEST_PASSED=0
    RESULT_COMMENT="Launch failure"
    ERROR_LEVEL=4
else
    TEST_PASSED=1
    RESULT_COMMENT="OK"
    ERROR_LEVEL=0
fi
