1*c3917926Sjruoho /* $NetBSD: t_equal.c,v 1.1 2011/03/24 12:40:59 jruoho Exp $ */
2*c3917926Sjruoho
3*c3917926Sjruoho /*-
4*c3917926Sjruoho * Copyright (c) 2011 The NetBSD Foundation, Inc.
5*c3917926Sjruoho * All rights reserved.
6*c3917926Sjruoho *
7*c3917926Sjruoho * This code is derived from software contributed to The NetBSD Foundation
8*c3917926Sjruoho * by Jukka Ruohonen.
9*c3917926Sjruoho *
10*c3917926Sjruoho * Redistribution and use in source and binary forms, with or without
11*c3917926Sjruoho * modification, are permitted provided that the following conditions
12*c3917926Sjruoho * are met:
13*c3917926Sjruoho * 1. Redistributions of source code must retain the above copyright
14*c3917926Sjruoho * notice, this list of conditions and the following disclaimer.
15*c3917926Sjruoho * 2. Redistributions in binary form must reproduce the above copyright
16*c3917926Sjruoho * notice, this list of conditions and the following disclaimer in the
17*c3917926Sjruoho * documentation and/or other materials provided with the distribution.
18*c3917926Sjruoho *
19*c3917926Sjruoho * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*c3917926Sjruoho * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*c3917926Sjruoho * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*c3917926Sjruoho * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*c3917926Sjruoho * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*c3917926Sjruoho * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*c3917926Sjruoho * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*c3917926Sjruoho * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*c3917926Sjruoho * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*c3917926Sjruoho * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*c3917926Sjruoho * POSSIBILITY OF SUCH DAMAGE.
30*c3917926Sjruoho */
31*c3917926Sjruoho #include <sys/cdefs.h>
32*c3917926Sjruoho __RCSID("$NetBSD: t_equal.c,v 1.1 2011/03/24 12:40:59 jruoho Exp $");
33*c3917926Sjruoho
34*c3917926Sjruoho #include <pthread.h>
35*c3917926Sjruoho
36*c3917926Sjruoho #include <atf-c.h>
37*c3917926Sjruoho
38*c3917926Sjruoho #include "h_common.h"
39*c3917926Sjruoho
40*c3917926Sjruoho static void *func(void *);
41*c3917926Sjruoho
42*c3917926Sjruoho static void *
func(void * arg)43*c3917926Sjruoho func(void *arg)
44*c3917926Sjruoho {
45*c3917926Sjruoho return NULL;
46*c3917926Sjruoho }
47*c3917926Sjruoho
48*c3917926Sjruoho ATF_TC(pthread_equal);
ATF_TC_HEAD(pthread_equal,tc)49*c3917926Sjruoho ATF_TC_HEAD(pthread_equal, tc)
50*c3917926Sjruoho {
51*c3917926Sjruoho atf_tc_set_md_var(tc, "descr", "A test of pthread_equal(3)");
52*c3917926Sjruoho }
53*c3917926Sjruoho
ATF_TC_BODY(pthread_equal,tc)54*c3917926Sjruoho ATF_TC_BODY(pthread_equal, tc)
55*c3917926Sjruoho {
56*c3917926Sjruoho pthread_t t1, t2;
57*c3917926Sjruoho
58*c3917926Sjruoho ATF_REQUIRE(pthread_create(&t1, NULL, func, NULL) == 0);
59*c3917926Sjruoho ATF_REQUIRE(pthread_create(&t2, NULL, func, NULL) == 0);
60*c3917926Sjruoho
61*c3917926Sjruoho ATF_REQUIRE(pthread_equal(t1, t1) != 0);
62*c3917926Sjruoho ATF_REQUIRE(pthread_equal(t2, t2) != 0);
63*c3917926Sjruoho ATF_REQUIRE(pthread_equal(t1, t2) == 0);
64*c3917926Sjruoho
65*c3917926Sjruoho ATF_REQUIRE(pthread_join(t1, NULL) == 0);
66*c3917926Sjruoho ATF_REQUIRE(pthread_join(t2, NULL) == 0);
67*c3917926Sjruoho }
68*c3917926Sjruoho
ATF_TP_ADD_TCS(tp)69*c3917926Sjruoho ATF_TP_ADD_TCS(tp)
70*c3917926Sjruoho {
71*c3917926Sjruoho ATF_TP_ADD_TC(tp, pthread_equal);
72*c3917926Sjruoho
73*c3917926Sjruoho return atf_no_error();
74*c3917926Sjruoho }
75