-
Notifications
You must be signed in to change notification settings - Fork 16
/
locate-test
executable file
·121 lines (106 loc) · 3.3 KB
/
locate-test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#! /bin/sh
# Copyright (c) 2002, Intel Corporation. All rights reserved.
# Created by: inaky.perez-gonzalez 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.
# Added FreeBSD compatibility changes by Craig Rodrigues
usage()
{
cat <<EOF
Usage: $(basename $0) [OPTIONs] DIRECTORY
Lists the tests (source/binary) available from the DIRECTORY directory
and down.
--buildable List only tests that require building
--execs List only tests that are executable
If you just want to build a test, but not run it,
do not include a main function into the .c file or
name it something including the "-buildonly" string.
--fmake Find functional makefiles.
--smake Find stress makefiles.
--frun Find functional run.sh files.
--srun Find stress run.sh files.
--help Show this help and exit
Filenames need to follow some standarized format for them to be picked
up by this tool. This might change in the future. So far, the ones
picked up are:
NUMBER-NUMBER.c [requires compilation]
NUMBER-NUMBER.sh [does not require compilation]
NUMBER-buildonly.c [requires compilation]
NAME.sh [does not require compilation]
Note that the [requires compilation] tags will mean that the actual
test name for TEST.c after compiling will be TEST. Currently it does
not support TESTs compiled from many different sources.
EOF
}
buildable="";
execs=""
print_execs=0
# Go through the cmd line options
while true
do
case "$1" in
"--buildable")
buildable="( -name [0-9]*-*.c ! -name [0-9]*-[0-9]*.sh )";
shift;
;;
"--execs")
print_execs=1;
execs="( ( -name [0-9]*-[0-9]*.c -o -name [0-9]*-[0-9]*.sh ) -a ! -name *-buildonly* )";
shift;
;;
"--fmake")
find functional/ -maxdepth 2 -mindepth 2 -type f -name "Makefile" -exec dirname '{}' ';'
exit 0;
;;
"--frun")
find functional/ -maxdepth 2 -mindepth 2 -type f -name "run.sh" -exec dirname '{}' ';'
exit 0;
;;
"--smake")
find stress/ -maxdepth 2 -mindepth 2 -type f -name "Makefile" -exec dirname '{}' ';'
exit 0;
;;
"--srun")
find stress/ -maxdepth 2 -mindepth 2 -type f -name "run.sh" -exec dirname '{}' ';'
exit 0;
;;
"--help")
usage;
exit 0;
;;
--*)
echo "Unknown option $1" 1>&2;
usage 1>&2;
exit 1;
;;
*)
break 2;
;;
esac
done
# Need the DIRECTORY arg ...
if [ -z "$1" ]
then
echo "Error: no root directory specified" 1>&2
usage 1>&2;
exit 1;
fi
# Simple version right now, just locate all:
WHERE="$1"
# Force something .c or .sh
# Avoid .o, backups
# IF --execs, force it has no "-buildonly"
# If --buildable, remove the .sh files
find "$WHERE" -type f \
\( \
\( -name "[0-9]*-*.c" -o -name "[0-9]*-[0-9]*.sh" \) \
! -name \*.o ! -name \*~ \
\) \
$buildable $execs \
| if [ $print_execs -eq 1 ]
then
sed 's/\.\(sh\|c\)$/.test/'
else
cat
fi