Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/ld Test object ordering.



details:   https://anonhg.NetBSD.org/src/rev/b1302b9a35c4
branches:  trunk
changeset: 333721:b1302b9a35c4
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Sat Nov 15 03:47:29 2014 +0000

description:
Test object ordering.

diffstat:

 tests/usr.bin/ld/t_script.sh |  50 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 48 insertions(+), 2 deletions(-)

diffs (86 lines):

diff -r f839f831abe7 -r b1302b9a35c4 tests/usr.bin/ld/t_script.sh
--- a/tests/usr.bin/ld/t_script.sh      Sat Nov 15 03:22:29 2014 +0000
+++ b/tests/usr.bin/ld/t_script.sh      Sat Nov 15 03:47:29 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_script.sh,v 1.2 2014/11/15 03:10:01 uebayasi Exp $
+#      $NetBSD: t_script.sh,v 1.3 2014/11/15 03:47:29 uebayasi Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -25,6 +25,40 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
+################################################################################
+
+atf_test_case order
+order_head() {
+       atf_set "descr" "check if object ordering work"
+       atf_set "require.progs" "cc" "ld" "readelf" "nm" "sed" "grep"
+}
+
+order_body() {
+       for i in a b c; do
+               cat > $i.c << EOF
+#include <sys/cdefs.h>
+char $i __section(".data.$i") = '$i';
+EOF
+       done
+       cat > test.c << EOF
+int main(void) { return 0; }
+EOF
+       # c -> b -> a
+       atf_check -s exit:0 -o ignore -e ignore \
+           cc -o test test.c c.c b.c a.c
+       extract_symbol_names test |
+       grep '^[abc]$' >test.syms
+       {
+               match c &&
+               match b &&
+               match a &&
+               :
+       } <test.syms
+       atf_check test "$?" -eq 0
+}
+
+################################################################################
+
 atf_test_case multisec
 multisec_head() {
        atf_set "descr" "check if multiple SECTIONS commands work"
@@ -63,6 +97,8 @@
        assert_sec '\.data\.c'
 }
 
+################################################################################
+
 extract_section_names() {
        readelf -S "$1" |
        sed -ne '/\] \./ { s/^.*\] //; s/ .*$//; p }'
@@ -73,6 +109,14 @@
        sed -e 's/^.* //'
 }
 
+match() {
+       read line
+       case "$line" in
+       *"$1"*) return 0;
+       esac
+       return 1
+}
+
 assert_sec() {
        atf_check -s exit:0 -o ignore -e ignore \
            grep "^$1\$" test.secs
@@ -83,8 +127,10 @@
            grep "^$1\$" test.secs
 }
 
+################################################################################
+
 atf_init_test_cases()
 {
-
+       atf_add_test_case order
        atf_add_test_case multisec
 }



Home | Main Index | Thread Index | Old Index