]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/weak-coalesce.dtest/base.c
dyld-851.27.tar.gz
[apple/dyld.git] / testing / test-cases / weak-coalesce.dtest / base.c
1 #include <stdio.h>
2 #include <stdbool.h>
3
4 #include "test_support.h"
5 #include "base.h"
6
7 static bool wasProblem = false;
8 static const char* coal1Where = NULL;
9 static int* coal1Addr = NULL;
10 static int checkInCountCoal1 = 0;
11
12 void baseVerifyCoal1(const char* where, int* addr)
13 {
14 LOG("baseVerifyCoal1(%s, %p)", where, addr);
15 ++checkInCountCoal1;
16 if ( coal1Where == NULL ) {
17 coal1Where = where;
18 coal1Addr = addr;
19 }
20 else {
21 if ( addr != coal1Addr ) {
22 LOG("coal1 resolved to different locations. %p in %s and %p in %s",
23 coal1Addr, coal1Where, addr, where);
24 wasProblem = true;
25 }
26 }
27 }
28
29
30 static const char* coal2Where = NULL;
31 static int* coal2Addr = NULL;
32 static int checkInCountCoal2 = 0;
33
34 void baseVerifyCoal2(const char* where, int* addr)
35 {
36 LOG("baseVerifyCoal2(%s, %p)", where, addr);
37 ++checkInCountCoal2;
38 if ( coal2Where == NULL ) {
39 coal2Where = where;
40 coal2Addr = addr;
41 }
42 else {
43 if ( addr != coal2Addr ) {
44 LOG("coal2 resolved to different locations. %p in %s and %p in %s",
45 coal2Addr, coal2Where, addr, where);
46 wasProblem = true;
47 }
48 }
49 }
50
51
52
53 void baseCheck()
54 {
55 if ( wasProblem )
56 FAIL("was problem");
57 else if ( checkInCountCoal1 != 4 )
58 FAIL("checkInCountCoal1 != 4");
59 else if ( checkInCountCoal2 != 4 )
60 FAIL("checkInCountCoal2 != 2");
61 else
62 PASS("Success");
63 }
64