Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/cc Add a test case that (if gcc supports it on...
details: https://anonhg.NetBSD.org/src/rev/12fb0f2e41c5
branches: trunk
changeset: 780363:12fb0f2e41c5
user: martin <martin%NetBSD.org@localhost>
date: Sat Jul 21 12:30:55 2012 +0000
description:
Add a test case that (if gcc supports it on the current arch) to compile
a PIE binary and see if we can run it.
diffstat:
tests/usr.bin/cc/t_hello.sh | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diffs (50 lines):
diff -r f9f1962dd90a -r 12fb0f2e41c5 tests/usr.bin/cc/t_hello.sh
--- a/tests/usr.bin/cc/t_hello.sh Sat Jul 21 12:19:15 2012 +0000
+++ b/tests/usr.bin/cc/t_hello.sh Sat Jul 21 12:30:55 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_hello.sh,v 1.1 2012/03/17 17:15:29 jruoho Exp $
+# $NetBSD: t_hello.sh,v 1.2 2012/07/21 12:30:55 martin Exp $
#
# Copyright (c) 2011 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -37,6 +37,12 @@
atf_set "require.progs" "cc"
}
+atf_test_case hello_pie
+hello_pie_head() {
+ atf_set "descr" "compile and run position independend (PIE) \"hello world\""
+ atf_set "require.progs" "cc"
+}
+
atf_test_case hello32
hello32_head() {
atf_set "descr" "compile and run \"hello world\" for/in netbsd32 emulation"
@@ -72,6 +78,20 @@
atf_check -s exit:0 -o inline:"hello world\n" ./hello
}
+hello_pie_body() {
+ # check whether this arch supports -pie
+ if ! cc -pie -dM -E - < /dev/null 2>/dev/null >/dev/null; then
+ atf_skip "cc -pie not supported on this architecture"
+ fi
+ cat > test.c << EOF
+#include <stdio.h>
+#include <stdlib.h>
+int main(void) {printf("hello world\n");exit(0);}
+EOF
+ atf_check -s exit:0 -o ignore -e ignore cc -fpie -pie -o hello test.c
+ atf_check -s exit:0 -o inline:"hello world\n" ./hello
+}
+
hello32_body() {
# check whether this arch is 64bit
if ! cc -dM -E - < /dev/null | fgrep -q _LP64; then
@@ -119,5 +139,6 @@
atf_add_test_case hello
atf_add_test_case hello_pic
+ atf_add_test_case hello_pie
atf_add_test_case hello32
}
Home |
Main Index |
Thread Index |
Old Index