xref: /netbsd-src/tests/libexec/ld.elf_so/t_thread_local_dtor.sh (revision e5678be828932e6f3c8f31897ff2b79723f3129b)
1*e5678be8Sjoerg# $NetBSD: t_thread_local_dtor.sh,v 1.1 2017/07/11 15:21:36 joerg Exp $
2*e5678be8Sjoerg#
3*e5678be8Sjoerg# Copyright (c) 2017 The NetBSD Foundation, Inc.
4*e5678be8Sjoerg# All rights reserved.
5*e5678be8Sjoerg#
6*e5678be8Sjoerg# Redistribution and use in source and binary forms, with or without
7*e5678be8Sjoerg# modification, are permitted provided that the following conditions
8*e5678be8Sjoerg# are met:
9*e5678be8Sjoerg# 1. Redistributions of source code must retain the above copyright
10*e5678be8Sjoerg#    notice, this list of conditions and the following disclaimer.
11*e5678be8Sjoerg# 2. Redistributions in binary form must reproduce the above copyright
12*e5678be8Sjoerg#    notice, this list of conditions and the following disclaimer in the
13*e5678be8Sjoerg#    documentation and/or other materials provided with the distribution.
14*e5678be8Sjoerg#
15*e5678be8Sjoerg# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16*e5678be8Sjoerg# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17*e5678be8Sjoerg# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18*e5678be8Sjoerg# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19*e5678be8Sjoerg# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20*e5678be8Sjoerg# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21*e5678be8Sjoerg# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22*e5678be8Sjoerg# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23*e5678be8Sjoerg# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24*e5678be8Sjoerg# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25*e5678be8Sjoerg# POSSIBILITY OF SUCH DAMAGE.
26*e5678be8Sjoerg#
27*e5678be8Sjoerg
28*e5678be8Sjoergatf_test_case thread_local_dtor
29*e5678be8Sjoergthread_local_dtor_head()
30*e5678be8Sjoerg{
31*e5678be8Sjoerg	atf_set "descr" "Checks dlclose vs thread_local"
32*e5678be8Sjoerg}
33*e5678be8Sjoergthread_local_dtor_body()
34*e5678be8Sjoerg{
35*e5678be8Sjoerg	$(atf_get_srcdir)/h_thread_local_dtor >out \
36*e5678be8Sjoerg		|| atf_fail "h_thread_local_dtor failed, see output of the test for details"
37*e5678be8Sjoerg
38*e5678be8Sjoerg	cat >exp <<EOF
39*e5678be8Sjoergin ctor: global_dtor
40*e5678be8Sjoergin ctor: thread_local
41*e5678be8Sjoergbefore dlclose
42*e5678be8Sjoergafter dlclose
43*e5678be8Sjoergin dtor: thread_local
44*e5678be8Sjoergin dtor: global_dtor
45*e5678be8SjoergEOF
46*e5678be8Sjoerg
47*e5678be8Sjoerg	diff -Nru exp out \
48*e5678be8Sjoerg		|| atf_fail "h_thread_local_dtor failed, see output of the test for details"
49*e5678be8Sjoerg}
50*e5678be8Sjoerg
51*e5678be8Sjoergatf_init_test_cases()
52*e5678be8Sjoerg{
53*e5678be8Sjoerg	atf_add_test_case thread_local_dtor
54*e5678be8Sjoerg}
55