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 8 usage() 9 { 10 cat <<EOF 11 Usage: $(basename "$0") [OPTIONs] DIRECTORY 12 13 Lists the tests (source/binary) available from the DIRECTORY directory 14 and 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 24 Filenames need to follow some standarized format for them to be picked 25 up by this tool. This might change in the future. So far, the ones 26 picked up are: 27 28 NUMBER-NUMBER.c [requires compilation] 29 NUMBER-NUMBER.sh [does not require compilation] 30 NUMBER-buildonly.c [requires compilation] 31 NAME.sh [does not require compilation] 32 33 Note that the [requires compilation] tags will mean that the actual 34 test name for TEST.c after compiling will be TEST. Currently it does 35 not support TESTs compiled from many different sources. 36 37 EOF 38 } 39 40 mode= 41 42 # Go through the cmd line options 43 while true 44 do 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 71 done 72 73 # Simple version right now, just locate all: 74 WHERE=${1:-.} 75 76 # Need the DIRECTORY arg ... 77 if [ ! -d "$WHERE" ]; then 78 echo >&2 "Error: $WHERE: no such directory" 79 exit 1 80 elif [ "x$mode" = x ]; then 81 echo >&2 "Error: no options specified" 82 usage >&2 83 exit 1 84 fi 85 86 case "$mode" in 87 buildonly) 88 find "$WHERE" -type f -name "*.c" | grep buildonly 89 ;; 90 runnable) 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 ;; 98 test-tools) 99 find "$WHERE" -type f -name '*-core.c' 100 ;; 101 esac 102