1 /* $NetBSD: t_dummy.c,v 1.6 2016/11/19 15:13:46 kamil Exp $ */
4 * Copyright (c) 2016 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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 the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
30 #include <sys/cdefs.h>
31 __RCSID("$NetBSD: t_dummy.c,v 1.6 2016/11/19 15:13:46 kamil Exp $");
34 #include <pthread_dbg.h>
41 ATF_TC_HEAD(dummy1, tc)
44 atf_tc_set_md_var(tc, "descr",
45 "Asserts that dummy lookup functions stop td_open() with failure");
48 ATF_TC_BODY(dummy1, tc)
51 struct td_proc_callbacks_t dummy_callbacks;
54 dummy_callbacks.proc_read = dummy_proc_read;
55 dummy_callbacks.proc_write = dummy_proc_write;
56 dummy_callbacks.proc_lookup = dummy_proc_lookup;
57 dummy_callbacks.proc_regsize = dummy_proc_regsize;
58 dummy_callbacks.proc_getregs = dummy_proc_getregs;
59 dummy_callbacks.proc_setregs = dummy_proc_setregs;
61 ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_ERR);
65 ATF_TC_HEAD(dummy2, tc)
68 atf_tc_set_md_var(tc, "descr",
69 "Asserts that td_open() for basic proc_{read,write,lookup} works");
72 ATF_TC_BODY(dummy2, tc)
74 struct td_proc_callbacks_t dummy_callbacks;
77 dummy_callbacks.proc_read = basic_proc_read;
78 dummy_callbacks.proc_write = basic_proc_write;
79 dummy_callbacks.proc_lookup = basic_proc_lookup;
80 dummy_callbacks.proc_regsize = dummy_proc_regsize;
81 dummy_callbacks.proc_getregs = dummy_proc_getregs;
82 dummy_callbacks.proc_setregs = dummy_proc_setregs;
84 printf("Calling td_open(3)\n");
85 ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
87 printf("Calling td_close(3)\n");
88 ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
92 ATF_TC_HEAD(dummy3, tc)
95 atf_tc_set_md_var(tc, "descr",
96 "Asserts that calling twice td_open() for the same process fails");
99 ATF_TC_BODY(dummy3, tc)
101 struct td_proc_callbacks_t dummy_callbacks;
105 dummy_callbacks.proc_read = basic_proc_read;
106 dummy_callbacks.proc_write = basic_proc_write;
107 dummy_callbacks.proc_lookup = basic_proc_lookup;
108 dummy_callbacks.proc_regsize = dummy_proc_regsize;
109 dummy_callbacks.proc_getregs = dummy_proc_getregs;
110 dummy_callbacks.proc_setregs = dummy_proc_setregs;
112 printf("Calling td_open(3) for the first time - expecting success\n");
113 ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta1) == TD_ERR_OK);
115 printf("Calling td_open(3) for the first time - expecting in-use\n");
116 ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta2) ==
119 printf("Calling td_close(3) for the first successful call\n");
120 ATF_REQUIRE(td_close(main_ta1) == TD_ERR_OK);
126 ATF_TP_ADD_TC(tp, dummy1);
127 ATF_TP_ADD_TC(tp, dummy2);
128 ATF_TP_ADD_TC(tp, dummy3);
130 return atf_no_error();