| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: t_call_once2.sh,v 1.3 2021/09/04 05:47:31 rin Exp $ | | 1 | # $NetBSD: t_call_once2.sh,v 1.4 2022/05/07 05:14:09 rin Exp $ |
2 | # | | 2 | # |
3 | # Copyright (c) 2018 The NetBSD Foundation, Inc. | | 3 | # Copyright (c) 2018 The NetBSD Foundation, Inc. |
4 | # All rights reserved. | | 4 | # All rights reserved. |
5 | # | | 5 | # |
6 | # Redistribution and use in source and binary forms, with or without | | 6 | # Redistribution and use in source and binary forms, with or without |
7 | # modification, are permitted provided that the following conditions | | 7 | # modification, are permitted provided that the following conditions |
8 | # are met: | | 8 | # are met: |
9 | # 1. Redistributions of source code must retain the above copyright | | 9 | # 1. Redistributions of source code must retain the above copyright |
10 | # notice, this list of conditions and the following disclaimer. | | 10 | # notice, this list of conditions and the following disclaimer. |
11 | # 2. Redistributions in binary form must reproduce the above copyright | | 11 | # 2. Redistributions in binary form must reproduce the above copyright |
12 | # notice, this list of conditions and the following disclaimer in the | | 12 | # notice, this list of conditions and the following disclaimer in the |
13 | # documentation and/or other materials provided with the distribution. | | 13 | # documentation and/or other materials provided with the distribution. |
14 | # | | 14 | # |
| @@ -19,80 +19,90 @@ | | | @@ -19,80 +19,90 @@ |
19 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 19 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 20 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 21 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 22 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 23 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 | # POSSIBILITY OF SUCH DAMAGE. | | 25 | # POSSIBILITY OF SUCH DAMAGE. |
26 | # | | 26 | # |
27 | | | 27 | |
28 | atf_test_case call_once2 | | 28 | atf_test_case call_once2 |
29 | call_once2_head() { | | 29 | call_once2_head() { |
30 | atf_set "descr" "compile and run std::call_once" | | 30 | atf_set "descr" "compile and run std::call_once" |
31 | atf_set "require.progs" "c++" | | 31 | atf_set "require.progs" "c++" |
| | | 32 | atf_set "timeout" "600" |
32 | } | | 33 | } |
33 | | | 34 | |
34 | atf_test_case call_once2_profile | | 35 | atf_test_case call_once2_profile |
35 | call_once2_profile_head() { | | 36 | call_once2_profile_head() { |
36 | atf_set "descr" "compile and run std::call_once with profiling option" | | 37 | atf_set "descr" "compile and run std::call_once with profiling option" |
37 | atf_set "require.progs" "c++" | | 38 | atf_set "require.progs" "c++" |
| | | 39 | atf_set "timeout" "600" |
38 | } | | 40 | } |
39 | | | 41 | |
40 | atf_test_case call_once2_pic | | 42 | atf_test_case call_once2_pic |
41 | call_once2_pic_head() { | | 43 | call_once2_pic_head() { |
42 | atf_set "descr" "compile and run PIC std::call_once" | | 44 | atf_set "descr" "compile and run PIC std::call_once" |
43 | atf_set "require.progs" "c++" | | 45 | atf_set "require.progs" "c++" |
| | | 46 | atf_set "timeout" "600" |
44 | } | | 47 | } |
45 | | | 48 | |
46 | atf_test_case call_once2_pic_32 | | 49 | atf_test_case call_once2_pic_32 |
47 | call_once2_pic_32_head() { | | 50 | call_once2_pic_32_head() { |
48 | atf_set "descr" "compile and run 32-bit PIC std::call_once" | | 51 | atf_set "descr" "compile and run 32-bit PIC std::call_once" |
49 | atf_set "require.progs" "c++" | | 52 | atf_set "require.progs" "c++" |
| | | 53 | atf_set "timeout" "600" |
50 | } | | 54 | } |
51 | | | 55 | |
52 | atf_test_case call_once2_pic_profile | | 56 | atf_test_case call_once2_pic_profile |
53 | call_once2_pic_profile_head() { | | 57 | call_once2_pic_profile_head() { |
54 | atf_set "descr" "compile and run PIC std::call_once with profiling flag" | | 58 | atf_set "descr" "compile and run PIC std::call_once with profiling flag" |
55 | atf_set "require.progs" "c++" | | 59 | atf_set "require.progs" "c++" |
| | | 60 | atf_set "timeout" "600" |
56 | } | | 61 | } |
57 | | | 62 | |
58 | atf_test_case call_once2_pic_profile_32 | | 63 | atf_test_case call_once2_pic_profile_32 |
59 | call_once2_pic_profile_32_head() { | | 64 | call_once2_pic_profile_32_head() { |
60 | atf_set "descr" "compile and run 32-bit PIC std::call_once with profiling flag" | | 65 | atf_set "descr" "compile and run 32-bit PIC std::call_once with profiling flag" |
61 | atf_set "require.progs" "c++" | | 66 | atf_set "require.progs" "c++" |
| | | 67 | atf_set "timeout" "600" |
62 | } | | 68 | } |
63 | | | 69 | |
64 | atf_test_case call_once2_profile_32 | | 70 | atf_test_case call_once2_profile_32 |
65 | call_once2_profile_32_head() { | | 71 | call_once2_profile_32_head() { |
66 | atf_set "descr" "compile and run 32-bit std::call_once with profiling flag" | | 72 | atf_set "descr" "compile and run 32-bit std::call_once with profiling flag" |
67 | atf_set "require.progs" "c++" | | 73 | atf_set "require.progs" "c++" |
| | | 74 | atf_set "timeout" "600" |
68 | } | | 75 | } |
69 | | | 76 | |
70 | atf_test_case call_once2_pie | | 77 | atf_test_case call_once2_pie |
71 | call_once2_pie_head() { | | 78 | call_once2_pie_head() { |
72 | atf_set "descr" "compile and run position independent (PIE) std::call_once" | | 79 | atf_set "descr" "compile and run position independent (PIE) std::call_once" |
73 | atf_set "require.progs" "c++" | | 80 | atf_set "require.progs" "c++" |
| | | 81 | atf_set "timeout" "600" |
74 | } | | 82 | } |
75 | | | 83 | |
76 | atf_test_case call_once2_32 | | 84 | atf_test_case call_once2_32 |
77 | call_once2_32_head() { | | 85 | call_once2_32_head() { |
78 | atf_set "descr" "compile and run std::call_once for/in netbsd32 emulation" | | 86 | atf_set "descr" "compile and run std::call_once for/in netbsd32 emulation" |
79 | atf_set "require.progs" "c++ file diff cat" | | 87 | atf_set "require.progs" "c++ file diff cat" |
| | | 88 | atf_set "timeout" "600" |
80 | } | | 89 | } |
81 | | | 90 | |
82 | atf_test_case call_once2_static | | 91 | atf_test_case call_once2_static |
83 | call_once2_static_head() { | | 92 | call_once2_static_head() { |
84 | atf_set "descr" "compile and run std::call_once with static flag" | | 93 | atf_set "descr" "compile and run std::call_once with static flag" |
85 | atf_set "require.progs" "c++" | | 94 | atf_set "require.progs" "c++" |
| | | 95 | atf_set "timeout" "600" |
86 | } | | 96 | } |
87 | | | 97 | |
88 | call_once2_body() { | | 98 | call_once2_body() { |
89 | cat > test.cpp << EOF | | 99 | cat > test.cpp << EOF |
90 | #include <mutex> | | 100 | #include <mutex> |
91 | #include <thread> | | 101 | #include <thread> |
92 | #include <iostream> | | 102 | #include <iostream> |
93 | std::once_flag flag, flag_throw; | | 103 | std::once_flag flag, flag_throw; |
94 | void print_once(void) { std::call_once(flag, [](){ std::cout << "hello, " << std::flush; }); } | | 104 | void print_once(void) { std::call_once(flag, [](){ std::cout << "hello, " << std::flush; }); } |
95 | void throw_once(void) { throw std::exception(); } | | 105 | void throw_once(void) { throw std::exception(); } |
96 | int main(void) { | | 106 | int main(void) { |
97 | static const int nr_threads(4); | | 107 | static const int nr_threads(4); |
98 | std::thread threads[nr_threads]; | | 108 | std::thread threads[nr_threads]; |