2 # Copyright (c) 2010 Apple Inc. All rights reserved.
4 # @APPLE_LICENSE_HEADER_START@
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
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.
21 # @APPLE_LICENSE_HEADER_END@
24 include ${TESTROOT}/include/common.makefile
28 # Verify handling of object files with mismatched category class properties.
31 LD_R = ${LD} -arch ${ARCH} -r
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}
38 # check diagnostics from ld
39 FAIL_IF_DIAGNOSTICS = ${FAIL_IF_STDIN}
40 FAIL_IF_NO_DIAGNOSTICS = egrep 'warning.*category metadata' | ${FAIL_IF_EMPTY}
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.
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.
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}
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}
68 # Link each pair of class and category.
69 # Verify diagnostics and output's has-category-class-properties bit.
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}
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}
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}
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}
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}
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}
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}
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}
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}