Print this page
10367 ld(1) tests should be a real test suite
10368 want an ld(1) regression test for i386 LD tls transition (10267)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/sgs/test/ld/assert-deflib/test-deflib.sh
+++ new/usr/src/test/elf-tests/tests/assert-deflib/test-deflib.sh
1 1 #!/bin/bash
2 2 #
3 3 # This file and its contents are supplied under the terms of the
4 4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 5 # You may only use this file in accordance with the terms of version
6 6 # 1.0 of the CDDL.
7 7 #
8 8 # A full copy of the text of the CDDL should have accompanied this
9 9 # source. A copy of the CDDL is also available via the Internet at
10 10 # http://www.illumos.org/license/CDDL.
11 11 #
12 12
13 13 #
14 14 # Copyright (c) 2012, Joyent, Inc.
15 15 #
16 16
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 #
18 18 # This test validates that the -zassert-deflib option of ld(1) works correctly.
19 19 # It requires that some cc is in your path and that you have passed in the path
20 20 # to the proto area with the new version of libld.so.4. One thing that we have
21 21 # to do is be careful with using LD_LIBRARY_PATH. Setting LD_LIBRARY_PATH does
22 22 # not change the default search path so we want to make sure that we use a
23 23 # different ISA (e.g. 32-bit vs 64-bit) from the binary we're generating.
24 24 #
25 25 unalias -a
26 26
27 +TESTDIR=$(dirname $0)
28 +
27 29 sh_path=
28 30 sh_lib="lib"
29 31 sh_lib64="$sh_lib/64"
30 32 sh_soname="libld.so.4"
31 -sh_cc="cc"
33 +sh_cc="gcc"
32 34 sh_cflags="-m32"
33 -sh_file="link.c"
35 +sh_file="${TESTDIR}/link.c"
34 36 sh_arg0=$(basename $0)
35 37
36 38 function fatal
37 39 {
38 40 local msg="$*"
39 41 [[ -z "$msg" ]] && msg="failed"
40 42 echo "$sh_arg0: $msg" >&2
41 43 exit 1
42 44 }
43 45
44 46
45 47 #
46 48 # Validate that everything we need is in our path. That includes having cc
47 49 # and the proto area libld.
48 50 #
49 51 function validate
50 52 {
51 53 [[ -f $sh_path/$sh_lib/$sh_soname ]] || fatal "missing 32-bit $sh_soname"
52 54 [[ -f $sh_path/$sh_lib64/$sh_soname ]] ||
53 55 fatal "missing 64-bit $sh_soname"
54 56 which $sh_cc >/dev/null || fatal "cc not in path"
55 57 }
56 58
57 59 #
58 60 # $1 is a series of flags to append
59 61 # $2 is expected exit status
60 62 # $3 is pre-test message
61 63 # $4 is the failure message
62 64 #
63 65 function run
64 66 {
65 67 local ret
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
66 68
67 69 echo $3
68 70 LD_LIBRARY_PATH_64="$sh_path/$sh_lib64" $sh_cc $sh_cflags $sh_file $1
69 71 if [[ $? -eq $2 ]]; then
70 72 printf "success\n\n"
71 73 else
72 74 fatal $4
73 75 fi
74 76 }
75 77
76 -sh_path=$1
77 -[[ -z "$1" ]] && fatal "<proto root>"
78 +sh_path=${1:-/}
78 79 validate
79 80
80 81 run "-Wl,-zassert-deflib" 0 \
81 82 "Testing basic compilation succeeds with warnings..." \
82 83 "failed to compile with warnings"
83 84
84 85 run "-Wl,-zassert-deflib -Wl,-zfatal-warnings" 1 \
85 86 "Testing basic compilation fails if warning are fatal..." \
86 87 "linking succeeeded, expected failure"
87 88
88 89 run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings" 0 \
89 90 "Testing basic exception with fatal warnings..." \
90 91 "linking failed despite exception"
91 92
92 93 run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings" 0 \
93 94 "Testing basic exception with fatal warnings..." \
94 95 "linking failed despite exception"
95 96
96 97
97 98 run "-Wl,-zassert-deflib=lib.so -Wl,-zfatal-warnings" 1 \
98 99 "Testing invalid library name..." \
99 100 "ld should not allow invalid library name"
100 101
101 102 run "-Wl,-zassert-deflib=libf -Wl,-zfatal-warnings" 1 \
102 103 "Testing invalid library name..." \
103 104 "ld should not allow invalid library name"
104 105
105 106 run "-Wl,-zassert-deflib=libf.s -Wl,-zfatal-warnings" 1 \
106 107 "Testing invalid library name..." \
107 108 "ld should not allow invalid library name"
108 109
109 110 run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings -lelf" 1 \
110 111 "Errors even if one library is under exception path..." \
111 112 "one exception shouldn't stop another"
112 113
113 114 args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelf.so"
114 115 args="$args -Wl,-zfatal-warnings -lelf"
115 116
116 117 run "$args" 0 \
117 118 "Multiple exceptions work..." \
118 119 "multiple exceptions don't work"
119 120
120 121 args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelfe.so"
121 122 args="$args -Wl,-zfatal-warnings -lelf"
122 123
123 124 run "$args" 1 \
124 125 "Exceptions only catch the specific library" \
125 126 "exceptions caught the wrong library"
126 127
127 128 args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libel.so"
128 129 args="$args -Wl,-zfatal-warnings -lelf"
129 130
130 131 run "$args" 1 \
131 132 "Exceptions only catch the specific library" \
132 133 "exceptions caught the wrong library"
133 134
134 135 echo "Tests passed."
135 136 exit 0
↓ open down ↓ |
48 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX