4 Usage note: retriever.sh [option] [directory]
6 none retrieve TC names with corresponding startup and cleanup functions
7 -f retrieveve 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;
50 if [[ -z "$1" ]]; then
62 /^void .*startup\(void\)/ {
67 /^void .*cleanup\(void\)/ {
73 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
78 gsub(/\(void\).*/,"");
79 if (tc_list != "") tc_list = tc_list "\n";
80 tc_list = tc_list $0 OFS start_fun OFS clean_fun
99 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
116 # TODO: fix this hardcoded value
120 function tc_fullinfo {
135 for (i = 4; i <= NF; i++) {
136 purpose = purpose " " $i;
141 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
146 gsub(/\(void\)$/,"");
147 if (tc_list != "") tc_list = tc_list "\n";
148 tc_list = tc_list $0 OFS set OFS purpose;
163 # usage note and exit:
164 # - argument begin with '-' but is not recognised or number of arguments is > 3,
165 # - argument doesn't begin with '-' and number of arguments is > 2
166 if [[ ( "$1" == -* && ( ! "$1" =~ ^-(anum|mnum|f)$ || $# > 3 ) ) || ( "$1" != -* && $# > 2 ) ]]; then
171 # get directory from last argument (or assume current one)
172 if [[ ! "$1" =~ ^-(anum|mnum|f)$ ]]; then
178 # get filename from last argument
179 if [[ $# == 3 && -f $DIR/$3 ]] ; then
181 elif [[ $# == 2 && -f $DIR/$2 ]] ; then
185 #echo "Dir: $DIR File: $FILE" >& 2
188 # populate $TC_FILES with files declared in CMakeLists.txt
189 if [[ -z $FILE ]]; then
194 echo "Got all files" >& 2
196 TC_FILES="$DIR/$FILE"
197 echo "TC_FILES: $TC_FILES" >& 2
202 # run appropriate subcommand
209 tc_fullinfo $TC_FILES ;;
211 tc_names $TC_FILES ;;