#!/bin/sh
#
# see: The MySQL Test Framework :: 7 Creating and Executing Unit Tests
#   (MySQL Cluster Documentation)/mysqltest/en/unit-test.html
# see: Test Anything Protocol (TAP)
#   http://testanything.org/wiki/index.php/Main_Page
#   http://en.wikipedia.org/wiki/Test_Anything_Protocol

# not sure which protocol version we're using
#echo "TAP version 13"

# test range
echo "1..3"

# this script gets invoked from $(top_srcdir)/unittest
cd ../storage/ndb/src/ndbjtie/jtie/test

# log file for output from this script
log="`pwd`/jtie_unit_tests-t.log"
rm -f "$log"
touch "$log"

test_counter=0

#
# Run a simpler shell script test, and report it as TAP
#
# Arguments:
#   shell script hame
#
run_test()
{
    test_name=$1;
    test_counter=`expr $test_counter + 1`
    script_name="test_$test_name.sh"

    cd $test_name
    echo "running test '`pwd`/$test_name':" >> "$log" 2>&1
    if [ ! -x "$script_name" ]; then
       status="ok $test_counter # skip $test_name test file missing"
    else
      ./$script_name >> "$log" 2>&1
      s=""
      if [ "$?" -ne "0" ]; then
        s="not "
      fi
      status="${s}ok $test_counter - $test_name"
    fi;
    echo "$status" >> "$log" 2>&1
    echo "" >> "$log" 2>&1
    echo "$status"
    cd ..
}

run_test "myapi"
run_test "myjapi"
run_test "unload"

echo "done." >> "$log" 2>&1
