Source-Changes-HG archive

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

[src/trunk]: src Add new C++ ATF tests



details:   https://anonhg.NetBSD.org/src/rev/5bb4d34483c4
branches:  trunk
changeset: 321578:5bb4d34483c4
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Mar 24 00:26:51 2018 +0000

description:
Add new C++ ATF tests

Add new variations for existing C++ tests:
 - Static
 - Profile+32-bit
 - PIC+32-bit
 - PIC+Profile
 - PIC+Profile+32-bit

All tests pass for NetBSD/amd64:
 - t_cxxruntime
 - t_hello
 - t_static_destructor

+--------------------------------------------------------------+
| Options            | cxxruntime | hello  | static_destructor |
+--------------------------------------------------------------+
| None               | Passed     | Passed | Passed            |
| 32-bit             | Passed     | Passed | Passed            |
| PIC                | Passed     | Passed | Passed            |
| PIE                | Passed     | Passed | Passed            |
| Profile            | Passed     | Passed | Passed            |
| Static             | Passed     | Passed | Passed            |
| Profile+32-bit     | Passed     | Passed | Passed            |
| PIC+32-bit         | Passed     | Passed | Passed            |
| PIC+Profile        | Passed     | Passed | Passed            |
| PIC+Profile+32-bit | Passed     | Passed | Passed            |
+--------------------------------------------------------------+

Add new C++11 std::call_once tests:
 - t_call_once
 - t_call_once2

Add new C++11 test with pthread_once(3) and C++ lambda:
 - t_pthread_once

All tests with the profile option for std::call_once and
pthread_once(3) are marked as expected failure (NetBSD/amd64).

Results for *_once*:
+------------------------------------------------------------+
| Options            | call_once | call_once2 | pthread_once |
+------------------------------------------------------------+
| None               | Passed    | Passed     | Passed       |
| 32-bit             | Passed    |  Passed    | Passed       |
| PIC                | Passed    | Passed     | Passed       |
| PIE                | Passed    | Passed     | Passed       |
| Profile            |  Failed   |  Failed    |  Failed      |
| Static             | Passed    | Passed     | Passed       |
| Profile+32-bit     |  Failed   |  Failed    |  Failed      |
| PIC+32-bit         | Passed    | Passed     | Passed       |
| PIC+Profile        |  Failed   |  Failed    |  Failed      |
| PIC+Profile+32-bit |  Failed   |  Failed    |  Failed      |
+------------------------------------------------------------+

Long term there is an option to refacotr the framework for C and C++ tests,
in order to reduce code duplication.

Patches sent by Yang Zheng <tomsun.0.7%gmail.com@localhost>

diffstat:

 distrib/sets/lists/tests/mi              |    5 +-
 tests/usr.bin/c++/Makefile               |    5 +-
 tests/usr.bin/c++/t_call_once.sh         |  377 +++++++++++++++++++++
 tests/usr.bin/c++/t_call_once2.sh        |  553 +++++++++++++++++++++++++++++++
 tests/usr.bin/c++/t_cxxruntime.sh        |  171 +++++++++-
 tests/usr.bin/c++/t_hello.sh             |  152 ++++++++-
 tests/usr.bin/c++/t_pthread_once.sh      |  366 ++++++++++++++++++++
 tests/usr.bin/c++/t_static_destructor.sh |  228 ++++++++++++-
 8 files changed, 1850 insertions(+), 7 deletions(-)

diffs (truncated from 2024 to 300 lines):

diff -r 7184a88a544f -r 5bb4d34483c4 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Mar 24 00:06:32 2018 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Mar 24 00:26:51 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.777 2018/03/14 02:13:47 kamil Exp $
+# $NetBSD: mi,v 1.778 2018/03/24 00:26:51 kamil Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3638,6 +3638,9 @@
 ./usr/tests/usr.bin/c++/t_cxxruntime           tests-usr.bin-tests     compattestfile,atf,cxx
 ./usr/tests/usr.bin/c++/t_hello                        tests-usr.bin-tests     compattestfile,atf,cxx
 ./usr/tests/usr.bin/c++/t_static_destructor    tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_call_once            tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_call_once2           tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_pthread_once         tests-usr.bin-tests     compattestfile,atf,cxx
 ./usr/tests/usr.bin/cc                         tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/cc/Atffile                 tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/cc/Kyuafile                        tests-usr.bin-tests     compattestfile,atf,kyua
diff -r 7184a88a544f -r 5bb4d34483c4 tests/usr.bin/c++/Makefile
--- a/tests/usr.bin/c++/Makefile        Sat Mar 24 00:06:32 2018 +0000
+++ b/tests/usr.bin/c++/Makefile        Sat Mar 24 00:26:51 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2017/05/14 02:02:25 kamil Exp $
+# $NetBSD: Makefile,v 1.4 2018/03/24 00:26:51 kamil Exp $
 
 .include <bsd.own.mk>
 
@@ -7,5 +7,8 @@
 TESTS_SH=      t_cxxruntime
 TESTS_SH+=     t_hello
 TESTS_SH+=     t_static_destructor
+TESTS_SH+=     t_call_once
+TESTS_SH+=     t_call_once2
+TESTS_SH+=     t_pthread_once
 
 .include <bsd.test.mk>
diff -r 7184a88a544f -r 5bb4d34483c4 tests/usr.bin/c++/t_call_once.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/c++/t_call_once.sh  Sat Mar 24 00:26:51 2018 +0000
@@ -0,0 +1,377 @@
+#      $NetBSD: t_call_once.sh,v 1.1 2018/03/24 00:26:51 kamil Exp $
+#
+# Copyright (c) 2018 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+atf_test_case call_once
+call_once_head() {
+       atf_set "descr" "compile and run std::call_once"
+       atf_set "require.progs" "c++"
+}
+
+atf_test_case call_once_profile
+call_once_profile_head() {
+       atf_set "descr" "compile and run std::call_once with profiling option"
+       atf_set "require.progs" "c++"
+}
+
+atf_test_case call_once_pic
+call_once_pic_head() {
+       atf_set "descr" "compile and run PIC std::call_once"
+       atf_set "require.progs" "c++"
+}
+
+atf_test_case call_once_pic_32
+call_once_pic_32_head() {
+       atf_set "descr" "compile and run 32-bit PIC std::call_once"
+       atf_set "require.progs" "c++"
+}
+
+atf_test_case call_once_pic_profile
+call_once_pic_head() {
+       atf_set "descr" "compile and run PIC std::call_once with profiling flag"
+       atf_set "require.progs" "c++"
+}
+
+atf_test_case call_once_pic_profile_32
+call_once_pic_profile_32_head() {
+       atf_set "descr" "compile and run 32-bit PIC std::call_once with profiling flag"
+       atf_set "require.progs" "c++"
+}
+
+atf_test_case call_once_profile_32
+call_once_profile_32_head() {
+       atf_set "descr" "compile and run 32-bit std::call_once with profiling flag"
+       atf_set "require.progs" "c++"
+}
+
+atf_test_case call_once_pie
+call_once_pie_head() {
+       atf_set "descr" "compile and run position independent (PIE) std::call_once"
+       atf_set "require.progs" "c++"
+}
+
+atf_test_case call_once_32
+call_once_32_head() {
+       atf_set "descr" "compile and run std::call_once for/in netbsd32 emulation"
+       atf_set "require.progs" "c++ file diff cat"
+}
+
+atf_test_case call_once_static
+call_once_static_head() {
+       atf_set "descr" "compile and run std::call_once with static flag"
+       atf_set "require.progs" "c++"
+}
+
+call_once_body() {
+       cat > test.cpp << EOF
+#include <cstdio>
+#include <thread>
+#include <mutex>
+std::once_flag flag;
+int main(void) {
+        std::call_once(flag, [](){ printf("hello, world!\n"); });
+        return 0;
+}
+EOF
+       atf_check -s exit:0 -o ignore -e ignore c++ -o call_once test.cpp -pthread
+       atf_check -s exit:0 -o inline:"hello, world!\n" ./call_once
+}
+
+call_once_profile_body() {
+       atf_expect_fail "profiling option doesn't work now"
+       cat > test.cpp << EOF
+#include <cstdio>
+#include <thread>
+#include <mutex>
+std::once_flag flag;
+int main(void) {
+        std::call_once(flag, [](){ printf("hello, world!\n"); });
+        return 0;
+}
+EOF
+       atf_check -s exit:0 -o ignore -e ignore c++ -pg -o call_once test.cpp -pthread
+       atf_check -s exit:0 -o inline:"hello, world!\n" ./call_once
+}
+
+call_once_profile_32_body() {
+       atf_expect_fail "profiling option doesn't work now"
+       # check whether this arch is 64bit
+       if ! c++ -dM -E - < /dev/null | fgrep -q _LP64; then
+               atf_skip "this is not a 64 bit architecture"
+       fi
+       if ! c++ -m32 -dM -E - < /dev/null 2>/dev/null > ./def32; then
+               atf_skip "c++ -m32 not supported on this architecture"
+       else
+               if fgrep -q _LP64 ./def32; then
+                       atf_fail "c++ -m32 does not generate netbsd32 binaries"
+               fi
+       fi
+
+       cat > test.cpp << EOF
+#include <cstdio>
+#include <thread>
+#include <mutex>
+std::once_flag flag;
+int main(void) {
+        std::call_once(flag, [](){ printf("hello, world!\n"); });
+        return 0;
+}
+EOF
+       atf_check -s exit:0 -o ignore -e ignore c++ -m32 -pg -o call_once test.cpp -pthread
+       atf_check -s exit:0 -o inline:"hello, world!\n" ./call_once
+       atf_expect_fail "The combination of 32-bit and profiling should be fail"
+}
+
+call_once_pic_body() {
+       cat > test.cpp << EOF
+#include <stdlib.h>
+int callpic(void);
+int main(void) {callpic();exit(0);}
+EOF
+       cat > pic.cpp << EOF
+#include <cstdio>
+#include <thread>
+#include <mutex>
+std::once_flag flag;
+int callpic(void) {
+        std::call_once(flag, [](){ printf("hello, world!\n"); });
+        return 0;
+}
+EOF
+
+       atf_check -s exit:0 -o ignore -e ignore \
+           c++ -fPIC -shared -o libtest.so pic.cpp
+       atf_check -s exit:0 -o ignore -e ignore \
+           c++ -o call_once test.cpp -L. -ltest -pthread
+
+       export LD_LIBRARY_PATH=.
+       atf_check -s exit:0 -o inline:"hello, world!\n" ./call_once
+}
+
+call_once_pic_32_body() {
+       # check whether this arch is 64bit
+       if ! c++ -dM -E - < /dev/null | fgrep -q _LP64; then
+               atf_skip "this is not a 64 bit architecture"
+       fi
+       if ! c++ -m32 -dM -E - < /dev/null 2>/dev/null > ./def32; then
+               atf_skip "c++ -m32 not supported on this architecture"
+       else
+               if fgrep -q _LP64 ./def32; then
+                       atf_fail "c++ -m32 does not generate netbsd32 binaries"
+               fi
+       fi
+
+       cat > test.cpp << EOF
+#include <stdlib.h>
+int callpic(void);
+int main(void) {callpic();exit(0);}
+EOF
+       cat > pic.cpp << EOF
+#include <cstdio>
+#include <thread>
+#include <mutex>
+std::once_flag flag;
+int callpic(void) {
+        std::call_once(flag, [](){ printf("hello, world!\n"); });
+        return 0;
+}
+EOF
+
+       atf_check -s exit:0 -o ignore -e ignore \
+           c++ -m32 -fPIC -shared -o libtest.so pic.cpp
+       atf_check -s exit:0 -o ignore -e ignore \
+           c++ -m32 -o call_once test.cpp -L. -ltest -pthread
+
+       export LD_LIBRARY_PATH=.
+       atf_check -s exit:0 -o inline:"hello, world!\n" ./call_once
+}
+
+call_once_pic_profile_body() {
+       atf_expect_fail "profiling option doesn't work now"
+       cat > test.cpp << EOF
+#include <stdlib.h>
+int callpic(void);
+int main(void) {callpic();exit(0);}
+EOF
+       cat > pic.cpp << EOF
+#include <cstdio>
+#include <thread>
+#include <mutex>
+std::once_flag flag;
+int callpic(void) {
+        std::call_once(flag, [](){ printf("hello, world!\n"); });
+        return 0;
+}
+EOF
+
+       atf_check -s exit:0 -o ignore -e ignore \
+           c++ -pg -fPIC -shared -o libtest.so pic.cpp
+       atf_check -s exit:0 -o ignore -e ignore \
+           c++ -pg -o call_once test.cpp -L. -ltest -pthread
+
+       export LD_LIBRARY_PATH=.
+       atf_check -s exit:0 -o inline:"hello, world!\n" ./call_once
+}
+
+call_once_pic_profile_32_body() {
+       atf_expect_fail "profiling option doesn't work now"
+       # check whether this arch is 64bit
+       if ! c++ -dM -E - < /dev/null | fgrep -q _LP64; then
+               atf_skip "this is not a 64 bit architecture"
+       fi
+       if ! c++ -m32 -dM -E - < /dev/null 2>/dev/null > ./def32; then
+               atf_skip "c++ -m32 not supported on this architecture"
+       else
+               if fgrep -q _LP64 ./def32; then
+                       atf_fail "c++ -m32 does not generate netbsd32 binaries"
+               fi
+       fi
+
+       cat > test.cpp << EOF
+#include <stdlib.h>
+int callpic(void);
+int main(void) {callpic();exit(0);}
+EOF
+       cat > pic.cpp << EOF
+#include <cstdio>



Home | Main Index | Thread Index | Old Index