#! /bin/sh
# Copyright (c) 2002, Intel Corporation. All rights reserved.
# Created by:  julie.n.fleischer REMOVE-THIS AT intel DOT com
# This file is licensed under the GPL license.  For the full content
# of this license, see the COPYING file at the top level of this
# source tree.
#
# Use to build and run tests for a specific area

BASEDIR=conformance/interfaces

usage()
{
    cat <<EOF 
Usage: $0 [AIO|MEM|MSG|SEM|SIG|THR|TMR|TPS]

Build and run the tests for POSIX area specified by the 3 letter tag
in the POSIX spec

EOF
}

runtests()
{
	for test in `ls -d $1`; do
		POSIX_TARGET=$test make build-tests
		POSIX_TARGET=$test make run-tests
	done
}

case $1 in
  AIO) echo "Executing asynchronous I/O tests"
	runtests "$BASEDIR/aio_*"
	runtests "$BASEDIR/lio_listio"
	;;
  SIG) echo "Executing signals tests"
	runtests "$BASEDIR/sig*"
	runtests $BASEDIR/raise
	runtests $BASEDIR/kill
	runtests $BASEDIR/killpg
	runtests $BASEDIR/pthread_kill
	runtests $BASEDIR/pthread_sigmask
	;;
  SEM) echo "Executing semaphores tests"
	runtests "$BASEDIR/sem*"
	;;
  THR) echo "Executing threads tests"
	runtests "$BASEDIR/pthread_*"
	;;
  TMR) echo "Executing timers and clocks tests"
	runtests "$BASEDIR/time*"
	runtests "$BASEDIR/*time"
	runtests "$BASEDIR/clock*"
	runtests $BASEDIR/nanosleep
	;;
  MSG) echo "Executing message queues tests"
	runtests "$BASEDIR/mq_*"
	;;
  TPS) echo "Executing process and thread scheduling tests"
	runtests "$BASEDIR/*sched*"
	;;
  MEM) echo "Executing mapped, process and shared memory tests"
	runtests "$BASEDIR/m*lock*"
	runtests "$BASEDIR/m*map"
	runtests "$BASEDIR/shm_*"
	;;
  *)	usage
	exit 1
	;;
esac

echo "****Tests Complete****"
