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" '
41 files = files " " DIR "/" $1;
52 if [[ -z "$1" ]]; then
68 /^void .*startup\(void\)/ {
73 /^void .*cleanup\(void\)/ {
79 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
84 gsub(/\(void\).*/,"");
85 if (tc_list != "") tc_list = tc_list "\n";
86 tc_list = tc_list $0 OFS start_fun OFS clean_fun
105 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
122 # TODO: fix this hardcoded value
126 function tc_fullinfo {
141 for (i = 4; i <= NF; i++) {
142 purpose = purpose " " $i;
147 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
152 gsub(/\(void\)$/,"");
153 if (tc_list != "") tc_list = tc_list "\n";
154 tc_list = tc_list $0 OFS set OFS purpose;
168 TEMP=`getopt -o f::,a:,m: --long full::,anum:,mnum: \
169 -n 'retriever.sh' -- "$@"`
171 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
173 # Note the quotes around `$TEMP': they are essential!
183 -f|--full) opt_full_dir="$2" ; opt_full="true" ; shift 2 ;;
184 -a|--anum) opt_anum="$2" ; shift 2 ;;
185 -m|--mnum) opt_mnum="$2" ; shift 2 ;;
187 *) echo -e $USAGE ; exit 1 ;;
191 #echo "###Retriever" >& 2
192 #echo opt_full: {$opt_full} >& 2
193 #echo opt_full_dir: {$opt_full_dir} >& 2
196 if [ -n "$opt_anum" ] ; then
198 echo opt_anum: DIR=$DIR >& 2
199 elif [ -n "$opt_mnum" ] ; then
201 echo opt_mnum: DIR=$DIR >& 2
202 elif [ "$opt_full" == "true" ] ; then
203 if [ -n $opt_full_dir ] ; then
205 echo opt_full: DIR=$DIR >& 2
210 # get filename from first argument
211 if [[ $# == 1 && -f $DIR/$1 ]] ; then
216 #echo "Dir: $DIR File: $FILE" >& 2
218 # populate $TC_FILES with files declared in CMakeLists.txt
219 if [[ -z $FILE ]]; then
220 if [[ ! $DIR == "." || $# == 0 ]] ; then
221 #echo Get tc files: DIR=$DIR >& 2
233 echo "Got all files in `pwd`" >& 2
234 #echo "TC_FILES: $TC_FILES" >& 2
236 TC_FILES="$DIR/$FILE"
237 echo "TC_FILES: $TC_FILES" >& 2
242 # run appropriate subcommand
243 if [ "$opt_full" == "true" ] ; then
244 tc_fullinfo $TC_FILES
245 elif [ -n "$opt_anum" ] ; then
247 elif [ -n "$opt_mnum" ] ; then