t_crt0.sh revision 1.4.38.1 1 1.4.38.1 pgoyette # $NetBSD: t_crt0.sh,v 1.4.38.1 2019/01/18 08:51:00 pgoyette Exp $
2 1.1 jmmv #
3 1.1 jmmv # Copyright (c) 2008 The NetBSD Foundation, Inc.
4 1.1 jmmv # All rights reserved.
5 1.1 jmmv #
6 1.1 jmmv # Redistribution and use in source and binary forms, with or without
7 1.1 jmmv # modification, are permitted provided that the following conditions
8 1.1 jmmv # are met:
9 1.1 jmmv # 1. Redistributions of source code must retain the above copyright
10 1.1 jmmv # notice, this list of conditions and the following disclaimer.
11 1.1 jmmv # 2. Redistributions in binary form must reproduce the above copyright
12 1.1 jmmv # notice, this list of conditions and the following disclaimer in the
13 1.1 jmmv # documentation and/or other materials provided with the distribution.
14 1.1 jmmv #
15 1.1 jmmv # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1 jmmv # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1 jmmv # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1 jmmv # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1 jmmv # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1 jmmv # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1 jmmv # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1 jmmv # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1 jmmv # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1 jmmv # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 jmmv # POSSIBILITY OF SUCH DAMAGE.
26 1.1 jmmv #
27 1.1 jmmv
28 1.2 joerg atf_test_case initfini1
29 1.2 joerg initfini1_head()
30 1.1 jmmv {
31 1.1 jmmv atf_set "descr" "Checks support for init/fini sections"
32 1.1 jmmv }
33 1.2 joerg initfini1_body()
34 1.1 jmmv {
35 1.1 jmmv cat >expout <<EOF
36 1.2 joerg constructor executed
37 1.2 joerg main executed
38 1.2 joerg destructor executed
39 1.1 jmmv EOF
40 1.1 jmmv
41 1.2 joerg atf_check -o file:expout "$(atf_get_srcdir)/h_initfini1"
42 1.2 joerg }
43 1.2 joerg
44 1.2 joerg atf_test_case initfini2
45 1.2 joerg initfini2_head()
46 1.2 joerg {
47 1.2 joerg atf_set "descr" "Checks support for init/fini sections in static binaries"
48 1.2 joerg }
49 1.2 joerg initfini2_body()
50 1.2 joerg {
51 1.2 joerg cat >expout <<EOF
52 1.2 joerg constructor executed
53 1.2 joerg main executed
54 1.2 joerg destructor executed
55 1.2 joerg EOF
56 1.2 joerg
57 1.2 joerg atf_check -o file:expout "$(atf_get_srcdir)/h_initfini2"
58 1.2 joerg }
59 1.2 joerg
60 1.2 joerg atf_test_case initfini3
61 1.2 joerg initfini3_head()
62 1.2 joerg {
63 1.2 joerg atf_set "descr" "Checks support for init/fini sections in dlopen"
64 1.2 joerg }
65 1.2 joerg initfini3_body()
66 1.2 joerg {
67 1.2 joerg cat >expout <<EOF
68 1.2 joerg constructor executed
69 1.2 joerg main started
70 1.2 joerg constructor2 executed
71 1.2 joerg main after dlopen
72 1.2 joerg destructor2 executed
73 1.2 joerg main terminated
74 1.2 joerg destructor executed
75 1.2 joerg EOF
76 1.2 joerg
77 1.2 joerg atf_check -o file:expout "$(atf_get_srcdir)/h_initfini3"
78 1.1 jmmv }
79 1.1 jmmv
80 1.4 joerg atf_test_case initfini4
81 1.4 joerg initfini4_head()
82 1.4 joerg {
83 1.4 joerg atf_set "descr" "Checks support for init/fini sections in LD_PRELOAD"
84 1.4 joerg }
85 1.4 joerg initfini4_body()
86 1.4 joerg {
87 1.4 joerg cat >expout <<EOF
88 1.4 joerg constructor2 executed
89 1.4 joerg constructor executed
90 1.4 joerg main executed
91 1.4 joerg destructor executed
92 1.4 joerg destructor2 executed
93 1.4 joerg EOF
94 1.4 joerg
95 1.4 joerg atf_check -o file:expout -x "env LD_PRELOAD=$(atf_get_srcdir)/h_initfini3_dso.so $(atf_get_srcdir)/h_initfini1"
96 1.4 joerg }
97 1.4 joerg
98 1.4.38.1 pgoyette atf_test_case initfini_array
99 1.4.38.1 pgoyette initfini_array_head()
100 1.4.38.1 pgoyette {
101 1.4.38.1 pgoyette atf_set "descr" "Checks support for init_array/fini_array sections"
102 1.4.38.1 pgoyette }
103 1.4.38.1 pgoyette initfini_array_body()
104 1.4.38.1 pgoyette {
105 1.4.38.1 pgoyette atf_check -x "$(atf_get_srcdir)/h_initfini_array"
106 1.4.38.1 pgoyette }
107 1.4.38.1 pgoyette
108 1.1 jmmv atf_init_test_cases()
109 1.1 jmmv {
110 1.2 joerg atf_add_test_case initfini1
111 1.2 joerg atf_add_test_case initfini2
112 1.2 joerg atf_add_test_case initfini3
113 1.4 joerg atf_add_test_case initfini4
114 1.4.38.1 pgoyette atf_add_test_case initfini_array
115 1.1 jmmv }
116