Browse code

Update test for common scripts

Nat! authored on 23-07-2016 18:17:27
Showing 12 changed files
... ...
@@ -1 +1,2 @@
1 1
 http://www.mulle-kybernetik.com/repositories/mulle-configuration
2
+http://www.mulle-kybernetik.com/repositories/mulle-tests
... ...
@@ -15,3 +15,6 @@ old/
15 15
 tmp/
16 16
 *.dSYM/
17 17
 *.exe
18
+mulle-tests/
19
+/include
20
+/lib
18 21
\ No newline at end of file
... ...
@@ -13,7 +13,8 @@ endif()
13 13
 
14 14
 # using include_directories is a little bit shitty
15 15
 include_directories( src
16
-src/hash
16
+src/hashmap
17
+src/pointerarray
17 18
 )
18 19
 
19 20
 set( HEADERS
... ...
@@ -28,7 +29,24 @@ src/pointerarray/mulle_concurrent_pointerarray.c
28 29
 src/hashmap/mulle_concurrent_hashmap.c
29 30
 )
30 31
 
31
-INSTALL( TARGETS mulle_concurrent DESTINATION "lib")
32
+add_library( mulle_concurrent_standalone SHARED
33
+src/mulle_concurrent_standalone.c
34
+)
35
+
36
+add_dependencies( mulle_concurrent_standalone mulle_concurrent)
37
+
38
+TARGET_LINK_LIBRARIES( mulle_concurrent_standalone
39
+${BEGIN_ALL_LOAD}
40
+mulle_concurrent
41
+mulle_aba
42
+mulle_allocator
43
+mulle_test_allocator
44
+${END_ALL_LOAD}
45
+)
46
+
47
+
48
+
49
+INSTALL( TARGETS mulle_concurrent_standalone mulle_concurrent DESTINATION "lib")
32 50
 INSTALL( FILES ${HEADERS} DESTINATION "include/mulle_concurrent")
33 51
 
34 52
 
... ...
@@ -39,8 +39,7 @@
39 39
 		41CAEAD21C8D95BB003C2C7B /* libmulle_concurrent.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 41F14FE61B68F098002189F1 /* libmulle_concurrent.a */; };
40 40
 		41CAEAD81C8D95D4003C2C7B /* libmulle_allocator.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 41CAEAD51C8D95D4003C2C7B /* libmulle_allocator.a */; };
41 41
 		41CAEADA1C8D95ED003C2C7B /* mulle_concurrent.h in Headers */ = {isa = PBXBuildFile; fileRef = 41CAEAD91C8D95ED003C2C7B /* mulle_concurrent.h */; settings = {ATTRIBUTES = (Public, ); }; };
42
-		41CAEADC1C8D9601003C2C7B /* mulle_standalone_concurrent.h in Headers */ = {isa = PBXBuildFile; fileRef = 41CAEADB1C8D9601003C2C7B /* mulle_standalone_concurrent.h */; settings = {ATTRIBUTES = (Public, ); }; };
43
-		41CAEADF1C8D98F0003C2C7B /* mulle_standalone_concurrent.c in Sources */ = {isa = PBXBuildFile; fileRef = 41CAEADE1C8D98F0003C2C7B /* mulle_standalone_concurrent.c */; };
42
+		41CAEADF1C8D98F0003C2C7B /* mulle_concurrent_standalone.c in Sources */ = {isa = PBXBuildFile; fileRef = 41CAEADE1C8D98F0003C2C7B /* mulle_concurrent_standalone.c */; };
44 43
 		41CAEAE11C8D9D98003C2C7B /* mulle_concurrent_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 41CAEAE01C8D9D98003C2C7B /* mulle_concurrent_types.h */; settings = {ATTRIBUTES = (Public, ); }; };
45 44
 		41CAEAEF1C8DA00F003C2C7B /* hashmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 41CAEAEE1C8DA00F003C2C7B /* hashmap.c */; };
46 45
 		41CAEAF21C8DA09C003C2C7B /* libmulle_standalone_concurrent.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 41CAEAC41C8D9599003C2C7B /* libmulle_standalone_concurrent.dylib */; };
... ...
@@ -119,9 +118,8 @@
119 118
 		41CAEAD41C8D95D4003C2C7B /* libmulle_thread.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmulle_thread.a; path = dependencies/lib/Debug/libmulle_thread.a; sourceTree = "<group>"; };
120 119
 		41CAEAD51C8D95D4003C2C7B /* libmulle_allocator.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmulle_allocator.a; path = dependencies/lib/Debug/libmulle_allocator.a; sourceTree = "<group>"; };
121 120
 		41CAEAD91C8D95ED003C2C7B /* mulle_concurrent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mulle_concurrent.h; sourceTree = "<group>"; };
122
-		41CAEADB1C8D9601003C2C7B /* mulle_standalone_concurrent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mulle_standalone_concurrent.h; sourceTree = "<group>"; };
123 121
 		41CAEADD1C8D982D003C2C7B /* DynamicLibraryOSX.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DynamicLibraryOSX.xcconfig; sourceTree = "<group>"; };
124
-		41CAEADE1C8D98F0003C2C7B /* mulle_standalone_concurrent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mulle_standalone_concurrent.c; sourceTree = "<group>"; };
122
+		41CAEADE1C8D98F0003C2C7B /* mulle_concurrent_standalone.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mulle_concurrent_standalone.c; sourceTree = "<group>"; };
125 123
 		41CAEAE01C8D9D98003C2C7B /* mulle_concurrent_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mulle_concurrent_types.h; sourceTree = "<group>"; };
126 124
 		41CAEAE71C8D9FF4003C2C7B /* test-hashmap */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "test-hashmap"; sourceTree = BUILT_PRODUCTS_DIR; };
127 125
 		41CAEAEE1C8DA00F003C2C7B /* hashmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hashmap.c; path = tests/hashmap/hashmap.c; sourceTree = SOURCE_ROOT; };
... ...
@@ -174,9 +172,9 @@
174 172
 		414785231ABAF290002DBAE4 = {
175 173
 			isa = PBXGroup;
176 174
 			children = (
175
+				411A28C11BCD446E00D39FF7 /* CMakeLists.txt */,
177 176
 				41CAEB091C8DB97F003C2C7B /* README.md */,
178 177
 				41D04AB71C8DD69000CC8F11 /* RELEASENOTES.md */,
179
-				411A28C11BCD446E00D39FF7 /* CMakeLists.txt */,
180 178
 				417C02631BD8404E005A3751 /* mulle-configuration */,
181 179
 				4147852E1ABAF290002DBAE4 /* src */,
182 180
 				41CAEAE21C8D9F23003C2C7B /* Libraries */,
... ...
@@ -202,8 +200,7 @@
202 200
 			children = (
203 201
 				41CAEAD91C8D95ED003C2C7B /* mulle_concurrent.h */,
204 202
 				41CAEAE01C8D9D98003C2C7B /* mulle_concurrent_types.h */,
205
-				41CAEADB1C8D9601003C2C7B /* mulle_standalone_concurrent.h */,
206
-				41CAEADE1C8D98F0003C2C7B /* mulle_standalone_concurrent.c */,
203
+				41CAEADE1C8D98F0003C2C7B /* mulle_concurrent_standalone.c */,
207 204
 				41D8BA7C1C8D92DE00186ECE /* hashmap */,
208 205
 				41D8BA7F1C8D92DE00186ECE /* pointerarray */,
209 206
 			);
... ...
@@ -287,7 +284,6 @@
287 284
 			isa = PBXHeadersBuildPhase;
288 285
 			buildActionMask = 2147483647;
289 286
 			files = (
290
-				41CAEADC1C8D9601003C2C7B /* mulle_standalone_concurrent.h in Headers */,
291 287
 			);
292 288
 			runOnlyForDeploymentPostprocessing = 0;
293 289
 		};
... ...
@@ -436,7 +432,7 @@
436 432
 			isa = PBXSourcesBuildPhase;
437 433
 			buildActionMask = 2147483647;
438 434
 			files = (
439
-				41CAEADF1C8D98F0003C2C7B /* mulle_standalone_concurrent.c in Sources */,
435
+				41CAEADF1C8D98F0003C2C7B /* mulle_concurrent_standalone.c in Sources */,
440 436
 			);
441 437
 			runOnlyForDeploymentPostprocessing = 0;
442 438
 		};
443 439
similarity index 94%
444 440
rename from src/mulle_standalone_concurrent.c
445 441
rename to src/mulle_concurrent_standalone.c
... ...
@@ -31,8 +31,8 @@
31 31
 //  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 32
 //  POSSIBILITY OF SUCH DAMAGE.
33 33
 //
34
-#include "mulle_standalone_concurrent.h"
34
+#include "mulle_concurrent.h"
35 35
 #include <stdint.h>
36 36
 
37 37
 
38
-uint32_t  mulle_standalone_concurrent_version = MULLE_CONCURRENT_VERSION;
38
+uint32_t  mulle_concurrent_standalone_version = MULLE_CONCURRENT_VERSION;
39 39
deleted file mode 100644
... ...
@@ -1,39 +0,0 @@
1
-//
2
-//  mulle_standalone_concurrent.h
3
-//  mulle-concurrent
4
-//
5
-//  Created by Nat! on 07.03.16.
6
-//  Copyright © 2016 Mulle kybernetiK. All rights reserved.
7
-//
8
-//  Redistribution and use in source and binary forms, with or without
9
-//  modification, are permitted provided that the following conditions are met:
10
-//
11
-//  Redistributions of source code must retain the above copyright notice, this
12
-//  list of conditions and the following disclaimer.
13
-//
14
-//  Redistributions in binary form must reproduce the above copyright notice,
15
-//  this list of conditions and the following disclaimer in the documentation
16
-//  and/or other materials provided with the distribution.
17
-//
18
-//  Neither the name of Mulle kybernetiK nor the names of its contributors
19
-//  may be used to endorse or promote products derived from this software
20
-//  without specific prior written permission.
21
-//
22
-//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
-//  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
-//  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
-//  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26
-//  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
-//  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
-//  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
-//  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
-//  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
-//  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
-//  POSSIBILITY OF SUCH DAMAGE.
33
-//
34
-#ifndef mulle_standalone_concurrent_h__
35
-#define mulle_standalone_concurrent_h__
36
-
37
-#include <mulle_concurrent/mulle_concurrent.h>
38
-
39
-#endif /* mulle_standalone_concurrent_h */
40 0
new file mode 120000
... ...
@@ -0,0 +1 @@
1
+../mulle-tests/build-for-test.sh
0 2
\ No newline at end of file
... ...
@@ -31,7 +31,7 @@
31 31
 //  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 32
 //  POSSIBILITY OF SUCH DAMAGE.
33 33
 //
34
-#include <mulle_standalone_concurrent/mulle_standalone_concurrent.h>
34
+#include <mulle_concurrent/mulle_concurrent.h>
35 35
 
36 36
 #include <mulle_test_allocator/mulle_test_allocator.h>
37 37
 #include <mulle_aba/mulle_aba.h>
... ...
@@ -207,7 +207,7 @@ static void  single_threaded_test( void)
207 207
    mulle_aba_init( &mulle_test_allocator);
208 208
 
209 209
    mulle_allocator_set_aba( &mulle_test_allocator,  mulle_aba_get_global(), (void *) _mulle_aba_free);
210
-   
210
+
211 211
    mulle_aba_register();
212 212
 
213 213
    _mulle_concurrent_hashmap_init( &map, 0, &mulle_test_allocator);
... ...
@@ -257,9 +257,9 @@ static void  single_threaded_test( void)
257 257
    _mulle_concurrent_hashmap_done( &map);
258 258
 
259 259
    mulle_aba_unregister();
260
-   
260
+
261 261
    mulle_allocator_set_aba( &mulle_test_allocator, NULL, NULL);
262
-   
262
+
263 263
    mulle_aba_done();
264 264
 }
265 265
 
... ...
@@ -1,4 +1,4 @@
1
-#include <mulle_standalone_concurrent/mulle_standalone_concurrent.h>
1
+#include <mulle_concurrent/mulle_concurrent.h>
2 2
 
3 3
 
4 4
 static void   test( void)
... ...
@@ -31,8 +31,7 @@
31 31
 //  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 32
 //  POSSIBILITY OF SUCH DAMAGE.
33 33
 //
34
-#include <mulle_standalone_concurrent/mulle_standalone_concurrent.h>
35
-
34
+#include <mulle_concurrent/mulle_concurrent.h>
36 35
 #include <mulle_test_allocator/mulle_test_allocator.h>
37 36
 #include <mulle_aba/mulle_aba.h>
38 37
 #include <assert.h>
... ...
@@ -148,7 +147,7 @@ static void  multi_threaded_test( unsigned int n_threads)
148 147
 
149 148
    mulle_aba_init( &mulle_test_allocator);
150 149
    mulle_allocator_set_aba( &mulle_test_allocator, mulle_aba_get_global(), (void *) _mulle_aba_free);
151
-   
150
+
152 151
    _mulle_concurrent_pointerarray_init( &map, 0, &mulle_test_allocator);
153 152
 
154 153
    {
... ...
@@ -183,9 +182,9 @@ static void  single_threaded_test( void)
183 182
    void                                             *value;
184 183
 
185 184
    mulle_aba_init( &mulle_test_allocator);
186
-   
185
+
187 186
    mulle_allocator_set_aba( &mulle_test_allocator,  mulle_aba_get_global(), (void *) _mulle_aba_free);
188
-   
187
+
189 188
    mulle_aba_register();
190 189
 
191 190
    _mulle_concurrent_pointerarray_init( &map, 0, &mulle_test_allocator);
... ...
@@ -218,7 +217,7 @@ static void  single_threaded_test( void)
218 217
    _mulle_concurrent_pointerarray_done( &map);
219 218
 
220 219
    mulle_aba_unregister();
221
-   
220
+
222 221
    mulle_allocator_set_aba( &mulle_test_allocator, NULL, NULL);
223 222
 
224 223
    mulle_aba_done();
... ...
@@ -1,4 +1,4 @@
1
-#include <mulle_standalone_concurrent/mulle_standalone_concurrent.h>
1
+#include <mulle_concurrent/mulle_concurrent.h>
2 2
 
3 3
 
4 4
 static void   test( void)
... ...
@@ -7,589 +7,8 @@
7 7
 #  Copyright (c) 2013 Mulle kybernetiK. All rights reserved.
8 8
 #  (was run-mulle-scion-test)
9 9
 
10
-set -m
11 10
 
11
+LIBRARY_SHORTNAME="mulle_concurrent"
12 12
 
13
-# check if running a single test or all
14
-
15
-executable=`basename "$0"`
16
-executable=`basename "$executable" .sh`
17
-
18
-if [ "`basename "$executable"`" = "run-all-tests" ]
19
-then
20
-   TEST=""
21
-   VERBOSE=yes
22
-   if [ "$1" = "-q" ]
23
-   then
24
-      VERBOSE=no
25
-      shift
26
-   fi
27
-else
28
-   TEST="$1"
29
-   [ -z $# ] || shift
30
-fi
31
-
32
-
33
-if [ -z "${CFLAGS}" ]
34
-then
35
-   CFLAGS="-w -g -O0"
36
-fi
37
-
38
-#
39
-# this is system wide, not so great
40
-# and also not trapped...
41
-#
42
-suppress_crashdumping()
43
-{
44
-   local restore
45
-
46
-   case `uname` in
47
-      Darwin)
48
-         restore="`defaults read com.apple.CrashReporter DialogType 2> /dev/null`"
49
-         defaults write com.apple.CrashReporter DialogType none
50
-         ;;
51
-      Linux)
52
-         ;;
53
-   esac
54
-
55
-   echo "${restore}"
56
-}
57
-
58
-
59
-restore_crashdumping()
60
-{
61
-   local restore
62
-
63
-   restore="$1"
64
-
65
-   case `uname` in
66
-      Darwin)
67
-         if [ -z "${restore}" ]
68
-         then
69
-            defaults delete com.apple.CrashReporter DialogType
70
-         else
71
-            defaults write com.apple.CrashReporter DialogType "${restore}"
72
-         fi
73
-         ;;
74
-      Linux)
75
-         ;;
76
-   esac
77
-}
78
-
79
-
80
-trace_ignore()
81
-{
82
-   restore_crashdumping "$1"
83
-   return 0
84
-}
85
-
86
-
87
-RESTORE_CRASHDUMP=`suppress_crashdumping`
88
-trap 'trace_ignore "${RESTORE_CRASHDUMP}"' 0 5 6
89
-
90
-
91
-#
92
-# find runtime and headers
93
-#
94
-MULLE_CONCURRENT_DEPENDENCIES_INCLUDE=/usr/local/bin
95
-
96
-lib="`ls -1 ../lib/libmulle_standalone_concurrent.dylib 2> /dev/null | tail -1`"
97
-MULLE_CONCURRENT_DEPENDENCIES_INCLUDE="../include"
98
-
99
-if [ ! -x "${lib}" ]
100
-then
101
-   lib="`ls -1 "../build/Products/Debug/libmulle_standalone_concurrent.dylib" | tail -1 2> /dev/null`"
102
-   MULLE_CONCURRENT_DEPENDENCIES_INCLUDE="../dependencies/include"
103
-fi
104
-
105
-MULLE_CONCURRENT="${1:-${lib}}"
106
-[ -z $# ] || shift
107
-
108
-if [ -z "${MULLE_CONCURRENT}" ]
109
-then
110
-   echo "libmulle_standalone_concurrent.dylib can not be found" >&2
111
-   exit 1
112
-fi
113
-
114
-MULLE_CONCURRENT_INCLUDE="`dirname "${MULLE_CONCURRENT}"`"
115
-MULLE_CONCURRENT_INCLUDE="`dirname "${MULLE_CONCURRENT}"`"
116
-
117
-if [ -d "${MULLE_CONCURRENT_INCLUDE}/usr/local/include" ]
118
-then
119
-   MULLE_CONCURRENT_INCLUDE="${MULLE_CONCURRENT_INCLUDE}/usr/local/include"
120
-else
121
-   MULLE_CONCURRENT_INCLUDE="${MULLE_CONCURRENT_INCLUDE}/include"
122
-fi
123
-
124
-
125
-DIR=${1:-`pwd`}
126
-shift
127
-
128
-HAVE_WARNED="no"
129
-RUNS=0
130
-
131
-search_plist()
132
-{
133
-   local plist
134
-   local root
135
-
136
-   dir=`dirname "$1"`
137
-   plist=`basename "$1"`
138
-   root="$2"
139
-
140
-   while :
141
-   do
142
-      if [ -f "$dir"/"$plist" ]
143
-      then
144
-         echo "$dir/$plist"
145
-         break
146
-      fi
147
-
148
-      if [ "$dir" = "$root" ]
149
-      then
150
-         break
151
-      fi
152
-
153
-      next=`dirname "$dir"`
154
-      if [ "$next" = "$dir" ]
155
-      then
156
-         break
157
-      fi
158
-      dir="$next"
159
-   done
160
-}
161
-
162
-
163
-relpath()
164
-{
165
-   python -c "import os.path; print os.path.relpath('$1', '$2')"
166
-}
167
-
168
-
169
-
170
-absolute_path_if_relative()
171
-{
172
-   case "$1" in
173
-      .*)  echo "`pwd`/$1"
174
-      ;;
175
-
176
-      *) echo "$1"
177
-      ;;
178
-   esac
179
-}
180
-
181
-
182
-maybe_show_diagnostics()
183
-{
184
-   local errput
185
-
186
-   errput="$1"
187
-
188
-   local contents
189
-   contents="`head -2 "$errput"`" 2> /dev/null
190
-   if [ "${contents}" != "" ]
191
-   then
192
-      echo "DIAGNOSTICS:" >&2
193
-      cat  "$errput"
194
-   fi
195
-}
196
-
197
-
198
-maybe_show_output()
199
-{
200
-   local output
201
-
202
-   output="$1"
203
-
204
-   local contents
205
-   contents="`head -2 "$output"`" 2> /dev/null
206
-   if [ "${contents}" != "" ]
207
-   then
208
-      echo "OUTPUT:" >&2
209
-      cat  "$output"
210
-   fi
211
-}
212
-
213
-
214
-search_for_strings()
215
-{
216
-   local errput
217
-   local strings
218
-   local banner
219
-
220
-   banner="$1"
221
-   errput="$2"
222
-   strings="$3"
223
-
224
-   local fail
225
-   local expect
226
-   local match
227
-
228
-   fail=0
229
-   while read expect
230
-   do
231
-      if [ ! -z "$expect" ]
232
-      then
233
-         match=`grep "$expect" "$errput"`
234
-         if [ "$match" = "" ]
235
-         then
236
-            if [ $fail -eq 0 ]
237
-            then
238
-               echo "${banner}" >&2
239
-               fail=1
240
-            fi
241
-            echo "   $expect" >&2
242
-         fi
243
-      fi
244
-   done < "$strings"
245
-
246
-   [ $fail -eq 1 ]
247
-}
248
-
249
-
250
-fail_test()
251
-{
252
-   local m_source
253
-   local a_out
254
-   local stdin
255
-
256
-   m_source="$1"
257
-   a_out="$2"
258
-   stdin="$3"
259
-
260
-   echo "DEBUG: " >&2
261
-   echo "DYLD_FALLBACK_LIBRARY_PATH=\"${DYLD_FALLBACK_LIBRARY_PATH}\" \
262
-LD_LIBRARY_PATH=\"${LD_LIBRARY_PATH}\" lldb ${a_out}" >&2
263
-   if [ "${stdin}" != "/dev/null" ]
264
-   then
265
-      echo "run < ${stdin}" >&2
266
-   fi
267
-   exit 1
268
-}
269
-
270
-
271
-
272
-run()
273
-{
274
-   local m_source
275
-   local makefile
276
-   local root
277
-   local stdin
278
-   local stdout
279
-   local stderr
280
-   local ccdiag
281
-
282
-   m_source="$1"
283
-   makefile="$2"
284
-   root="$3"
285
-   stdin="$4"
286
-   stdout="$5"
287
-   stderr="$6"
288
-   ccdiag="$7"
289
-
290
-   local output
291
-   local errput
292
-   local random
293
-   local fail
294
-   local match
295
-
296
-   random=`mktemp -t "mulle-objc-runtime"`
297
-   a_out="$random.exe"
298
-   output="$random.stdout"
299
-   errput="$random.stderr"
300
-   errors=`basename $m_source .c`.errors
301
-
302
-   local owd
303
-
304
-   owd=`pwd`
305
-   pretty_source=`relpath "$owd"/"$m_source" "$root"`
306
-   if [ "$VERBOSE" = "yes" ]
307
-   then
308
-      echo "$pretty_source" >&2
309
-   fi
310
-
311
-   RUNS=`expr "$RUNS" + 1`
312
-
313
-   # plz2shutthefuckup bash
314
-   set +m
315
-   set +b
316
-   set +v
317
-   # denied, will always print TRACE/BPT
318
-
319
-   local  TMP_CFLAGS
320
-
321
-   TMP_CFLAGS="${CFLAGS} \
322
--w \
323
--I${MULLE_CONCURRENT_INCLUDE} \
324
--I${MULLE_CONCURRENT_DEPENDENCIES_INCLUDE}"
325
-
326
-
327
-   if [ -z "${makefile}" ]
328
-   then
329
-      cc ${TMP_CFLAGS} -o "${a_out}" "${m_source}" "${MULLE_CONCURRENT}"
330
- > "$errput" 2>&1
331
-   else
332
-      CFLAGS="${TMP_CFLAGS}" LDFLAGS="${MULLE_CONCURRENT}" OUTPUT="${a_out}" make
333
-   fi
334
-
335
-   if [ $? -ne 0 ]
336
-   then
337
-      if [ "$ccdiag" = "-" ]
338
-      then
339
-         echo "COMPILER ERRORS: \"$pretty_source\"" >&2
340
-         maybe_show_diagnostics "$errput"
341
-         fail_test "${m_source}" "${a_out}" "${stdin}"
342
-      else
343
-         search_for_strings "COMPILER FAILED TO PRODUCE ERRORS: \"$pretty_source\" ($errput)" \
344
-                            "$errput" "$ccdiag"
345
-         if [ $? -ne 0 ]
346
-         then
347
-            return 0
348
-         fi
349
-         maybe_show_diagnostics "$errput" >&2
350
-         fail_test "${m_source}" "${a_out}" "${stdin}"
351
-      fi
352
-   fi
353
-
354
-   "${a_out}" < "$stdin" > "$output" 2> "$errput"
355
-
356
-   if [ $? -ne 0 ]
357
-   then
358
-      if [ ! -f "$errors" ]
359
-      then
360
-         echo "TEST CRASHED: \"$pretty_source\" (${a_out}, ${errput})" >&2
361
-         maybe_show_diagnostics "$errput" >&2
362
-         fail_test "${m_source}" "${a_out}" "${stdin}"
363
-      else
364
-         search_for_strings "TEST FAILED TO PRODUCE ERRORS: \"$pretty_source\" (${a_out}, $errput)" \
365
-                            "$errput" "$errors"
366
-         if [ $? -ne 0 ]
367
-         then
368
-            return 0
369
-         fi
370
-         maybe_show_diagnostics "$errput" >&2
371
-         fail_test "${m_source}" "${a_out}" "${stdin}"
372
-      fi
373
-   else
374
-      if [ -f "$errors" ]
375
-      then
376
-         echo "TEST FAILED TO CRASH: \"$pretty_source\" (${a_out})" >&2
377
-         maybe_show_diagnostics "$errput" >&2
378
-         fail_test "${m_source}" "${a_out}" "${stdin}"
379
-      fi
380
-   fi
381
-
382
-   if [ "$stdout" != "-" ]
383
-   then
384
-      result=`diff -q "$stdout" "$output"`
385
-      if [ "$result" != "" ]
386
-      then
387
-         white=`diff -q -w "$stdout" "$output"`
388
-         if [ "$white" != "" ]
389
-         then
390
-            echo "FAILED: \"$pretty_source\" produced unexpected output (${a_out})" >&2
391
-            echo "DIFF: ($stdout vs. $output)" >&2
392
-            diff -y "$stdout" "$output" >&2
393
-         else
394
-            echo "FAILED: \"$pretty_source\" produced different whitespace output (${a_out})" >&2
395
-            echo "DIFF: ($stdout vs. $output)" >&2
396
-            od -a "$output" > "$output.actual.hex"
397
-            od -a "$stdout" > "$output.expect.hex"
398
-            diff -y "$output.expect.hex" "$output.actual.hex" >&2
399
-         fi
400
-
401
-         maybe_show_diagnostics "$errput" >&2
402
-         maybe_show_output "$output"
403
-
404
-         fail_test "${m_source}" "${a_out}" "${stdin}"
405
-      fi
406
-   else
407
-      contents="`head -2 "$output"`" 2> /dev/null
408
-      if [ "${contents}" != "" ]
409
-      then
410
-         echo "WARNING: \"$pretty_source\" produced unexpected output (${a_out}, $output)" >&2
411
-
412
-         maybe_show_diagnostics "$errput" >&2
413
-         maybe_show_output "$output"
414
-
415
-         fail_test "${m_source}" "${a_out}" "${stdin}"
416
-      fi
417
-   fi
418
-
419
-   if [ "$stderr" != "-" ]
420
-   then
421
-      result=`diff "$stderr" "$errput"`
422
-      if [ "$result" != "" ]
423
-      then
424
-         echo "WARNING: \"$pretty_source\" produced unexpected diagnostics (${a_out}, $errput)" >&2
425
-         echo "" >&2
426
-         diff "$stderr" "$errput" >&2
427
-
428
-         maybe_show_diagnostics "$errput"
429
-         fail_test "${m_source}" "${a_out}" "${stdin}"
430
-      fi
431
-   fi
432
-}
433
-
434
-
435
-run_test()
436
-{
437
-   local m_source
438
-   local root
439
-   local makefile
440
-
441
-   m_source="$1.c"
442
-   root="$2"
443
-   makefile="$3"
444
-
445
-   local stdin
446
-   local stdout
447
-   local stderr
448
-   local plist
449
-
450
-   stdin="$1.stdin"
451
-   if [ ! -f "$stdin" ]
452
-   then
453
-      stdin="provide/$1.stdin"
454
-   fi
455
-   if [ ! -f "$stdin" ]
456
-   then
457
-      stdin="default.stdin"
458
-   fi
459
-   if [ ! -f "$stdin" ]
460
-   then
461
-      stdin="/dev/null"
462
-   fi
463
-
464
-   stdout="$1.stdout"
465
-   if [ ! -f "$stdout" ]
466
-   then
467
-      stdout="expect/$1.stdout"
468
-   fi
469
-   if [ ! -f "$stdout" ]
470
-   then
471
-      stdout="default.stdout"
472
-   fi
473
-   if [ ! -f "$stdout" ]
474
-   then
475
-      stdout="-"
476
-   fi
477
-
478
-   stderr="$1.stderr"
479
-   if [ ! -f "$stderr" ]
480
-   then
481
-      stderr="expect/$1.stderr"
482
-   fi
483
-   if [ ! -f "$stderr" ]
484
-   then
485
-      stderr="default.stderr"
486
-   fi
487
-   if [ ! -f "$stderr" ]
488
-   then
489
-      stderr="-"
490
-   fi
491
-
492
-   ccdiag="$1.ccdiag"
493
-   if [ ! -f "$ccdiag" ]
494
-   then
495
-      ccdiag="expect/$1.ccdiag"
496
-   fi
497
-   if [ ! -f "$ccdiag" ]
498
-   then
499
-      ccdiag="default.ccdiag"
500
-   fi
501
-   if [ ! -f "$ccdiag" ]
502
-   then
503
-      ccdiag="-"
504
-   fi
505
-
506
-   run "$m_source" "$makefile" "$root" "$stdin" "$stdout" "$stderr" "$ccdiag"
507
-}
508
-
509
-
510
-scan_current_directory()
511
-{
512
-   local root
513
-
514
-   root="$1"
515
-
516
-   local i
517
-   local filename
518
-   local dir
519
-
520
-   if [ -f Makefile ]
521
-   then
522
-      run_test "$1" "$root" "Makefile"
523
-      return 0
524
-   fi
525
-
526
-   for i in [^_]*
527
-   do
528
-      if [ -d "$i" ]
529
-      then
530
-         dir=`pwd`
531
-         cd "$i"
532
-         scan_current_directory "$root"
533
-         cd "$dir"
534
-      else
535
-         filename=`basename "$i" .c`
536
-         if [ "$filename" != "$i" ]
537
-         then
538
-            run_test "$filename" "$root"
539
-         fi
540
-      fi
541
-   done
542
-}
543
-
544
-
545
-
546
-MULLE_CONCURRENT="`absolute_path_if_relative "$MULLE_CONCURRENT"`"
547
-MULLE_CONCURRENT_INCLUDE="`absolute_path_if_relative "$MULLE_CONCURRENT_INCLUDE"`"
548
-MULLE_CONCURRENT_DEPENDENCIES_INCLUDE="`absolute_path_if_relative "$MULLE_CONCURRENT_DEPENDENCIES_INCLUDE"`"
549
-
550
-# OS X
551
-DYLD_FALLBACK_LIBRARY_PATH="`dirname "${MULLE_CONCURRENT}"`" ; export DYLD_FALLBACK_LIBRARY_PATH
552
-# Linux
553
-LD_LIBRARY_PATH="`dirname "${MULLE_CONCURRENT}"`" ; export LD_LIBRARY_PATH
554
-
555
-
556
-if [ "$TEST" = "" ]
557
-then
558
-   cd "${DIR}"
559
-   scan_current_directory "`pwd -P`"
560
-
561
-   if [ "$RUNS" -ne 0 ]
562
-   then
563
-      echo "All tests ($RUNS) passed successfully"
564
-   else
565
-      echo "no tests found" >&2
566
-      exit 1
567
-   fi
568
-else
569
-    dirname=`dirname "$TEST"`
570
-    if [ "$dirname" = "" ]
571
-    then
572
-       dirname="."
573
-    fi
574
-    file=`basename "$TEST"`
575
-    filename=`basename "$file" .c`
576
-
577
-    if [ "$file" = "$filename" ]
578
-    then
579
-       echo "error: source file must have .c extension" >&2
580
-       exit 1
581
-    fi
582
-
583
-    if [ ! -f "$TEST" ]
584
-    then
585
-       echo "error: source file not found" >&2
586
-       exit 1
587
-    fi
588
-
589
-    old="`pwd -P`"
590
-    cd "${dirname}" || exit 1
591
-    run_test "$filename" "${old}"
592
-    rval=$?
593
-    cd "${old}" || exit 1
594
-    exit $rval
595
-fi
13
+. "../mulle-tests/run-test-c-common.sh"
14
+. "../mulle-tests/run-test-common.sh"