3 objc\[\d+\]: class `DoesNotExist\' not linked into application
16 #include <mach-o/ldsyms.h>
17 #include <objc/objc-runtime.h>
19 #if __has_feature(objc_arc)
23 testwarn("rdar://11368528 confused by Foundation");
24 fprintf(stderr, "confused by Foundation\n");
30 @interface Sub : TestRoot @end
31 @implementation Sub @end
37 unsigned int count, count0, count2;
46 // This shouldn't touch any classes.
47 dladdr(&_mh_execute_header, &info);
48 names = objc_copyClassNamesForImage(info.dli_fname, &count);
50 testassert(count == 2);
51 testassert(names[count] == NULL);
54 for (i = 0; i < count; i++) {
55 if (0 == strcmp(names[i], "TestRoot")) foundTestRoot++;
56 if (0 == strcmp(names[i], "Sub")) foundSub++;
58 testassert(foundTestRoot == 1);
59 testassert(foundSub == 1);
62 // class Sub hasn't been touched - make sure it's in the class list too
63 count0 = objc_getClassList(NULL, 0);
64 testassert(count0 >= 2 && count0 < 100);
66 list[count0-1] = NULL;
67 count = objc_getClassList(list, count0-1);
68 testassert(list[count0-1] == NULL);
69 testassert(count == count0);
71 count = objc_getClassList(list, count0);
72 testassert(count == count0);
75 for (i = 0; i < count; i++) {
76 if (0 == strcmp(class_getName(list[i]), "TestRoot")) foundTestRoot++;
77 if (0 == strcmp(class_getName(list[i]), "Sub")) foundSub++;
78 // list should be non-meta classes only
79 testassert(!class_isMetaClass(list[i]));
81 testassert(foundTestRoot == 1);
82 testassert(foundSub == 1);
84 // fixme check class handler
85 testassert(objc_getClass("TestRoot") == [TestRoot class]);
86 testassert(objc_getClass("DoesNotExist") == nil);
87 testassert(objc_getClass(NULL) == nil);
89 testassert(objc_getMetaClass("TestRoot") == object_getClass([TestRoot class]));
90 testassert(objc_getMetaClass("DoesNotExist") == nil);
91 testassert(objc_getMetaClass(NULL) == nil);
93 // fixme check class no handler
94 testassert(objc_lookUpClass("TestRoot") == [TestRoot class]);
95 testassert(objc_lookUpClass("DoesNotExist") == nil);
96 testassert(objc_lookUpClass(NULL) == nil);
98 list2 = objc_copyClassList(&count2);
99 testassert(count2 == count);
101 testassert(malloc_size(list2) >= (1+count2) * sizeof(Class));
102 for (i = 0; i < count; i++) {
103 testassert(list[i] == list2[i]);
105 testassert(list2[count] == NULL);
107 free(objc_copyClassList(NULL));