1f08c3bdfSopenharmony_ci#! /bin/sh 2f08c3bdfSopenharmony_ci# Copyright (c) 2002, Intel Corporation. All rights reserved. 3f08c3bdfSopenharmony_ci# Created by: inaky.perez-gonzalez REMOVE-THIS AT intel DOT com 4f08c3bdfSopenharmony_ci# This file is licensed under the GPLv2 license. For the full content 5f08c3bdfSopenharmony_ci# of this license, see the COPYING file at the top level of this 6f08c3bdfSopenharmony_ci# source tree. 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ciusage() 9f08c3bdfSopenharmony_ci{ 10f08c3bdfSopenharmony_ci cat <<EOF 11f08c3bdfSopenharmony_ciUsage: $(basename "$0") [OPTIONs] DIRECTORY 12f08c3bdfSopenharmony_ci 13f08c3bdfSopenharmony_ciLists the tests (source/binary) available from the DIRECTORY directory 14f08c3bdfSopenharmony_ciand down. 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ci --buildonly List only tests that require building 17f08c3bdfSopenharmony_ci --runnable List only tests that are executable 18f08c3bdfSopenharmony_ci If you just want to build a test, but not run it, 19f08c3bdfSopenharmony_ci do not include a main function into the .c file or 20f08c3bdfSopenharmony_ci name it something including the "-buildonly" string. 21f08c3bdfSopenharmony_ci --test-tools List all test tools that require building. 22f08c3bdfSopenharmony_ci --help Show this help and exit 23f08c3bdfSopenharmony_ci 24f08c3bdfSopenharmony_ciFilenames need to follow some standarized format for them to be picked 25f08c3bdfSopenharmony_ciup by this tool. This might change in the future. So far, the ones 26f08c3bdfSopenharmony_cipicked up are: 27f08c3bdfSopenharmony_ci 28f08c3bdfSopenharmony_ciNUMBER-NUMBER.c [requires compilation] 29f08c3bdfSopenharmony_ciNUMBER-NUMBER.sh [does not require compilation] 30f08c3bdfSopenharmony_ciNUMBER-buildonly.c [requires compilation] 31f08c3bdfSopenharmony_ciNAME.sh [does not require compilation] 32f08c3bdfSopenharmony_ci 33f08c3bdfSopenharmony_ciNote that the [requires compilation] tags will mean that the actual 34f08c3bdfSopenharmony_citest name for TEST.c after compiling will be TEST. Currently it does 35f08c3bdfSopenharmony_cinot support TESTs compiled from many different sources. 36f08c3bdfSopenharmony_ci 37f08c3bdfSopenharmony_ciEOF 38f08c3bdfSopenharmony_ci} 39f08c3bdfSopenharmony_ci 40f08c3bdfSopenharmony_cimode= 41f08c3bdfSopenharmony_ci 42f08c3bdfSopenharmony_ci# Go through the cmd line options 43f08c3bdfSopenharmony_ciwhile true 44f08c3bdfSopenharmony_cido 45f08c3bdfSopenharmony_ci case "$1" in 46f08c3bdfSopenharmony_ci "--buildonly") 47f08c3bdfSopenharmony_ci mode="buildonly" 48f08c3bdfSopenharmony_ci shift 49f08c3bdfSopenharmony_ci ;; 50f08c3bdfSopenharmony_ci "--runnable") 51f08c3bdfSopenharmony_ci mode="runnable" 52f08c3bdfSopenharmony_ci shift 53f08c3bdfSopenharmony_ci ;; 54f08c3bdfSopenharmony_ci "--test-tools") 55f08c3bdfSopenharmony_ci mode="test-tools" 56f08c3bdfSopenharmony_ci shift 57f08c3bdfSopenharmony_ci ;; 58f08c3bdfSopenharmony_ci "--help") 59f08c3bdfSopenharmony_ci usage 60f08c3bdfSopenharmony_ci exit 0 61f08c3bdfSopenharmony_ci ;; 62f08c3bdfSopenharmony_ci --*) 63f08c3bdfSopenharmony_ci echo >&2 "Unknown option: $1" 64f08c3bdfSopenharmony_ci usage >&2 65f08c3bdfSopenharmony_ci exit 1 66f08c3bdfSopenharmony_ci ;; 67f08c3bdfSopenharmony_ci *) 68f08c3bdfSopenharmony_ci break 69f08c3bdfSopenharmony_ci ;; 70f08c3bdfSopenharmony_ci esac 71f08c3bdfSopenharmony_cidone 72f08c3bdfSopenharmony_ci 73f08c3bdfSopenharmony_ci# Simple version right now, just locate all: 74f08c3bdfSopenharmony_ciWHERE=${1:-.} 75f08c3bdfSopenharmony_ci 76f08c3bdfSopenharmony_ci# Need the DIRECTORY arg ... 77f08c3bdfSopenharmony_ciif [ ! -d "$WHERE" ]; then 78f08c3bdfSopenharmony_ci echo >&2 "Error: $WHERE: no such directory" 79f08c3bdfSopenharmony_ci exit 1 80f08c3bdfSopenharmony_cielif [ "x$mode" = x ]; then 81f08c3bdfSopenharmony_ci echo >&2 "Error: no options specified" 82f08c3bdfSopenharmony_ci usage >&2 83f08c3bdfSopenharmony_ci exit 1 84f08c3bdfSopenharmony_cifi 85f08c3bdfSopenharmony_ci 86f08c3bdfSopenharmony_cicase "$mode" in 87f08c3bdfSopenharmony_cibuildonly) 88f08c3bdfSopenharmony_ci find "$WHERE" -type f -name "*.c" | grep buildonly 89f08c3bdfSopenharmony_ci ;; 90f08c3bdfSopenharmony_cirunnable) 91f08c3bdfSopenharmony_ci # XXX (garrcoop): the tools part is a hack to ensure that we don't 92f08c3bdfSopenharmony_ci # waltz down the tools directory and try and build t0 (which doesn't 93f08c3bdfSopenharmony_ci # make sense as it's a tool, not a test). Better criterion needs to 94f08c3bdfSopenharmony_ci # be established for this file. 95f08c3bdfSopenharmony_ci find "$WHERE/conformance" "$WHERE/stress" -type f -name '*[0-9].c' -o -name '[0-9]*-[0-9]*.sh' | grep -v buildonly | grep -v '^./tools' 96f08c3bdfSopenharmony_ci find "$WHERE/functional" -type f -name '*.c' 97f08c3bdfSopenharmony_ci ;; 98f08c3bdfSopenharmony_citest-tools) 99f08c3bdfSopenharmony_ci find "$WHERE" -type f -name '*-core.c' 100f08c3bdfSopenharmony_ci ;; 101f08c3bdfSopenharmony_ciesac 102