4 Usage note: retriever.sh [option] [directory] test-files
6 none retrieve TC names with corresponding startup and cleanup functions
7 -f retrieve TC name with corresponding "set" and "purpose" clauses
8 -anum retrieve automatic TC number
9 -mnum retrieve manual TC number
11 In case of TC in form of "int tc_name()" script will abort.
12 ("int tc_name(void)" is a proper function signature)
16 function get_tc_files {
17 CMAKE_FILE="$DIR/CMakeLists.txt"
18 if [ ! -e $CMAKE_FILE ]; then
19 echo "File $CMAKE_FILE not found. Aborting..."
23 TC_FILES=$(cat $CMAKE_FILE | awk -vDIR="$DIR" '
32 /LIST\(APPEND TC_SOURCES/ {
44 files = files " " DIR "/" $1;
55 if [[ -z "$1" ]]; then
71 /^void .*startup\(void\)/ {
76 /^void .*cleanup\(void\)/ {
82 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
87 gsub(/\(void\).*/,"");
88 if (tc_list != "") tc_list = tc_list "\n";
89 tc_list = tc_list $0 OFS start_fun OFS clean_fun
108 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
125 # TODO: fix this hardcoded value
129 function tc_fullinfo {
144 for (i = 4; i <= NF; i++) {
145 purpose = purpose " " $i;
150 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
155 gsub(/\(void\)$/,"");
156 if (tc_list != "") tc_list = tc_list "\n";
157 tc_list = tc_list $0 OFS set OFS purpose;
171 TEMP=`getopt -o f::,a:,m: --long full::,anum:,mnum: \
172 -n 'retriever.sh' -- "$@"`
174 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
176 # Note the quotes around `$TEMP': they are essential!
186 -f|--full) opt_full_dir="$2" ; opt_full="true" ; shift 2 ;;
187 -a|--anum) opt_anum="$2" ; shift 2 ;;
188 -m|--mnum) opt_mnum="$2" ; shift 2 ;;
190 *) echo -e $USAGE ; exit 1 ;;
194 #echo "###Retriever" >& 2
195 #echo opt_full: {$opt_full} >& 2
196 #echo opt_full_dir: {$opt_full_dir} >& 2
199 if [ -n "$opt_anum" ] ; then
201 echo opt_anum: DIR=$DIR >& 2
202 elif [ -n "$opt_mnum" ] ; then
204 echo opt_mnum: DIR=$DIR >& 2
205 elif [ "$opt_full" == "true" ] ; then
206 if [ -n $opt_full_dir ] ; then
208 echo opt_full: DIR=$DIR >& 2
213 # get filename from first argument
214 if [[ $# == 1 && -f $DIR/$1 ]] ; then
219 #echo "Dir: $DIR File: $FILE" >& 2
221 # populate $TC_FILES with files declared in CMakeLists.txt
222 if [[ -z $FILE ]]; then
223 if [[ ! $DIR == "." || $# == 0 ]] ; then
224 #echo Get tc files: DIR=$DIR >& 2
236 echo "Got all files in `pwd`" >& 2
237 #echo "TC_FILES: $TC_FILES" >& 2
239 TC_FILES="$DIR/$FILE"
240 echo "TC_FILES: $TC_FILES" >& 2
245 # run appropriate subcommand
246 if [ "$opt_full" == "true" ] ; then
247 tc_fullinfo $TC_FILES
248 elif [ -n "$opt_anum" ] ; then
250 elif [ -n "$opt_mnum" ] ; then