1 /* $NetBSD: t_syslog.c,v 1.3 2020/07/03 03:13:10 jruoho Exp $ */
2
3 /*-
4 * Copyright (c) 2010, 2020 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31 #include <sys/types.h>
32
33 #include <atf-c.h>
34 #include <syslog.h>
35
36 ATF_TC(syslog_pthread);
ATF_TC_HEAD(syslog_pthread,tc)37 ATF_TC_HEAD(syslog_pthread, tc)
38 {
39 atf_tc_set_md_var(tc, "descr", "Test that syslog(3) "
40 "works when linked to pthread(3) (PR lib/44248)");
41 atf_tc_set_md_var(tc, "timeout", "2");
42 }
43
ATF_TC_BODY(syslog_pthread,tc)44 ATF_TC_BODY(syslog_pthread, tc)
45 {
46 syslog(LOG_DEBUG, "from tests/lib/libc/gen/t_syslog");
47 }
48
49 ATF_TC(syslog_invalid_priority);
ATF_TC_HEAD(syslog_invalid_priority,tc)50 ATF_TC_HEAD(syslog_invalid_priority, tc)
51 {
52 atf_tc_set_md_var(tc, "descr", "Test that syslog(3) does "
53 "not segfault from an invalid priority (PR lib/55041)");
54 }
55
ATF_TC_BODY(syslog_invalid_priority,tc)56 ATF_TC_BODY(syslog_invalid_priority, tc)
57 {
58 syslog(-1, "from tests/lib/libc/gen/t_syslog");
59 }
60
ATF_TP_ADD_TCS(tp)61 ATF_TP_ADD_TCS(tp)
62 {
63
64 ATF_TP_ADD_TC(tp, syslog_pthread);
65 ATF_TP_ADD_TC(tp, syslog_invalid_priority);
66
67 return atf_no_error();
68 }
69