Path: blob/main/contrib/atf/atf-c/detail/test_helpers.h
39507 views
/* Copyright (c) 2008 The NetBSD Foundation, Inc.1* All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11*12* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND13* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,14* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF15* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16* IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY17* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE19* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS20* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER21* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR22* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN23* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */2425#if defined(ATF_C_DETAIL_TEST_HELPERS_H)26# error "Cannot include test_helpers.h more than once."27#else28# define ATF_C_DETAIL_TEST_HELPERS_H29#endif3031#include <stdbool.h>3233#include <atf-c.h>3435#include <atf-c/detail/env.h>36#include <atf-c/error_fwd.h>37#include <atf-c/tc.h>3839struct atf_dynstr;40struct atf_fs_path;4142#define CE(stm) ATF_CHECK(!atf_is_error(stm))43#define RE(stm) ATF_REQUIRE(!atf_is_error(stm))4445#define HEADER_TC(name, hdrname) \46ATF_TC(name); \47ATF_TC_HEAD(name, tc) \48{ \49const char *cc; \50atf_tc_set_md_var(tc, "descr", "Tests that the " hdrname " file can " \51"be included on its own, without any prerequisites"); \52cc = atf_env_get_with_default("ATF_BUILD_CC", ATF_BUILD_CC); \53atf_tc_set_md_var(tc, "require.progs", cc); \54} \55ATF_TC_BODY(name, tc) \56{ \57header_check(hdrname); \58}5960#define BUILD_TC(name, sfile, descr, failmsg) \61ATF_TC(name); \62ATF_TC_HEAD(name, tc) \63{ \64const char *cc; \65atf_tc_set_md_var(tc, "descr", descr); \66cc = atf_env_get_with_default("ATF_BUILD_CC", ATF_BUILD_CC); \67atf_tc_set_md_var(tc, "require.progs", cc); \68} \69ATF_TC_BODY(name, tc) \70{ \71if (!build_check_c_o_srcdir(tc, sfile)) \72atf_tc_fail("%s", failmsg); \73}7475bool build_check_c_o(const char *);76bool build_check_c_o_srcdir(const atf_tc_t *, const char *);77void header_check(const char *);78void get_process_helpers_path(const atf_tc_t *, const bool,79struct atf_fs_path *);80bool read_line(int, struct atf_dynstr *);81void run_h_tc(atf_tc_t *, const char *, const char *, const char *);828384