1275988Sngie/* Copyright (c) 2008 The NetBSD Foundation, Inc.
2240116Smarcel * All rights reserved.
3240116Smarcel *
4240116Smarcel * Redistribution and use in source and binary forms, with or without
5240116Smarcel * modification, are permitted provided that the following conditions
6240116Smarcel * are met:
7240116Smarcel * 1. Redistributions of source code must retain the above copyright
8240116Smarcel *    notice, this list of conditions and the following disclaimer.
9240116Smarcel * 2. Redistributions in binary form must reproduce the above copyright
10240116Smarcel *    notice, this list of conditions and the following disclaimer in the
11240116Smarcel *    documentation and/or other materials provided with the distribution.
12240116Smarcel *
13240116Smarcel * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
14240116Smarcel * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
15240116Smarcel * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16240116Smarcel * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17240116Smarcel * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
18240116Smarcel * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19240116Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20240116Smarcel * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21240116Smarcel * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22240116Smarcel * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23240116Smarcel * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24275988Sngie * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */
25240116Smarcel
26275988Sngie#if defined(ATF_C_DETAIL_TEST_HELPERS_H)
27240116Smarcel#   error "Cannot include test_helpers.h more than once."
28240116Smarcel#else
29275988Sngie#   define ATF_C_DETAIL_TEST_HELPERS_H
30240116Smarcel#endif
31240116Smarcel
32240116Smarcel#include <stdbool.h>
33240116Smarcel
34275988Sngie#include <atf-c.h>
35240116Smarcel
36275988Sngie#include <atf-c/error_fwd.h>
37275988Sngie#include <atf-c/tc.h>
38275988Sngie
39240116Smarcelstruct atf_dynstr;
40240116Smarcelstruct atf_fs_path;
41240116Smarcel
42240116Smarcel#define CE(stm) ATF_CHECK(!atf_is_error(stm))
43240116Smarcel#define RE(stm) ATF_REQUIRE(!atf_is_error(stm))
44240116Smarcel
45240116Smarcel#define HEADER_TC(name, hdrname) \
46240116Smarcel    ATF_TC(name); \
47240116Smarcel    ATF_TC_HEAD(name, tc) \
48240116Smarcel    { \
49240116Smarcel        atf_tc_set_md_var(tc, "descr", "Tests that the " hdrname " file can " \
50240116Smarcel            "be included on its own, without any prerequisites"); \
51240116Smarcel    } \
52240116Smarcel    ATF_TC_BODY(name, tc) \
53240116Smarcel    { \
54240116Smarcel        header_check(hdrname); \
55240116Smarcel    }
56240116Smarcel
57240116Smarcel#define BUILD_TC(name, sfile, descr, failmsg) \
58240116Smarcel    ATF_TC(name); \
59240116Smarcel    ATF_TC_HEAD(name, tc) \
60240116Smarcel    { \
61240116Smarcel        atf_tc_set_md_var(tc, "descr", descr); \
62240116Smarcel    } \
63240116Smarcel    ATF_TC_BODY(name, tc) \
64240116Smarcel    { \
65262855Sjmmv        if (!build_check_c_o_srcdir(tc, sfile)) \
66262855Sjmmv            atf_tc_fail("%s", failmsg); \
67240116Smarcel    }
68240116Smarcel
69262855Sjmmvbool build_check_c_o(const char *);
70262855Sjmmvbool build_check_c_o_srcdir(const atf_tc_t *, const char *);
71240116Smarcelvoid header_check(const char *);
72240116Smarcelvoid get_process_helpers_path(const atf_tc_t *, const bool,
73240116Smarcel                              struct atf_fs_path *);
74240116Smarcelbool read_line(int, struct atf_dynstr *);
75240116Smarcelvoid run_h_tc(atf_tc_t *, const char *, const char *, const char *);
76