]> git.saurik.com Git - apple/ld64.git/blob - ld64-134.9/unit-tests/proctor-run
ld64-134.9.tar.gz
[apple/ld64.git] / ld64-134.9 / unit-tests / proctor-run
1 #!/bin/sh
2
3 all_archs="ppc ppc64 i386 x86_64"
4
5 sysattr()
6 {
7 echo " <sysattr name=\"$1\" value=\"$2\" />"
8 }
9
10 doresults()
11 {
12 local ver
13
14 echo "<tests end_time=\"`date +%s`\" start_time=\"$start_time\" comment=\""$comment"\">"
15
16 echo " <sysattrs>"
17 sysattr cctools "`as</dev/null -v 2>&1 |sed 's/.*cctools-//;s/,.*//'`"
18 sysattr hostname "`hostname`"
19 sysattr os "`uname -r`"
20 sysattr platform "`uname -m`"
21 sysattr ld64 "`ld64 -v 2>&1|sed 's/.*PROJECT://;s/ .*//'`"
22 sysattr ld "`ld_classic -v 2>&1|sed 's/.*cctools-//;s/ .*//'`"
23 sysattr gcc "`gcc --version|head -1`"
24 sysattr processor "`uname -p`"
25 sysattr LANG "$LANG"
26 sysattr LC_CTYPE "$LC_CTYPE"
27 sysattr LC_MESSAGES "$LC_MESSAGES"
28 sysattr LC_ALL "$LC_ALL"
29 sysattr TMPDIR "$TMPDIR"
30 sysattr GCC_EXEC_PREFIX "$GCC_EXEC_PREFIX"
31 sysattr COMPILER_PATH "$COMPILER_PATH"
32 sysattr LIBRARY_PATH "$LIBRARY_PATH"
33 sysattr LANG "$LANG"
34 sysattr CPATH "$CPATH"
35 sysattr C_INCLUDE_PATH "$C_INCLUDE_PATH"
36 sysattr CPLUS_INCLUDE_PATH "$CPLUS_INCLUDE_PATH"
37 sysattr OBJC_INCLUDE_PATH "$OBJC_INCLUDE_PATH"
38 sysattr DEPENDENCIES_OUTPUT "$DEPENDENCIES_OUTPUT"
39 sysattr SUNPRO_DEPENDENCIES "$SUNPRO_DEPENDENCIES"
40 echo " </sysattrs>"
41
42 echo "<tools>"
43 echo "<tool name=\"ld\">"
44 echo " <results incomplete=\"0\">"
45 for i in $*
46 do
47 echo " <testgroup name=\"$i\">"
48 cat $i
49 echo " </testgroup>"
50 done
51
52 echo " </results>"
53 echo "</tool>"
54 echo "</tools>"
55 echo "</tests>"
56
57 #rm $*
58 }
59
60 find_path_to_test_dir()
61 {
62 # FIND THE PATH TO THE TEST DIR
63 # SO THAT WE CAN ADD THE BIN DIR INTO
64 # THE SEARCH PATH
65
66 # remember the top level execution dir
67 chmod +x "$0" # just in case
68
69 #add path to $0 into search
70 local savedir
71 savedir=$PWD
72 DIRNAME=`dirname $0`
73 [ -d "$DIRNAME" ] && cd "$DIRNAME"
74 PATH=$PATH:$PWD
75 cd "$savedir"
76
77 chmod +x "$0" # just in case
78 EXECNAME=`which $0`
79 DIRNAME=`dirname "$EXECNAME"`
80 if [ -d "$DIRNAME" ]
81 then
82 TEST_HOME_DIR=`cd "$DIRNAME";pwd`
83 fi
84
85 if [ -z "$TEST_HOME_DIR" ]
86 then
87 TEST_HOME_DIR="$savedir" # Give up and assume current dir
88 fi
89
90 cd "$TEST_HOME_DIR"
91 cd ../build/Release
92
93 PATH="$PWD":"$TEST_HOME_DIR/bin":"$PATH"
94 cd "$savedir"
95 }
96
97 start_time=`date +%s`
98
99 find_path_to_test_dir
100
101 # Execute from the location of the script; or if not found the current loc
102 [ -d $TEST_HOME_DIR/test-cases ] && cd $TEST_HOME_DIR/test-cases || cd test-cases
103
104 rm-stale-test-logs 3 >/dev/null &
105
106 make -C ../src # make sure the binaries are available
107
108 DATEFORMAT=`date +%F-%H%M | sed -e 's/ //'`
109 tmpdir=/tmp/proctor$DATEFORMAT
110
111 if ! mkdir $tmpdir >/dev/null 2>/dev/null
112 then
113 rm -rf $tmpdir
114 mkdir $tmpdir
115 fi
116
117
118 linestart=0
119 if [ x$1 = x-comment ]
120 then
121 shift
122 comment="$1"
123 shift
124 fi
125
126 find_makefile()
127 {
128 local j
129
130 MF=""
131
132 if [ ! -d $1 ]
133 then
134 return 1
135 fi
136
137 for j in Makefile makefile
138 do
139 [ -f $1/$j ] && MF=$j
140 done
141
142 if [ "$NEWTEST" ]
143 then
144 for j in Makefile.newtest makefile.newtest
145 do
146 [ -f $1/$j ] && MF=$j
147 done
148 fi
149
150 [ "$MF" ] && return 0
151 return 1
152 }
153
154 one_test()
155 {
156 echo cwd: $1
157 echo cmd: $1 ARCH="$arch"
158 make -f "$MF" -C $1 ARCH="$arch" 2>$tmpdir/stderr >$tmpdir/stdout
159 result=$?
160 sed 's/^/stdout: /'<$tmpdir/stdout
161 sed 's/^/stderr: /'<$tmpdir/stderr
162 echo exit: $?
163 }
164
165 if [ "$1" ]
166 then
167 i="$1"
168 for arch in $all_archs
169 do
170 rm -f $tmpdir/$arch
171 if find_makefile $i
172 then
173 one_test $i
174 fi
175 #fi | tee -a $tmpdir/raw | ../bin/results-to-xml $linestart>>$tmpdir/$arch
176 linestart=`expr $linestart + 10000`
177 done | tee -a $tmpdir/raw | ../bin/results-to-xml $linestart>>$tmpdir/$arch
178 else
179 for arch in $all_archs
180 do
181 rm -f $tmpdir/$arch
182 for i in *
183 do
184 if find_makefile $i
185 then
186 one_test $i
187 fi
188 done | tee -a $tmpdir/raw | ../bin/results-to-xml $linestart>>$tmpdir/$arch
189 linestart=`expr $linestart + 10000`
190 done
191 fi
192
193 (cd $tmpdir; doresults $all_archs)>$tmpdir/o.xml
194 ../bin/xmlparser $tmpdir/o.xml >/dev/null
195 if [ $? = 0 ]
196 then
197 if ! proctor localhost ld import $tmpdir/o.xml
198 then
199 proctor database load failed!
200 fi
201 else
202 echo Test results not loaded: internal xml error!
203 exit 1
204 fi