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