1f08c3bdfSopenharmony_ci#! /bin/sh
2f08c3bdfSopenharmony_ci# Copyright (c) Linux Test Project, 2010-2022
3f08c3bdfSopenharmony_ci# Copyright (c) 2002, Intel Corporation. All rights reserved.
4f08c3bdfSopenharmony_ci# Created by:  julie.n.fleischer REMOVE-THIS AT intel DOT com
5f08c3bdfSopenharmony_ci# This file is licensed under the GPL license.  For the full content
6f08c3bdfSopenharmony_ci# of this license, see the COPYING file at the top level of this
7f08c3bdfSopenharmony_ci# source tree.
8f08c3bdfSopenharmony_ci#
9f08c3bdfSopenharmony_ci# Use to build and run tests for a specific area
10f08c3bdfSopenharmony_ci
11f08c3bdfSopenharmony_ciTESTPATH=""
12f08c3bdfSopenharmony_ci
13f08c3bdfSopenharmony_ciBASEDIR="$(dirname "$0")/../${TESTPATH}/conformance/interfaces"
14f08c3bdfSopenharmony_ci
15f08c3bdfSopenharmony_ciusage()
16f08c3bdfSopenharmony_ci{
17f08c3bdfSopenharmony_ci    cat <<EOF
18f08c3bdfSopenharmony_ciusage: $(basename "$0") [AIO|MEM|MSG|SEM|SIG|THR|TMR|TPS]
19f08c3bdfSopenharmony_ci
20f08c3bdfSopenharmony_ciBuild and run the tests for POSIX area specified by the 3 letter tag
21f08c3bdfSopenharmony_ciin the POSIX spec
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_ciEOF
24f08c3bdfSopenharmony_ci}
25f08c3bdfSopenharmony_ci
26f08c3bdfSopenharmony_cirun_option_group_tests()
27f08c3bdfSopenharmony_ci{
28f08c3bdfSopenharmony_ci	local list_of_tests
29f08c3bdfSopenharmony_ci
30f08c3bdfSopenharmony_ci	list_of_tests=`find $1 -name '*.run-test' | sort`
31f08c3bdfSopenharmony_ci
32f08c3bdfSopenharmony_ci	if [ -z "$list_of_tests" ]; then
33f08c3bdfSopenharmony_ci		echo ".run-test files not found under $1, have been the tests compiled?"
34f08c3bdfSopenharmony_ci		exit 1
35f08c3bdfSopenharmony_ci	fi
36f08c3bdfSopenharmony_ci
37f08c3bdfSopenharmony_ci	for test_script in $list_of_tests; do
38f08c3bdfSopenharmony_ci		(cd "$(dirname "$test_script")" && ./$(basename "$test_script"))
39f08c3bdfSopenharmony_ci	done
40f08c3bdfSopenharmony_ci}
41f08c3bdfSopenharmony_ci
42f08c3bdfSopenharmony_cicase $1 in
43f08c3bdfSopenharmony_ciAIO)
44f08c3bdfSopenharmony_ci	echo "Executing asynchronous I/O tests"
45f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/aio_*"
46f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/lio_listio"
47f08c3bdfSopenharmony_ci	;;
48f08c3bdfSopenharmony_ciSIG)
49f08c3bdfSopenharmony_ci	echo "Executing signals tests"
50f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/sig*"
51f08c3bdfSopenharmony_ci	run_option_group_tests $BASEDIR/raise
52f08c3bdfSopenharmony_ci	run_option_group_tests $BASEDIR/kill
53f08c3bdfSopenharmony_ci	run_option_group_tests $BASEDIR/killpg
54f08c3bdfSopenharmony_ci	run_option_group_tests $BASEDIR/pthread_kill
55f08c3bdfSopenharmony_ci	run_option_group_tests $BASEDIR/pthread_sigmask
56f08c3bdfSopenharmony_ci	;;
57f08c3bdfSopenharmony_ciSEM)
58f08c3bdfSopenharmony_ci	echo "Executing semaphores tests"
59f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/sem*"
60f08c3bdfSopenharmony_ci	;;
61f08c3bdfSopenharmony_ciTHR)
62f08c3bdfSopenharmony_ci	echo "Executing threads tests"
63f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/pthread_*"
64f08c3bdfSopenharmony_ci	;;
65f08c3bdfSopenharmony_ciTMR)
66f08c3bdfSopenharmony_ci	echo "Executing timers and clocks tests"
67f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/time*"
68f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/*time"
69f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/clock*"
70f08c3bdfSopenharmony_ci	run_option_group_tests $BASEDIR/nanosleep
71f08c3bdfSopenharmony_ci	;;
72f08c3bdfSopenharmony_ciMSG)
73f08c3bdfSopenharmony_ci	echo "Executing message queues tests"
74f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/mq_*"
75f08c3bdfSopenharmony_ci	;;
76f08c3bdfSopenharmony_ciTPS)
77f08c3bdfSopenharmony_ci	echo "Executing process and thread scheduling tests"
78f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/*sched*"
79f08c3bdfSopenharmony_ci	;;
80f08c3bdfSopenharmony_ciMEM)
81f08c3bdfSopenharmony_ci	echo "Executing mapped, process and shared memory tests"
82f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/m*lock*"
83f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/m*map"
84f08c3bdfSopenharmony_ci	run_option_group_tests "$BASEDIR/shm_*"
85f08c3bdfSopenharmony_ci	;;
86f08c3bdfSopenharmony_ci*)
87f08c3bdfSopenharmony_ci	usage
88f08c3bdfSopenharmony_ci	exit 1
89f08c3bdfSopenharmony_ci	;;
90f08c3bdfSopenharmony_ciesac
91f08c3bdfSopenharmony_ci
92f08c3bdfSopenharmony_ciecho "****Tests Complete****"
93