Import atf 0.16:

Experimental version released on July 10th, 2012.

* Added a --enable-tools flag to configure to request the build of the
  deprecated ATF tools, whose build is now disabled by default.  In order
  to continue running tests, you should migrate to Kyua instead of enabling
  the build of the deprecated tools.  The kyua-atf-compat package provides
  transitional compatibility versions of atf-run and atf-report built on
  top of Kyua.

* Tweaked the ATF_TEST_CASE macro of atf-c++ so that the compiler can
  detect defined but unused test cases.

* PR bin/45859: Fixed some XSLT bugs that resulted in the tc-time and
  tp-time XML tags leaking into the generated HTML file.  Also improved
  the CSS file slightly to correct alignment and color issues with the
  timestamps column.

* Optimized atf-c++/macros.hpp so that GNU G++ consumes less memory during
  compilation with GNU G++.

* Flipped the default to building shared libraries for atf-c and atf-c++,
  and started versioning them.  As a side-effect, this removes the
  --enable-unstable-shared flag from configure that appears to not work any
  more (under NetBSD).  Additionally, some distributions require the use of
  shared libraries for proper dependency tracking (e.g. Fedora), so it is
  better if we do the right versioning upstream.

* Project hosting moved from an adhoc solution (custom web site and
  Monotone repository) to Google Code (standard wiki and Git).  ATF now
  lives in a subcomponent of the Kyua project.
This commit is contained in:
jmmv 2012-07-11 22:37:05 +00:00
parent c951f9d446
commit 4e0366868d
16 changed files with 295 additions and 88 deletions

View File

@ -6,6 +6,7 @@ tp: atf-c
tp: atf-c++
tp: atf-sh
tp: test-programs
tp: atf-config
tp: atf-report
tp: atf-run
tp-glob: atf-config*
tp-glob: atf-report*
tp-glob: atf-run*

View File

@ -6,6 +6,13 @@ include("atf-c/Kyuafile")
include("atf-c++/Kyuafile")
include("atf-sh/Kyuafile")
include("test-programs/Kyuafile")
include("atf-config/Kyuafile")
include("atf-report/Kyuafile")
include("atf-run/Kyuafile")
if fs.exists("atf-config/Kyuafile") then
include("atf-config/Kyuafile")
end
if fs.exists("atf-report/Kyuafile") then
include("atf-report/Kyuafile")
end
if fs.exists("atf-run/Kyuafile") then
include("atf-run/Kyuafile")
end

View File

@ -2,6 +2,41 @@ Major changes between releases Automated Testing Framework
===========================================================================
Changes in version 0.16
***********************
Experimental version released on July 10th, 2012.
* Added a --enable-tools flag to configure to request the build of the
deprecated ATF tools, whose build is now disabled by default. In order
to continue running tests, you should migrate to Kyua instead of enabling
the build of the deprecated tools. The kyua-atf-compat package provides
transitional compatibility versions of atf-run and atf-report built on
top of Kyua.
* Tweaked the ATF_TEST_CASE macro of atf-c++ so that the compiler can
detect defined but unused test cases.
* PR bin/45859: Fixed some XSLT bugs that resulted in the tc-time and
tp-time XML tags leaking into the generated HTML file. Also improved
the CSS file slightly to correct alignment and color issues with the
timestamps column.
* Optimized atf-c++/macros.hpp so that GNU G++ consumes less memory during
compilation with GNU G++.
* Flipped the default to building shared libraries for atf-c and atf-c++,
and started versioning them. As a side-effect, this removes the
--enable-unstable-shared flag from configure that appears to not work any
more (under NetBSD). Additionally, some distributions require the use of
shared libraries for proper dependency tracking (e.g. Fedora), so it is
better if we do the right versioning upstream.
* Project hosting moved from an adhoc solution (custom web site and
Monotone repository) to Google Code (standard wiki and Git). ATF now
lives in a subcomponent of the Kyua project.
Changes in version 0.15
***********************

View File

@ -26,7 +26,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd December 10, 2010
.Dd January 21, 2012
.Dt ATF-C++-API 3
.Os
.Sh NAME
@ -48,6 +48,8 @@
.Nm ATF_TEST_CASE_BODY ,
.Nm ATF_TEST_CASE_CLEANUP ,
.Nm ATF_TEST_CASE_HEAD ,
.Nm ATF_TEST_CASE_NAME ,
.Nm ATF_TEST_CASE_USE ,
.Nm ATF_TEST_CASE_WITH_CLEANUP ,
.Nm ATF_TEST_CASE_WITHOUT_HEAD ,
.Nd C++ API to write ATF-based test programs
@ -71,6 +73,8 @@
.Fn ATF_TEST_CASE_BODY "name"
.Fn ATF_TEST_CASE_CLEANUP "name"
.Fn ATF_TEST_CASE_HEAD "name"
.Fn ATF_TEST_CASE_NAME "name"
.Fn ATF_TEST_CASE_USE "name"
.Fn ATF_TEST_CASE_WITH_CLEANUP "name"
.Fn ATF_TEST_CASE_WITHOUT_HEAD "name"
.Sh DESCRIPTION
@ -170,6 +174,18 @@ and
macros, all of which take the test case's name.
Following each of these, a block of code is expected, surrounded by the
opening and closing brackets.
.Pp
Additionally, the
.Fn ATF_TEST_CASE_NAME
macro can be used to obtain the name of the class corresponding to a
particular test case, as the name is internally manged by the library to
prevent clashes with other user identifiers.
Similarly, the
.Fn ATF_TEST_CASE_USE
macro can be executed on a particular test case to mark it as "used" and
thus prevent compiler warnings regarding unused symbols.
Note that
.Em you should never have to use these macros during regular operation.
.Ss Program initialization
The library provides a way to easily define the test program's
.Fn main

View File

@ -191,10 +191,12 @@ ATF_TEST_CASE_HEAD(build_c_o)
}
ATF_TEST_CASE_BODY(build_c_o)
{
ATF_TEST_CASE_USE(h_build_c_o_ok);
run_h_tc< ATF_TEST_CASE_NAME(h_build_c_o_ok) >();
ATF_REQUIRE(grep_file("stdout", "-o test.o"));
ATF_REQUIRE(grep_file("stdout", "-c test.c"));
ATF_TEST_CASE_USE(h_build_c_o_fail);
run_h_tc< ATF_TEST_CASE_NAME(h_build_c_o_fail) >();
ATF_REQUIRE(grep_file("stdout", "-o test.o"));
ATF_REQUIRE(grep_file("stdout", "-c test.c"));
@ -209,11 +211,13 @@ ATF_TEST_CASE_HEAD(build_cpp)
}
ATF_TEST_CASE_BODY(build_cpp)
{
ATF_TEST_CASE_USE(h_build_cpp_ok);
run_h_tc< ATF_TEST_CASE_NAME(h_build_cpp_ok) >();
ATF_REQUIRE(grep_file("stdout", "-o.*test.p"));
ATF_REQUIRE(grep_file("stdout", "test.c"));
ATF_REQUIRE(grep_file("test.p", "foo bar"));
ATF_TEST_CASE_USE(h_build_cpp_fail);
run_h_tc< ATF_TEST_CASE_NAME(h_build_cpp_fail) >();
ATF_REQUIRE(grep_file("stdout", "-o test.p"));
ATF_REQUIRE(grep_file("stdout", "test.c"));
@ -228,10 +232,12 @@ ATF_TEST_CASE_HEAD(build_cxx_o)
}
ATF_TEST_CASE_BODY(build_cxx_o)
{
ATF_TEST_CASE_USE(h_build_cxx_o_ok);
run_h_tc< ATF_TEST_CASE_NAME(h_build_cxx_o_ok) >();
ATF_REQUIRE(grep_file("stdout", "-o test.o"));
ATF_REQUIRE(grep_file("stdout", "-c test.cpp"));
ATF_TEST_CASE_USE(h_build_cxx_o_fail);
run_h_tc< ATF_TEST_CASE_NAME(h_build_cxx_o_fail) >();
ATF_REQUIRE(grep_file("stdout", "-o test.o"));
ATF_REQUIRE(grep_file("stdout", "-c test.cpp"));

View File

@ -45,23 +45,27 @@ extern "C" {
#include "test_helpers.hpp"
void
build_check_cxx_o_aux(const atf::fs::path& sfile, const char* failmsg)
build_check_cxx_o_aux(const atf::fs::path& sfile, const char* failmsg,
const bool expect_pass)
{
std::vector< std::string > optargs;
optargs.push_back("-I" + atf::config::get("atf_includedir"));
optargs.push_back("-Wall");
optargs.push_back("-Werror");
if (!atf::check::build_cxx_o(sfile.str(), "test.o",
atf::process::argv_array(optargs)))
const bool result = atf::check::build_cxx_o(
sfile.str(), "test.o", atf::process::argv_array(optargs));
if ((expect_pass && !result) || (!expect_pass && result))
ATF_FAIL(failmsg);
}
void
build_check_cxx_o(const atf::tests::tc& tc, const char* sfile,
const char* failmsg)
const char* failmsg, const bool expect_pass)
{
const atf::fs::path sfilepath =
atf::fs::path(tc.get_config_var("srcdir")) / sfile;
build_check_cxx_o_aux(sfilepath, failmsg);
build_check_cxx_o_aux(sfilepath, failmsg, expect_pass);
}
void
@ -74,7 +78,7 @@ header_check(const char *hdrname)
const std::string failmsg = std::string("Header check failed; ") +
hdrname + " is not self-contained";
build_check_cxx_o_aux(atf::fs::path("test.c"), failmsg.c_str());
build_check_cxx_o_aux(atf::fs::path("test.c"), failmsg.c_str(), true);
}
atf::fs::path

View File

@ -64,7 +64,18 @@
} \
ATF_TEST_CASE_BODY(name) \
{ \
build_check_cxx_o(*this, sfile, failmsg); \
build_check_cxx_o(*this, sfile, failmsg, true); \
}
#define BUILD_TC_FAIL(name, sfile, descr, failmsg) \
ATF_TEST_CASE(name); \
ATF_TEST_CASE_HEAD(name) \
{ \
set_md_var("descr", descr); \
} \
ATF_TEST_CASE_BODY(name) \
{ \
build_check_cxx_o(*this, sfile, failmsg, false); \
}
namespace atf {
@ -74,7 +85,7 @@ class tc;
}
void header_check(const char*);
void build_check_cxx_o(const atf::tests::tc&, const char*, const char*);
void build_check_cxx_o(const atf::tests::tc&, const char*, const char*, bool);
atf::fs::path get_process_helpers_path(const atf::tests::tc&);
bool grep_file(const char*, const char*);
bool grep_string(const std::string&, const char*);

View File

@ -36,31 +36,48 @@
#include <atf-c++/tests.hpp>
// Do not define inline methods for the test case classes. Doing so
// significantly increases the memory requirements of GNU G++ during
// compilation.
#define ATF_TEST_CASE_WITHOUT_HEAD(name) \
namespace { \
class atfu_tc_ ## name : public atf::tests::tc { \
void body(void) const; \
public: \
atfu_tc_ ## name(void) : atf::tests::tc(#name, false) {} \
};
atfu_tc_ ## name(void); \
}; \
static atfu_tc_ ## name* atfu_tcptr_ ## name; \
atfu_tc_ ## name::atfu_tc_ ## name(void) : atf::tests::tc(#name, false) {} \
}
#define ATF_TEST_CASE(name) \
namespace { \
class atfu_tc_ ## name : public atf::tests::tc { \
void head(void); \
void body(void) const; \
public: \
atfu_tc_ ## name(void) : atf::tests::tc(#name, false) {} \
};
atfu_tc_ ## name(void); \
}; \
static atfu_tc_ ## name* atfu_tcptr_ ## name; \
atfu_tc_ ## name::atfu_tc_ ## name(void) : atf::tests::tc(#name, false) {} \
}
#define ATF_TEST_CASE_WITH_CLEANUP(name) \
namespace { \
class atfu_tc_ ## name : public atf::tests::tc { \
void head(void); \
void body(void) const; \
void cleanup(void) const; \
public: \
atfu_tc_ ## name(void) : atf::tests::tc(#name, true) {} \
};
atfu_tc_ ## name(void); \
}; \
static atfu_tc_ ## name* atfu_tcptr_ ## name; \
atfu_tc_ ## name::atfu_tc_ ## name(void) : atf::tests::tc(#name, true) {} \
}
#define ATF_TEST_CASE_NAME(name) atfu_tc_ ## name
#define ATF_TEST_CASE_USE(name) (atfu_tcptr_ ## name) = NULL
#define ATF_TEST_CASE_HEAD(name) \
void \
@ -198,8 +215,8 @@
#define ATF_ADD_TEST_CASE(tcs, tcname) \
do { \
atf::tests::tc* tcptr = new atfu_tc_ ## tcname(); \
(tcs).push_back(tcptr); \
atfu_tcptr_ ## tcname = new atfu_tc_ ## tcname(); \
(tcs).push_back(atfu_tcptr_ ## tcname); \
} while (0);
#endif // !defined(_ATF_CXX_MACROS_HPP_)

View File

@ -106,6 +106,7 @@ ATF_TEST_CASE(TEST_MACRO_1);
ATF_TEST_CASE_HEAD(TEST_MACRO_1) { }
ATF_TEST_CASE_BODY(TEST_MACRO_1) { }
void instantiate_1(void) {
ATF_TEST_CASE_USE(TEST_MACRO_1);
atf::tests::tc* the_test = new ATF_TEST_CASE_NAME(TEST_MACRO_1)();
delete the_test;
}
@ -114,12 +115,16 @@ ATF_TEST_CASE_HEAD(TEST_MACRO_2) { }
ATF_TEST_CASE_BODY(TEST_MACRO_2) { }
ATF_TEST_CASE_CLEANUP(TEST_MACRO_2) { }
void instatiate_2(void) {
ATF_TEST_CASE_USE(TEST_MACRO_2);
atf::tests::tc* the_test = new ATF_TEST_CASE_NAME(TEST_MACRO_2)();
delete the_test;
}
ATF_TEST_CASE_WITH_CLEANUP(TEST_MACRO_3);
ATF_TEST_CASE_HEAD(TEST_MACRO_3) { }
ATF_TEST_CASE_BODY(TEST_MACRO_3) { }
ATF_TEST_CASE_CLEANUP(TEST_MACRO_3) { }
void instatiate_3(void) {
ATF_TEST_CASE_USE(TEST_MACRO_3);
atf::tests::tc* the_test = new ATF_TEST_CASE_NAME(TEST_MACRO_3)();
delete the_test;
}

View File

@ -289,6 +289,7 @@ ATF_TEST_CASE_HEAD(pass)
}
ATF_TEST_CASE_BODY(pass)
{
ATF_TEST_CASE_USE(h_pass);
run_h_tc< ATF_TEST_CASE_NAME(h_pass) >();
ATF_REQUIRE(grep_file("result", "^passed"));
ATF_REQUIRE(atf::fs::exists(atf::fs::path("before")));
@ -302,6 +303,7 @@ ATF_TEST_CASE_HEAD(fail)
}
ATF_TEST_CASE_BODY(fail)
{
ATF_TEST_CASE_USE(h_fail);
run_h_tc< ATF_TEST_CASE_NAME(h_fail) >();
ATF_REQUIRE(grep_file("result", "^failed: Failed on purpose"));
ATF_REQUIRE(atf::fs::exists(atf::fs::path("before")));
@ -315,6 +317,7 @@ ATF_TEST_CASE_HEAD(skip)
}
ATF_TEST_CASE_BODY(skip)
{
ATF_TEST_CASE_USE(h_skip);
run_h_tc< ATF_TEST_CASE_NAME(h_skip) >();
ATF_REQUIRE(grep_file("result", "^skipped: Skipped on purpose"));
ATF_REQUIRE(atf::fs::exists(atf::fs::path("before")));
@ -346,6 +349,7 @@ ATF_TEST_CASE_BODY(require)
std::cout << "Checking with a " << t->cond << " value\n";
ATF_TEST_CASE_USE(h_require);
run_h_tc< ATF_TEST_CASE_NAME(h_require) >(config);
ATF_REQUIRE(atf::fs::exists(before));
@ -394,6 +398,7 @@ ATF_TEST_CASE_BODY(require_eq)
<< " and expecting " << (t->ok ? "true" : "false")
<< "\n";
ATF_TEST_CASE_USE(h_require_eq);
run_h_tc< ATF_TEST_CASE_NAME(h_require_eq) >(config);
ATF_REQUIRE(atf::fs::exists(before));
@ -438,6 +443,7 @@ ATF_TEST_CASE_BODY(require_in)
atf::tests::vars_map config;
config["value"] = t->value;
ATF_TEST_CASE_USE(h_require_in);
run_h_tc< ATF_TEST_CASE_NAME(h_require_in) >(config);
ATF_REQUIRE(atf::fs::exists(before));
@ -484,6 +490,7 @@ ATF_TEST_CASE_BODY(require_match)
<< " and expecting " << (t->ok ? "true" : "false")
<< "\n";
ATF_TEST_CASE_USE(h_require_match);
run_h_tc< ATF_TEST_CASE_NAME(h_require_match) >(config);
ATF_REQUIRE(atf::fs::exists(before));
@ -528,6 +535,7 @@ ATF_TEST_CASE_BODY(require_not_in)
atf::tests::vars_map config;
config["value"] = t->value;
ATF_TEST_CASE_USE(h_require_not_in);
run_h_tc< ATF_TEST_CASE_NAME(h_require_not_in) >(config);
ATF_REQUIRE(atf::fs::exists(before));
@ -573,6 +581,7 @@ ATF_TEST_CASE_BODY(require_throw)
std::cout << "Checking with " << t->what << " and expecting "
<< (t->ok ? "true" : "false") << "\n";
ATF_TEST_CASE_USE(h_require_throw);
run_h_tc< ATF_TEST_CASE_NAME(h_require_throw) >(config);
ATF_REQUIRE(atf::fs::exists(before));
@ -607,8 +616,9 @@ ATF_TEST_CASE_BODY(require_throw_re)
} *t, tests[] = {
{ "throw_int", false, "unexpected error" },
{ "throw_rt_match", true, NULL },
{ "throw_rt_no_match", true, "threw.*runtime_error(baz foo bar a).*"
"does not match 'a foo bar baz'" },
{ "throw_rt_no_match", false,
"threw.*runtime_error\\(baz foo bar a\\).*"
"does not match 'foo\\.\\*baz'" },
{ "no_throw_rt", false, "did not throw" },
{ NULL, false, NULL }
};
@ -623,7 +633,8 @@ ATF_TEST_CASE_BODY(require_throw_re)
std::cout << "Checking with " << t->what << " and expecting "
<< (t->ok ? "true" : "false") << "\n";
run_h_tc< ATF_TEST_CASE_NAME(h_require_throw) >(config);
ATF_TEST_CASE_USE(h_require_throw_re);
run_h_tc< ATF_TEST_CASE_NAME(h_require_throw_re) >(config);
ATF_REQUIRE(atf::fs::exists(before));
if (t->ok) {
@ -670,6 +681,7 @@ ATF_TEST_CASE_BODY(check_errno)
atf::tests::vars_map config;
config["what"] = t->what;
ATF_TEST_CASE_USE(h_check_errno);
run_h_tc< ATF_TEST_CASE_NAME(h_check_errno) >(config);
ATF_REQUIRE(atf::fs::exists(before));
@ -717,6 +729,7 @@ ATF_TEST_CASE_BODY(require_errno)
atf::tests::vars_map config;
config["what"] = t->what;
ATF_TEST_CASE_USE(h_require_errno);
run_h_tc< ATF_TEST_CASE_NAME(h_require_errno) >(config);
ATF_REQUIRE(atf::fs::exists(before));
@ -747,6 +760,11 @@ BUILD_TC(use, "macros_hpp_test.cpp",
"do not cause syntax errors when used",
"Build of macros_hpp_test.cpp failed; some macros in "
"atf-c++/macros.hpp are broken");
BUILD_TC_FAIL(detect_unused_tests, "unused_test.cpp",
"Tests that defining an unused test case raises a warning (and thus "
"an error)",
"Build of unused_test.cpp passed; unused test cases are not properly "
"detected");
// ------------------------------------------------------------------------
// Main.
@ -771,4 +789,5 @@ ATF_INIT_TEST_CASES(tcs)
// Add the test cases for the header file.
ATF_ADD_TEST_CASE(tcs, include);
ATF_ADD_TEST_CASE(tcs, use);
ATF_ADD_TEST_CASE(tcs, detect_unused_tests);
}

View File

@ -0,0 +1,52 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2012 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.
//
#include <atf-c++/macros.hpp>
ATF_TEST_CASE(this_is_used);
ATF_TEST_CASE_HEAD(this_is_used)
{
}
ATF_TEST_CASE_BODY(this_is_used)
{
}
ATF_TEST_CASE(this_is_unused);
ATF_TEST_CASE_HEAD(this_is_unused)
{
}
ATF_TEST_CASE_BODY(this_is_unused)
{
}
ATF_INIT_TEST_CASES(tcs)
{
ATF_ADD_TEST_CASE(tcs, this_is_used);
//ATF_ADD_TEST_CASE(tcs, this_is_unused);
}

View File

@ -63,10 +63,21 @@ struct atf_fs_path;
} \
ATF_TC_BODY(name, tc) \
{ \
build_check_c_o(tc, sfile, failmsg); \
build_check_c_o(tc, sfile, failmsg, true); \
}
void build_check_c_o(const atf_tc_t *, const char *, const char *);
#define BUILD_TC_FAIL(name, sfile, descr, failmsg) \
ATF_TC(name); \
ATF_TC_HEAD(name, tc) \
{ \
atf_tc_set_md_var(tc, "descr", descr); \
} \
ATF_TC_BODY(name, tc) \
{ \
build_check_c_o(tc, sfile, failmsg, false); \
}
void build_check_c_o(const atf_tc_t *, const char *, const char *, const bool);
void header_check(const char *);
void get_process_helpers_path(const atf_tc_t *, const bool,
struct atf_fs_path *);

View File

@ -31,6 +31,7 @@
#define ATF_C_MACROS_H
#include <atf-c/defs.h>
#include <atf-c/error.h>
#include <atf-c/tc.h>
#include <atf-c/tp.h>
#include <atf-c/utils.h>

View File

@ -749,6 +749,11 @@ BUILD_TC(use, "macros_h_test.c",
"do not cause syntax errors when used",
"Build of macros_h_test.c failed; some macros in atf-c/macros.h "
"are broken");
BUILD_TC_FAIL(detect_unused_tests, "unused_test.c",
"Tests that defining an unused test case raises a warning (and thus "
"an error)",
"Build of unused_test.c passed; unused test cases are not properly "
"detected");
/* ---------------------------------------------------------------------
* Main.
@ -771,6 +776,7 @@ ATF_TP_ADD_TCS(tp)
/* Add the test cases for the header file. */
ATF_TP_ADD_TC(tp, include);
ATF_TP_ADD_TC(tp, use);
ATF_TP_ADD_TC(tp, detect_unused_tests);
return atf_no_error();
}

View File

@ -0,0 +1,56 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2012 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.
*/
#include <atf-c/macros.h>
ATF_TC(this_is_used);
ATF_TC_HEAD(this_is_used, tc)
{
atf_tc_set_md_var(tc, "descr", "A test case that is not referenced");
}
ATF_TC_BODY(this_is_used, tc)
{
}
ATF_TC(this_is_unused);
ATF_TC_HEAD(this_is_unused, tc)
{
atf_tc_set_md_var(tc, "descr", "A test case that is referenced");
}
ATF_TC_BODY(this_is_unused, tc)
{
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, this_is_used);
/* ATF_TP_ADD_TC(tp, this_is_unused); */
return atf_no_error();
}

View File

@ -37,7 +37,7 @@ set -e
Prog_Name=${0##*/}
MTN=
GIT=
ROOT=
#
@ -49,57 +49,10 @@ err() {
}
#
# call_mtn args
# call_git args
#
call_mtn() {
${MTN} --root=${ROOT} "${@}"
}
# extract_certs rev
#
extract_certs() {
call_mtn automate certs ${1} | awk '
BEGIN {
current_cert = ""
}
/^[ \t]*name "([^"]*)"[ \t]*$/ {
current_cert = substr($2, 2, length($2) - 2)
next
}
/^[ \t]*value "([^"]*)"[ \t]*$/ {
value = substr($2, 2, length($2) - 2)
if (current_cert == "branch") {
print "rev_branch=\"" value "\""
} else if (current_cert == "date") {
print "rev_date=\"" value "\""
}
next
}
'
}
#
# get_rev_info_into_vars
#
# Sets the following variables to describe the current revision of the tree:
# rev_base_id: The base revision identifier.
# rev_branch: The branch name.
# rev_modified: true if the tree has been locally modified.
# rev_date: The date of the revision.
#
get_rev_info_into_vars() {
rev_base_id=$(call_mtn automate get_base_revision_id)
if call_mtn status | grep "no changes" >/dev/null; then
rev_modified=false
else
rev_modified=true
fi
# The following defines several rev_* variables.
eval $(extract_certs ${rev_base_id})
call_git() {
( cd "${ROOT}" && "${GIT}" "${@}" )
}
#
@ -115,16 +68,23 @@ generate_from_dist() {
}
#
# generate_from_mtn revfile
# generate_from_git revfile
#
generate_from_mtn() {
generate_from_git() {
revfile=${1}
get_rev_info_into_vars
rev_base_id=$(call_git rev-parse HEAD)
rev_branch=$(call_git branch | grep '^\* ' | cut -d ' ' -f 2-)
rev_date=$(call_git log -1 | grep '^Date:' | sed -e 's,^Date:[ \t]*,,')
if [ -z "$(call_git status -s)" ]; then
rev_modified=false
else
rev_modified=true
fi
>${revfile}
echo "#define PACKAGE_REVISION_TYPE_MTN" >>${revfile}
echo "#define PACKAGE_REVISION_TYPE_GIT" >>${revfile}
echo "#define PACKAGE_REVISION_BRANCH \"${rev_branch}\"" >>${revfile}
echo "#define PACKAGE_REVISION_BASE \"${rev_base_id}\"" >>${revfile}
@ -144,10 +104,10 @@ generate_from_mtn() {
main() {
outfile=
version=
while getopts :m:r:o:v: arg; do
while getopts :g:r:o:v: arg; do
case ${arg} in
m)
MTN=${OPTARG}
g)
GIT=${OPTARG}
;;
o)
outfile=${OPTARG}
@ -170,8 +130,8 @@ main() {
[ -n "${version}" ] || \
err "Must specify a version number with -v"
if [ -n "${MTN}" -a -d ${ROOT}/_MTN ]; then
generate_from_mtn ${outfile}
if [ -n "${GIT}" -a -d ${ROOT}/.git ]; then
generate_from_git ${outfile}
else
generate_from_dist ${outfile} ${version}
fi