Path: blob/main/contrib/kyua/drivers/list_tests_helpers.cpp
39478 views
// Copyright 2011 The Kyua Authors.1// All rights reserved.2//3// Redistribution and use in source and binary forms, with or without4// modification, are permitted provided that the following conditions are5// met:6//7// * Redistributions of source code must retain the above copyright8// notice, this list of conditions and the following disclaimer.9// * Redistributions in binary form must reproduce the above copyright10// notice, this list of conditions and the following disclaimer in the11// documentation and/or other materials provided with the distribution.12// * Neither the name of Google Inc. nor the names of its contributors13// may be used to endorse or promote products derived from this software14// without specific prior written permission.15//16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2728#include <cstdlib>2930#include <atf-c++.hpp>3132#include "utils/test_utils.ipp"333435ATF_TEST_CASE(config_in_head);36ATF_TEST_CASE_HEAD(config_in_head)37{38if (has_config_var("the-variable")) {39set_md_var("descr", "the-variable is " +40get_config_var("the-variable"));41}42}43ATF_TEST_CASE_BODY(config_in_head)44{45utils::abort_without_coredump();46}474849ATF_TEST_CASE(crash_list);50ATF_TEST_CASE_HEAD(crash_list)51{52utils::abort_without_coredump();53}54ATF_TEST_CASE_BODY(crash_list)55{56utils::abort_without_coredump();57}585960ATF_TEST_CASE_WITHOUT_HEAD(no_properties);61ATF_TEST_CASE_BODY(no_properties)62{63utils::abort_without_coredump();64}656667ATF_TEST_CASE(some_properties);68ATF_TEST_CASE_HEAD(some_properties)69{70set_md_var("descr", "This is a description");71set_md_var("require.progs", "non-existent /bin/ls");72}73ATF_TEST_CASE_BODY(some_properties)74{75utils::abort_without_coredump();76}777879ATF_INIT_TEST_CASES(tcs)80{81std::string enabled;8283const char* tests = std::getenv("TESTS");84if (tests == NULL)85enabled = "config_in_head crash_list no_properties some_properties";86else87enabled = tests;8889if (enabled.find("config_in_head") != std::string::npos)90ATF_ADD_TEST_CASE(tcs, config_in_head);91if (enabled.find("crash_list") != std::string::npos)92ATF_ADD_TEST_CASE(tcs, crash_list);93if (enabled.find("no_properties") != std::string::npos)94ATF_ADD_TEST_CASE(tcs, no_properties);95if (enabled.find("some_properties") != std::string::npos)96ATF_ADD_TEST_CASE(tcs, some_properties);97}9899100