#!/bin/sh

# This script is the top level script for the lsb-xml test suites.
# There are two kinds of test suites available with XML. 
# a) XML regression test suite
# b) XML API test cases 
# This script first executes XML regression test and after that XML API test.
# The output journal file produced by this script is journal.libxml2

# (sb) upstream regression tests changed with 2.6.27
rm -f result
if [ -f /usr/lib64/libxml2.so.2 ]; then
    XMLLIB=/usr/lib64/libxml2.so.2
else
    XMLLIB=/usr/lib/libxml2.so.2
fi
MINOR=`LC_ALL=C ls -ll $XMLLIB | awk '{print $11}' | sed 's|libxml2.so.2||;s|\.[0-9]*\.||;s|\*||'`
if [ $MINOR -gt 26 ]; then
    ln -sf result27 result
else
    ln -sf result21 result
fi

if [ ! -f ./runtest ]; then
    echo "XML regression test binary is missing, terminating!"
    echo ""
    exit 1
else
    echo "Starting XML regression test..."
    ./runtest
fi

if [ ! -f ./testapi ]; then
    echo "XML API test binary is missing, terminating!"
    echo ""
    exit 1
else
    echo "Starting XML API test..."
    ./testapi
fi

if [ -f ./journal.runtest ] && [ -f ./journal.testapi ]; then
    cat ./journal.runtest ./journal.testapi > ./journal.libxml2 
    rm -rf ./journal.runtest ./journal.testapi ./stderr-dump.log
else
    echo "Journal files are missing"
    echo ""
    exit 1
fi
