Module Name: src
Committed By: martin
Date: Sat Jul 21 12:30:55 UTC 2012
Modified Files:
src/tests/usr.bin/cc: t_hello.sh
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/cc/t_hello.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/cc/t_hello.sh
diff -u src/tests/usr.bin/cc/t_hello.sh:1.1 src/tests/usr.bin/cc/t_hello.sh:1.2
--- src/tests/usr.bin/cc/t_hello.sh:1.1 Sat Mar 17 17:15:29 2012
+++ src/tests/usr.bin/cc/t_hello.sh Sat Jul 21 12:30:55 2012
@@ -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 @@ hello_pic_head() {
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 @@ EOF
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_init_test_cases()
atf_add_test_case hello
atf_add_test_case hello_pic
+ atf_add_test_case hello_pie
atf_add_test_case hello32
}