]>
Commit | Line | Data |
---|---|---|
0a8dc3df A |
1 | ## |
2 | # Copyright (c) 2010 Apple Inc. All rights reserved. | |
3 | # | |
4 | # @APPLE_LICENSE_HEADER_START@ | |
5 | # | |
6 | # This file contains Original Code and/or Modifications of Original Code | |
7 | # as defined in and that are subject to the Apple Public Source License | |
8 | # Version 2.0 (the 'License'). You may not use this file except in | |
9 | # compliance with the License. Please obtain a copy of the License at | |
10 | # http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | # file. | |
12 | # | |
13 | # The Original Code and all software distributed under the License are | |
14 | # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | # Please see the License for the specific language governing rights and | |
19 | # limitations under the License. | |
20 | # | |
21 | # @APPLE_LICENSE_HEADER_END@ | |
22 | ## | |
23 | TESTROOT = ../.. | |
24 | include ${TESTROOT}/include/common.makefile | |
25 | SHELL = bash | |
26 | ||
27 | # | |
28 | # Verify handling of object files with mismatched category class properties. | |
29 | # | |
30 | ||
31 | LD_R = ${LD} -arch ${ARCH} -r | |
32 | ||
33 | # check output of objcimageinfo | |
34 | FAIL_IF_OLD = grep -v has-category-class-properties | ${FAIL_IF_STDIN} | |
35 | FAIL_IF_NEW = grep has-category-class-properties | ${FAIL_IF_STDIN} | |
36 | REALLY_FAIL_IF_NEW = grep has-category-class-properties | ${FAIL_IF_STDIN} | |
37 | ||
38 | # check diagnostics from ld | |
39 | FAIL_IF_DIAGNOSTICS = ${FAIL_IF_STDIN} | |
40 | FAIL_IF_NO_DIAGNOSTICS = egrep 'warning.*category metadata' | ${FAIL_IF_EMPTY} | |
41 | ||
42 | # Hack: Old ABI doesn't need the has-category-class-properties bit. | |
43 | # There should instead be no diagnostics and no "OLD" output anywhere. | |
44 | ifeq (${ARCH},i386) | |
45 | FAIL_IF_NEW = ${FAIL_IF_OLD} | |
46 | FAIL_IF_NO_DIAGNOSTICS = ${FAIL_IF_DIAGNOSTICS} | |
47 | # REALLY_FAIL_IF_NEW is unchanged to sanity-check objcimageinfo itself. | |
48 | endif | |
49 | ||
50 | all: | |
51 | # Generate files with has-category-class-properties bit ("NEW"). | |
52 | ${CC} ${CCFLAGS} -c class.m -o class.o | |
53 | ${CC} ${CCFLAGS} -c -DCATEGORY=1 -DCLASS_PROPERTY=1 cat.m -o cat-with-class-prop.o | |
54 | ${CC} ${CCFLAGS} -c -DCATEGORY=1 -DCLASS_PROPERTY=0 cat.m -o cat-without-class-prop.o | |
55 | ${CC} ${CCFLAGS} -c -DCATEGORY=0 -DCLASS_PROPERTY=0 cat.m -o nocat.o | |
56 | ${CC} ${CCFLAGS} -c -DCATEGORY=0 -DCLASS_PROPERTY=0 -x c cat.m -o noobjc.o | |
57 | ${OBJCIMAGEINFO} class.o cat-with-class-prop.o cat-without-class-prop.o nocat.o | ${FAIL_IF_OLD} | |
58 | # nocat.o must have objc_image_info; noobjc.o must not | |
59 | size -m -l nocat.o | egrep '(__image_info|__objc_imageinfo)' | ${FAIL_IF_EMPTY} | |
60 | size -m -l noobjc.o | egrep '(__image_info|__objc_imageinfo)' | ${FAIL_IF_STDIN} | |
61 | ||
62 | # Generate files without has-category-class-properties bit ("OLD"). | |
63 | cp -f cat-without-class-prop.o old-cat.o | |
64 | cp -f nocat.o old-nocat.o | |
65 | cp -f class.o old-class.o | |
66 | ${OBJCIMAGEINFO} -has-category-class-properties old-cat.o old-class.o old-nocat.o | ${REALLY_FAIL_IF_NEW} | |
67 | ||
68 | # Link each pair of class and category. | |
69 | # Verify diagnostics and output's has-category-class-properties bit. | |
70 | ||
71 | ############ | |
72 | # Class: NEW | |
73 | ||
74 | # Category: not OLD. No diagnostics. Result should be marked NEW. | |
75 | # Category: OLD but no category. No diagnostics. Result should be marked NEW. | |
76 | ${LD_R} class.o cat-with-class-prop.o -o class__cat-with-class-prop.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
77 | ${LD_R} class.o cat-without-class-prop.o -o class__cat-without-class-prop.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
78 | ${LD_R} class.o nocat.o -o class__nocat.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
79 | ${LD_R} class.o noobjc.o -o class__noobjc.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
80 | ${LD_R} class.o old-nocat.o -o class__old-nocat.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
81 | ${OBJCIMAGEINFO} class__cat-with-class-prop.o | ${FAIL_IF_OLD} | |
82 | ${OBJCIMAGEINFO} class__cat-without-class-prop.o | ${FAIL_IF_OLD} | |
83 | ${OBJCIMAGEINFO} class__nocat.o | ${FAIL_IF_OLD} | |
84 | ${OBJCIMAGEINFO} class__noobjc.o | ${FAIL_IF_OLD} | |
85 | ${OBJCIMAGEINFO} class__old-nocat.o | ${FAIL_IF_OLD} | |
86 | ||
87 | # Category: OLD. No diagnostics. Result should be marked OLD. | |
88 | ${LD_R} class.o old-cat.o -o class__old-cat.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
89 | ${OBJCIMAGEINFO} class__old-cat.o | ${FAIL_IF_NEW} | |
90 | ||
91 | # Two categories: OLD + NEW with class properties. Has diagnostics. Result should be marked OLD. | |
92 | ${LD_R} class.o old-cat.o cat-with-class-prop.o -o class__old-cat__cat-with-class-prop.o 2>&1 | ${FAIL_IF_NO_DIAGNOSTICS} | |
93 | ${OBJCIMAGEINFO} class__old-cat__cat-with-class-prop.o | ${FAIL_IF_NEW} | |
94 | ||
95 | # Two categories: OLD + NEW without class properties. No diagnostics. Result should be marked OLD. | |
96 | ${LD_R} class.o old-cat.o cat-without-class-prop.o -o class__old-cat__cat-without-class-prop.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
97 | ${OBJCIMAGEINFO} class__old-cat__cat-without-class-prop.o | ${FAIL_IF_NEW} | |
98 | ||
99 | ||
100 | ############ | |
101 | # Class: OLD | |
102 | ||
103 | # Category: OLD. No diagnostics. Result should be marked OLD. | |
104 | ${LD_R} old-class.o old-cat.o -o old-class__old-cat.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
105 | ${OBJCIMAGEINFO} old-class__old-cat.o | ${FAIL_IF_NEW} | |
106 | ||
107 | # Category: none. No diagnostics. Result should be marked NEW. | |
108 | ${LD_R} old-class.o nocat.o -o old-class__nocat.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
109 | ${LD_R} old-class.o noobjc.o -o old-class__noobjc.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
110 | ${LD_R} old-class.o old-nocat.o -o old-class__old-nocat.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
111 | ${OBJCIMAGEINFO} old-class__nocat.o | ${FAIL_IF_OLD} | |
112 | ${OBJCIMAGEINFO} old-class__noobjc.o | ${FAIL_IF_OLD} | |
113 | ${OBJCIMAGEINFO} old-class__old-nocat.o | ${FAIL_IF_OLD} | |
114 | ||
115 | # Category: NEW. No diagnostics. Result should be marked NEW. | |
116 | ${LD_R} old-class.o cat-without-class-prop.o -o old-class__cat-without-class-prop.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
117 | ${LD_R} old-class.o cat-with-class-prop.o -o old-class__cat-with-class-prop.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
118 | ${OBJCIMAGEINFO} old-class__cat-without-class-prop.o | ${FAIL_IF_OLD} | |
119 | ${OBJCIMAGEINFO} old-class__cat-with-class-prop.o | ${FAIL_IF_OLD} | |
120 | ||
121 | # Two categories: OLD + NEW with class properties. Has diagnostics. Result should be marked OLD. | |
122 | ${LD_R} old-class.o old-cat.o cat-with-class-prop.o -o old-class__old-cat__cat-with-class-prop.o 2>&1 | ${FAIL_IF_NO_DIAGNOSTICS} | |
123 | ${OBJCIMAGEINFO} old-class__old-cat__cat-with-class-prop.o | ${FAIL_IF_NEW} | |
124 | ||
125 | # Two categories: OLD + NEW without class properties. No diagnostics. Result should be marked OLD. | |
126 | ${LD_R} old-class.o old-cat.o cat-without-class-prop.o -o old-class__old-cat__cat-without-class-prop.o 2>&1 | ${FAIL_IF_DIAGNOSTICS} | |
127 | ${OBJCIMAGEINFO} old-class__old-cat__cat-without-class-prop.o | ${FAIL_IF_NEW} | |
128 | ||
129 | ${PASS_IFF} true | |
130 | ||
131 | clean: | |
132 | rm -rf *.o |