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