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_old {
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;
49 function get_tc_files {
50 TC_FILES=$(cd ../../build; cmake -LA -N 2>/dev/null | grep TC_SOURCE_LIST | perl -n -e 'my ($blah, $vars)=split(/=/,$_);my @files=split(/;/, $vars); print join("\n", @files) ;' )
54 if [[ -z "$1" ]]; then
66 /^void .*startup\(void\)/ {
71 /^void .*cleanup\(void\)/ {
77 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
82 gsub(/\(void\).*/,"");
83 if (tc_list != "") tc_list = tc_list "\n";
84 tc_list = tc_list $0 OFS start_fun OFS clean_fun
103 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
120 # TODO: fix this hardcoded value
124 function tc_fullinfo {
139 for (i = 4; i <= NF; i++) {
140 purpose = purpose " " $i;
145 print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
150 gsub(/\(void\)$/,"");
151 if (tc_list != "") tc_list = tc_list "\n";
152 tc_list = tc_list $0 OFS set OFS purpose;
167 # usage note and exit:
168 # - argument begin with '-' but is not recognised or number of arguments is > 3,
169 # - argument doesn't begin with '-' and number of arguments is > 2
170 if [[ ( "$1" == -* && ( ! "$1" =~ ^-(anum|mnum|f|l)$ || $# > 3 ) ) || ( "$1" != -* && $# > 2 ) ]]; then
175 # get directory from last argument (or assume current one)
176 if [[ ! "$1" =~ ^-(anum|mnum|f|l)$ ]]; then
182 # get filename from last argument
183 if [[ $# == 3 && -f $DIR/$3 ]] ; then
185 elif [[ $# == 2 && -f $DIR/$2 ]] ; then
189 #echo "Dir: $DIR File: $FILE" >& 2
192 # populate $TC_FILES with files declared in CMakeLists.txt
193 if [[ -z $FILE ]]; then
198 echo "Got all files" >& 2
200 TC_FILES="$DIR/$FILE"
201 echo "TC_FILES: $TC_FILES" >& 2
206 # run appropriate subcommand
213 tc_fullinfo $TC_FILES ;;
217 tc_names $TC_FILES ;;