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 'genmake' -- "$@"`
171 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
173 # Note the quotes around `$TEMP': they are essential!
182 -f|--full) opt_full=true ; shift ;;
183 -a|--anum) opt_anum="$2" ; shift 2 ;;
184 -m|--mnum) opt_mnum="$2" ; shift 2 ;;
186 *) echo -e $USAGE ; exit 1 ;;
191 if [ -n "$opt_anum" ] ; then
193 echo opt_anum: DIR=$DIR >& 2
194 elif [ -n "$opt_mnum" ] ; then
196 echo opt_mnum: DIR=$DIR >& 2
199 # get filename from first argument
200 if [[ $# == 1 && -f $DIR/$1 ]] ; then
205 #echo "Dir: $DIR File: $FILE" >& 2
207 # populate $TC_FILES with files declared in CMakeLists.txt
208 if [[ -z $FILE ]]; then
209 if [[ ! $DIR == "." || $# == 0 ]] ; then
210 #echo Get tc files: DIR=$DIR >& 2
222 echo "Got all files in `pwd`" >& 2
223 #echo "TC_FILES: $TC_FILES" >& 2
225 TC_FILES="$DIR/$FILE"
226 echo "TC_FILES: $TC_FILES" >& 2
231 # run appropriate subcommand
232 if [ $opt_full == "true" ] ; then
233 tc_fullinfo $TC_FILES
234 elif [ -n "$opt_anum" ] ; then
236 elif [ -n "$opt_mnum" ] ; then