Path: blob/main/contrib/atf/atf-c++/macros_test.cpp
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#include "atf-c++/macros.hpp"2627extern "C" {28#include <fcntl.h>29#include <unistd.h>30}3132#include <cerrno>33#include <cstdlib>34#include <iostream>35#include <stdexcept>3637#include <atf-c++.hpp>3839#include "atf-c++/detail/fs.hpp"40#include "atf-c++/detail/process.hpp"41#include "atf-c++/detail/sanity.hpp"42#include "atf-c++/detail/test_helpers.hpp"43#include "atf-c++/detail/text.hpp"44#include "atf-c++/utils.hpp"4546// ------------------------------------------------------------------------47// Auxiliary functions.48// ------------------------------------------------------------------------4950static51void52create_ctl_file(const char *name)53{54ATF_REQUIRE(open(name, O_CREAT | O_WRONLY | O_TRUNC, 0644) != -1);55}5657// ------------------------------------------------------------------------58// Auxiliary test cases.59// ------------------------------------------------------------------------6061ATF_TEST_CASE(h_pass);62ATF_TEST_CASE_HEAD(h_pass)63{64set_md_var("descr", "Helper test case");65}66ATF_TEST_CASE_BODY(h_pass)67{68create_ctl_file("before");69ATF_PASS();70create_ctl_file("after");71}7273ATF_TEST_CASE(h_fail);74ATF_TEST_CASE_HEAD(h_fail)75{76set_md_var("descr", "Helper test case");77}78ATF_TEST_CASE_BODY(h_fail)79{80create_ctl_file("before");81ATF_FAIL("Failed on purpose");82create_ctl_file("after");83}8485ATF_TEST_CASE(h_skip);86ATF_TEST_CASE_HEAD(h_skip)87{88set_md_var("descr", "Helper test case");89}90ATF_TEST_CASE_BODY(h_skip)91{92create_ctl_file("before");93ATF_SKIP("Skipped on purpose");94create_ctl_file("after");95}9697ATF_TEST_CASE(h_require);98ATF_TEST_CASE_HEAD(h_require)99{100set_md_var("descr", "Helper test case");101}102ATF_TEST_CASE_BODY(h_require)103{104bool condition = atf::text::to_bool(get_config_var("condition"));105106create_ctl_file("before");107ATF_REQUIRE(condition);108create_ctl_file("after");109}110111ATF_TEST_CASE(h_require_eq);112ATF_TEST_CASE_HEAD(h_require_eq)113{114set_md_var("descr", "Helper test case");115}116ATF_TEST_CASE_BODY(h_require_eq)117{118long v1 = atf::text::to_type< long >(get_config_var("v1"));119long v2 = atf::text::to_type< long >(get_config_var("v2"));120121create_ctl_file("before");122ATF_REQUIRE_EQ(v1, v2);123create_ctl_file("after");124}125126ATF_TEST_CASE(h_require_in);127ATF_TEST_CASE_HEAD(h_require_in)128{129set_md_var("descr", "Helper test case");130}131ATF_TEST_CASE_BODY(h_require_in)132{133const std::string element = get_config_var("value");134135std::set< std::string > collection;136collection.insert("foo");137collection.insert("bar");138collection.insert("baz");139140create_ctl_file("before");141ATF_REQUIRE_IN(element, collection);142create_ctl_file("after");143}144145ATF_TEST_CASE(h_require_match);146ATF_TEST_CASE_HEAD(h_require_match)147{148set_md_var("descr", "Helper test case");149}150ATF_TEST_CASE_BODY(h_require_match)151{152const std::string regexp = get_config_var("regexp");153const std::string string = get_config_var("string");154155create_ctl_file("before");156ATF_REQUIRE_MATCH(regexp, string);157create_ctl_file("after");158}159160ATF_TEST_CASE(h_require_not_in);161ATF_TEST_CASE_HEAD(h_require_not_in)162{163set_md_var("descr", "Helper test case");164}165ATF_TEST_CASE_BODY(h_require_not_in)166{167const std::string element = get_config_var("value");168169std::set< std::string > collection;170collection.insert("foo");171collection.insert("bar");172collection.insert("baz");173174create_ctl_file("before");175ATF_REQUIRE_NOT_IN(element, collection);176create_ctl_file("after");177}178179ATF_TEST_CASE(h_require_throw);180ATF_TEST_CASE_HEAD(h_require_throw)181{182set_md_var("descr", "Helper test case");183}184ATF_TEST_CASE_BODY(h_require_throw)185{186create_ctl_file("before");187188if (get_config_var("what") == "throw_int")189ATF_REQUIRE_THROW(std::runtime_error, if (1) throw int(5));190else if (get_config_var("what") == "throw_rt")191ATF_REQUIRE_THROW(std::runtime_error,192if (1) throw std::runtime_error("e"));193else if (get_config_var("what") == "no_throw_rt")194ATF_REQUIRE_THROW(std::runtime_error,195if (0) throw std::runtime_error("e"));196197create_ctl_file("after");198}199200ATF_TEST_CASE(h_require_throw_re);201ATF_TEST_CASE_HEAD(h_require_throw_re)202{203set_md_var("descr", "Helper test case");204}205ATF_TEST_CASE_BODY(h_require_throw_re)206{207create_ctl_file("before");208209if (get_config_var("what") == "throw_int")210ATF_REQUIRE_THROW_RE(std::runtime_error, "5", if (1) throw int(5));211else if (get_config_var("what") == "throw_rt_match")212ATF_REQUIRE_THROW_RE(std::runtime_error, "foo.*baz",213if (1) throw std::runtime_error("a foo bar baz"));214else if (get_config_var("what") == "throw_rt_no_match")215ATF_REQUIRE_THROW_RE(std::runtime_error, "foo.*baz",216if (1) throw std::runtime_error("baz foo bar a"));217else if (get_config_var("what") == "no_throw_rt")218ATF_REQUIRE_THROW_RE(std::runtime_error, "e",219if (0) throw std::runtime_error("e"));220221create_ctl_file("after");222}223224static int225errno_fail_stub(const int raised_errno)226{227errno = raised_errno;228return -1;229}230231static int232errno_ok_stub(void)233{234return 0;235}236237ATF_TEST_CASE(h_check_errno);238ATF_TEST_CASE_HEAD(h_check_errno)239{240set_md_var("descr", "Helper test case");241}242ATF_TEST_CASE_BODY(h_check_errno)243{244create_ctl_file("before");245246if (get_config_var("what") == "no_error")247ATF_CHECK_ERRNO(-1, errno_ok_stub() == -1);248else if (get_config_var("what") == "errno_ok")249ATF_CHECK_ERRNO(2, errno_fail_stub(2) == -1);250else if (get_config_var("what") == "errno_fail")251ATF_CHECK_ERRNO(3, errno_fail_stub(4) == -1);252else253UNREACHABLE;254255create_ctl_file("after");256}257258ATF_TEST_CASE(h_require_errno);259ATF_TEST_CASE_HEAD(h_require_errno)260{261set_md_var("descr", "Helper test case");262}263ATF_TEST_CASE_BODY(h_require_errno)264{265create_ctl_file("before");266267if (get_config_var("what") == "no_error")268ATF_REQUIRE_ERRNO(-1, errno_ok_stub() == -1);269else if (get_config_var("what") == "errno_ok")270ATF_REQUIRE_ERRNO(2, errno_fail_stub(2) == -1);271else if (get_config_var("what") == "errno_fail")272ATF_REQUIRE_ERRNO(3, errno_fail_stub(4) == -1);273else274UNREACHABLE;275276create_ctl_file("after");277}278279// ------------------------------------------------------------------------280// Test cases for the macros.281// ------------------------------------------------------------------------282283ATF_TEST_CASE(pass);284ATF_TEST_CASE_HEAD(pass)285{286set_md_var("descr", "Tests the ATF_PASS macro");287}288ATF_TEST_CASE_BODY(pass)289{290ATF_TEST_CASE_USE(h_pass);291run_h_tc< ATF_TEST_CASE_NAME(h_pass) >();292ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));293ATF_REQUIRE(atf::fs::exists(atf::fs::path("before")));294ATF_REQUIRE(!atf::fs::exists(atf::fs::path("after")));295}296297ATF_TEST_CASE(fail);298ATF_TEST_CASE_HEAD(fail)299{300set_md_var("descr", "Tests the ATF_FAIL macro");301}302ATF_TEST_CASE_BODY(fail)303{304ATF_TEST_CASE_USE(h_fail);305run_h_tc< ATF_TEST_CASE_NAME(h_fail) >();306ATF_REQUIRE(atf::utils::grep_file("^failed: Failed on purpose", "result"));307ATF_REQUIRE(atf::fs::exists(atf::fs::path("before")));308ATF_REQUIRE(!atf::fs::exists(atf::fs::path("after")));309}310311ATF_TEST_CASE(skip);312ATF_TEST_CASE_HEAD(skip)313{314set_md_var("descr", "Tests the ATF_SKIP macro");315}316ATF_TEST_CASE_BODY(skip)317{318ATF_TEST_CASE_USE(h_skip);319run_h_tc< ATF_TEST_CASE_NAME(h_skip) >();320ATF_REQUIRE(atf::utils::grep_file("^skipped: Skipped on purpose",321"result"));322ATF_REQUIRE(atf::fs::exists(atf::fs::path("before")));323ATF_REQUIRE(!atf::fs::exists(atf::fs::path("after")));324}325326ATF_TEST_CASE(require);327ATF_TEST_CASE_HEAD(require)328{329set_md_var("descr", "Tests the ATF_REQUIRE macro");330}331ATF_TEST_CASE_BODY(require)332{333struct test {334const char *cond;335bool ok;336} *t, tests[] = {337{ "false", false },338{ "true", true },339{ NULL, false }340};341342const atf::fs::path before("before");343const atf::fs::path after("after");344345for (t = &tests[0]; t->cond != NULL; t++) {346atf::tests::vars_map config;347config["condition"] = t->cond;348349std::cout << "Checking with a " << t->cond << " value\n";350351ATF_TEST_CASE_USE(h_require);352run_h_tc< ATF_TEST_CASE_NAME(h_require) >(config);353354ATF_REQUIRE(atf::fs::exists(before));355if (t->ok) {356ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));357ATF_REQUIRE(atf::fs::exists(after));358} else {359ATF_REQUIRE(atf::utils::grep_file(360"^failed: .*condition not met", "result"));361ATF_REQUIRE(!atf::fs::exists(after));362}363364atf::fs::remove(before);365if (t->ok)366atf::fs::remove(after);367}368}369370ATF_TEST_CASE(require_eq);371ATF_TEST_CASE_HEAD(require_eq)372{373set_md_var("descr", "Tests the ATF_REQUIRE_EQ macro");374}375ATF_TEST_CASE_BODY(require_eq)376{377struct test {378const char *v1;379const char *v2;380bool ok;381} *t, tests[] = {382{ "1", "1", true },383{ "1", "2", false },384{ "2", "1", false },385{ "2", "2", true },386{ NULL, NULL, false }387};388389const atf::fs::path before("before");390const atf::fs::path after("after");391392for (t = &tests[0]; t->v1 != NULL; t++) {393atf::tests::vars_map config;394config["v1"] = t->v1;395config["v2"] = t->v2;396397std::cout << "Checking with " << t->v1 << ", " << t->v2398<< " and expecting " << (t->ok ? "true" : "false")399<< "\n";400401ATF_TEST_CASE_USE(h_require_eq);402run_h_tc< ATF_TEST_CASE_NAME(h_require_eq) >(config);403404ATF_REQUIRE(atf::fs::exists(before));405if (t->ok) {406ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));407ATF_REQUIRE(atf::fs::exists(after));408} else {409ATF_REQUIRE(atf::utils::grep_file("^failed: .*v1 != v2", "result"));410ATF_REQUIRE(!atf::fs::exists(after));411}412413atf::fs::remove(before);414if (t->ok)415atf::fs::remove(after);416}417}418419ATF_TEST_CASE(require_in);420ATF_TEST_CASE_HEAD(require_in)421{422set_md_var("descr", "Tests the ATF_REQUIRE_IN macro");423}424ATF_TEST_CASE_BODY(require_in)425{426struct test {427const char *value;428bool ok;429} *t, tests[] = {430{ "foo", true },431{ "bar", true },432{ "baz", true },433{ "xxx", false },434{ "fooa", false },435{ "foo ", false },436{ NULL, false }437};438439const atf::fs::path before("before");440const atf::fs::path after("after");441442for (t = &tests[0]; t->value != NULL; t++) {443atf::tests::vars_map config;444config["value"] = t->value;445446ATF_TEST_CASE_USE(h_require_in);447run_h_tc< ATF_TEST_CASE_NAME(h_require_in) >(config);448449ATF_REQUIRE(atf::fs::exists(before));450if (t->ok) {451ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));452ATF_REQUIRE(atf::fs::exists(after));453} else {454ATF_REQUIRE(atf::utils::grep_file("^failed: ", "result"));455ATF_REQUIRE(!atf::fs::exists(after));456}457458atf::fs::remove(before);459if (t->ok)460atf::fs::remove(after);461}462}463464ATF_TEST_CASE(require_match);465ATF_TEST_CASE_HEAD(require_match)466{467set_md_var("descr", "Tests the ATF_REQUIRE_MATCH macro");468}469ATF_TEST_CASE_BODY(require_match)470{471struct test {472const char *regexp;473const char *string;474bool ok;475} *t, tests[] = {476{ "foo.*bar", "this is a foo, bar, baz", true },477{ "bar.*baz", "this is a baz, bar, foo", false },478{ NULL, NULL, false }479};480481const atf::fs::path before("before");482const atf::fs::path after("after");483484for (t = &tests[0]; t->regexp != NULL; t++) {485atf::tests::vars_map config;486config["regexp"] = t->regexp;487config["string"] = t->string;488489std::cout << "Checking with " << t->regexp << ", " << t->string490<< " and expecting " << (t->ok ? "true" : "false")491<< "\n";492493ATF_TEST_CASE_USE(h_require_match);494run_h_tc< ATF_TEST_CASE_NAME(h_require_match) >(config);495496ATF_REQUIRE(atf::fs::exists(before));497if (t->ok) {498ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));499ATF_REQUIRE(atf::fs::exists(after));500} else {501ATF_REQUIRE(atf::utils::grep_file("^failed: ", "result"));502ATF_REQUIRE(!atf::fs::exists(after));503}504505atf::fs::remove(before);506if (t->ok)507atf::fs::remove(after);508}509}510511ATF_TEST_CASE(require_not_in);512ATF_TEST_CASE_HEAD(require_not_in)513{514set_md_var("descr", "Tests the ATF_REQUIRE_NOT_IN macro");515}516ATF_TEST_CASE_BODY(require_not_in)517{518struct test {519const char *value;520bool ok;521} *t, tests[] = {522{ "foo", false },523{ "bar", false },524{ "baz", false },525{ "xxx", true },526{ "fooa", true },527{ "foo ", true },528{ NULL, false }529};530531const atf::fs::path before("before");532const atf::fs::path after("after");533534for (t = &tests[0]; t->value != NULL; t++) {535atf::tests::vars_map config;536config["value"] = t->value;537538ATF_TEST_CASE_USE(h_require_not_in);539run_h_tc< ATF_TEST_CASE_NAME(h_require_not_in) >(config);540541ATF_REQUIRE(atf::fs::exists(before));542if (t->ok) {543ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));544ATF_REQUIRE(atf::fs::exists(after));545} else {546ATF_REQUIRE(atf::utils::grep_file("^failed: ", "result"));547ATF_REQUIRE(!atf::fs::exists(after));548}549550atf::fs::remove(before);551if (t->ok)552atf::fs::remove(after);553}554}555556ATF_TEST_CASE(require_throw);557ATF_TEST_CASE_HEAD(require_throw)558{559set_md_var("descr", "Tests the ATF_REQUIRE_THROW macro");560}561ATF_TEST_CASE_BODY(require_throw)562{563struct test {564const char *what;565bool ok;566const char *msg;567} *t, tests[] = {568{ "throw_int", false, "unexpected error" },569{ "throw_rt", true, NULL },570{ "no_throw_rt", false, "did not throw" },571{ NULL, false, NULL }572};573574const atf::fs::path before("before");575const atf::fs::path after("after");576577for (t = &tests[0]; t->what != NULL; t++) {578atf::tests::vars_map config;579config["what"] = t->what;580581std::cout << "Checking with " << t->what << " and expecting "582<< (t->ok ? "true" : "false") << "\n";583584ATF_TEST_CASE_USE(h_require_throw);585run_h_tc< ATF_TEST_CASE_NAME(h_require_throw) >(config);586587ATF_REQUIRE(atf::fs::exists(before));588if (t->ok) {589ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));590ATF_REQUIRE(atf::fs::exists(after));591} else {592std::cout << "Checking that message contains '" << t->msg593<< "'\n";594std::string exp_result = std::string("^failed: .*") + t->msg;595ATF_REQUIRE(atf::utils::grep_file(exp_result.c_str(), "result"));596ATF_REQUIRE(!atf::fs::exists(after));597}598599atf::fs::remove(before);600if (t->ok)601atf::fs::remove(after);602}603}604605ATF_TEST_CASE(require_throw_re);606ATF_TEST_CASE_HEAD(require_throw_re)607{608set_md_var("descr", "Tests the ATF_REQUIRE_THROW_RE macro");609}610ATF_TEST_CASE_BODY(require_throw_re)611{612struct test {613const char *what;614bool ok;615const char *msg;616} *t, tests[] = {617{ "throw_int", false, "unexpected error" },618{ "throw_rt_match", true, NULL },619{ "throw_rt_no_match", false,620"threw.*runtime_error\\(baz foo bar a\\).*"621"does not match 'foo\\.\\*baz'" },622{ "no_throw_rt", false, "did not throw" },623{ NULL, false, NULL }624};625626const atf::fs::path before("before");627const atf::fs::path after("after");628629for (t = &tests[0]; t->what != NULL; t++) {630atf::tests::vars_map config;631config["what"] = t->what;632633std::cout << "Checking with " << t->what << " and expecting "634<< (t->ok ? "true" : "false") << "\n";635636ATF_TEST_CASE_USE(h_require_throw_re);637run_h_tc< ATF_TEST_CASE_NAME(h_require_throw_re) >(config);638639ATF_REQUIRE(atf::fs::exists(before));640if (t->ok) {641ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));642ATF_REQUIRE(atf::fs::exists(after));643} else {644std::cout << "Checking that message contains '" << t->msg645<< "'\n";646std::string exp_result = std::string("^failed: .*") + t->msg;647ATF_REQUIRE(atf::utils::grep_file(exp_result.c_str(), "result"));648ATF_REQUIRE(!atf::fs::exists(after));649}650651atf::fs::remove(before);652if (t->ok)653atf::fs::remove(after);654}655}656657ATF_TEST_CASE(check_errno);658ATF_TEST_CASE_HEAD(check_errno)659{660set_md_var("descr", "Tests the ATF_CHECK_ERRNO macro");661}662ATF_TEST_CASE_BODY(check_errno)663{664struct test {665const char *what;666bool ok;667const char *msg;668} *t, tests[] = {669{ "no_error", false,670"Expected true value in errno_ok_stub\\(\\) == -1" },671{ "errno_ok", true, NULL },672{ "errno_fail", false,673"Expected errno 3, got 4, in errno_fail_stub\\(4\\) == -1" },674{ NULL, false, NULL }675};676677const atf::fs::path before("before");678const atf::fs::path after("after");679680for (t = &tests[0]; t->what != NULL; t++) {681atf::tests::vars_map config;682config["what"] = t->what;683684ATF_TEST_CASE_USE(h_check_errno);685run_h_tc< ATF_TEST_CASE_NAME(h_check_errno) >(config);686687ATF_REQUIRE(atf::fs::exists(before));688ATF_REQUIRE(atf::fs::exists(after));689690if (t->ok) {691ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));692} else {693ATF_REQUIRE(atf::utils::grep_file("^failed", "result"));694695std::string exp_result = "macros_test.cpp:[0-9]+: " +696std::string(t->msg) + "$";697ATF_REQUIRE(atf::utils::grep_file(exp_result.c_str(), "stderr"));698}699700atf::fs::remove(before);701atf::fs::remove(after);702}703}704705ATF_TEST_CASE(require_errno);706ATF_TEST_CASE_HEAD(require_errno)707{708set_md_var("descr", "Tests the ATF_REQUIRE_ERRNO macro");709}710ATF_TEST_CASE_BODY(require_errno)711{712struct test {713const char *what;714bool ok;715const char *msg;716} *t, tests[] = {717{ "no_error", false,718"Expected true value in errno_ok_stub\\(\\) == -1" },719{ "errno_ok", true, NULL },720{ "errno_fail", false,721"Expected errno 3, got 4, in errno_fail_stub\\(4\\) == -1" },722{ NULL, false, NULL }723};724725const atf::fs::path before("before");726const atf::fs::path after("after");727728for (t = &tests[0]; t->what != NULL; t++) {729atf::tests::vars_map config;730config["what"] = t->what;731732ATF_TEST_CASE_USE(h_require_errno);733run_h_tc< ATF_TEST_CASE_NAME(h_require_errno) >(config);734735ATF_REQUIRE(atf::fs::exists(before));736if (t->ok) {737ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));738ATF_REQUIRE(atf::fs::exists(after));739} else {740std::string exp_result = "^failed: .*macros_test.cpp:[0-9]+: " +741std::string(t->msg) + "$";742ATF_REQUIRE(atf::utils::grep_file(exp_result.c_str(), "result"));743744ATF_REQUIRE(!atf::fs::exists(after));745}746747atf::fs::remove(before);748if (t->ok)749atf::fs::remove(after);750}751}752753// ------------------------------------------------------------------------754// Tests cases for the header file.755// ------------------------------------------------------------------------756757BUILD_TC(use, "macros_hpp_test.cpp",758"Tests that the macros provided by the atf-c++/macros.hpp file "759"do not cause syntax errors when used",760"Build of macros_hpp_test.cpp failed; some macros in "761"atf-c++/macros.hpp are broken");762763ATF_TEST_CASE(detect_unused_tests);764ATF_TEST_CASE_HEAD(detect_unused_tests)765{766set_md_var("descr",767"Tests that defining an unused test case raises a warning (and "768"thus an error)");769}770ATF_TEST_CASE_BODY(detect_unused_tests)771{772const char* validate_compiler =773"class test_class { public: int dummy; };\n"774"#define define_unused static test_class unused\n"775"define_unused;\n";776777atf::utils::create_file("compiler_test.cpp", validate_compiler);778if (build_check_cxx_o("compiler_test.cpp"))779expect_fail("Compiler does not raise a warning on an unused "780"static global variable declared by a macro");781782if (build_check_cxx_o_srcdir(*this, "unused_test.cpp"))783ATF_FAIL("Build of unused_test.cpp passed; unused test cases are "784"not properly detected");785}786787// ------------------------------------------------------------------------788// Main.789// ------------------------------------------------------------------------790791ATF_INIT_TEST_CASES(tcs)792{793// Add the test cases for the macros.794ATF_ADD_TEST_CASE(tcs, pass);795ATF_ADD_TEST_CASE(tcs, fail);796ATF_ADD_TEST_CASE(tcs, skip);797ATF_ADD_TEST_CASE(tcs, check_errno);798ATF_ADD_TEST_CASE(tcs, require);799ATF_ADD_TEST_CASE(tcs, require_eq);800ATF_ADD_TEST_CASE(tcs, require_in);801ATF_ADD_TEST_CASE(tcs, require_match);802ATF_ADD_TEST_CASE(tcs, require_not_in);803ATF_ADD_TEST_CASE(tcs, require_throw);804ATF_ADD_TEST_CASE(tcs, require_throw_re);805ATF_ADD_TEST_CASE(tcs, require_errno);806807// Add the test cases for the header file.808ATF_ADD_TEST_CASE(tcs, use);809ATF_ADD_TEST_CASE(tcs, detect_unused_tests);810}811812813