//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ------------------------------------------------------------------------
// Helper tests for "t_config".
// ------------------------------------------------------------------------
ATF_TEST_CASE(config_unset);
ATF_TEST_CASE_HEAD(config_unset)
{
set_md_var("descr", "Helper test case for the t_config test program");
}
ATF_TEST_CASE_BODY(config_unset)
{
ATF_REQUIRE(!has_config_var("test"));
}
ATF_TEST_CASE(config_empty);
ATF_TEST_CASE_HEAD(config_empty)
{
set_md_var("descr", "Helper test case for the t_config test program");
}
ATF_TEST_CASE_BODY(config_empty)
{
ATF_REQUIRE_EQ(get_config_var("test"), "");
}
ATF_TEST_CASE(config_value);
ATF_TEST_CASE_HEAD(config_value)
{
set_md_var("descr", "Helper test case for the t_config test program");
}
ATF_TEST_CASE_BODY(config_value)
{
ATF_REQUIRE_EQ(get_config_var("test"), "foo");
}
ATF_TEST_CASE(config_multi_value);
ATF_TEST_CASE_HEAD(config_multi_value)
{
set_md_var("descr", "Helper test case for the t_config test program");
}
ATF_TEST_CASE_BODY(config_multi_value)
{
ATF_REQUIRE_EQ(get_config_var("test"), "foo bar");
}
// ------------------------------------------------------------------------
// Helper tests for "t_expect".
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Helper tests for "t_srcdir".
// ------------------------------------------------------------------------
ATF_TEST_CASE(srcdir_exists);
ATF_TEST_CASE_HEAD(srcdir_exists)
{
set_md_var("descr", "Helper test case for the t_srcdir test program");
}
ATF_TEST_CASE_BODY(srcdir_exists)
{
if (!atf::fs::exists(atf::fs::path(get_config_var("srcdir")) /
"datafile"))
ATF_FAIL("Cannot find datafile");
}
// ------------------------------------------------------------------------
// Helper tests for "t_result".
// ------------------------------------------------------------------------
ATF_TEST_CASE(result_newlines_fail);
ATF_TEST_CASE_HEAD(result_newlines_fail)
{
set_md_var("descr", "Helper test case for the t_result test program");
}
ATF_TEST_CASE_BODY(result_newlines_fail)
{
ATF_FAIL("First line\nSecond line");
}
ATF_TEST_CASE(result_newlines_skip);
ATF_TEST_CASE_HEAD(result_newlines_skip)
{
set_md_var("descr", "Helper test case for the t_result test program");
}
ATF_TEST_CASE_BODY(result_newlines_skip)
{
ATF_SKIP("First line\nSecond line");
}