summaryrefslogtreecommitdiffstats
path: root/contrib/atf/atf-c
diff options
context:
space:
mode:
authorjmmv <jmmv@FreeBSD.org>2014-02-14 19:33:16 +0000
committerjmmv <jmmv@FreeBSD.org>2014-02-14 19:33:16 +0000
commit3000aef4b44bdeb9b83e0df3facbc6a75f8da412 (patch)
tree12192b0e3ae6cc3f8047467370fbd632a6788123 /contrib/atf/atf-c
parente21b440a4ce43fd31d59cd278801c727e21d3f2b (diff)
parent14f39fed9fe557bdd640e02d9abbe2e695400d9e (diff)
downloadFreeBSD-src-3000aef4b44bdeb9b83e0df3facbc6a75f8da412.zip
FreeBSD-src-3000aef4b44bdeb9b83e0df3facbc6a75f8da412.tar.gz
MFV: Import atf-0.20.
Diffstat (limited to 'contrib/atf/atf-c')
-rw-r--r--contrib/atf/atf-c/config.c4
-rw-r--r--contrib/atf/atf-c/config_test.c4
-rw-r--r--contrib/atf/atf-c/detail/test_helpers.c20
-rw-r--r--contrib/atf/atf-c/detail/test_helpers.h17
-rw-r--r--contrib/atf/atf-c/detail/version_helper.c43
-rw-r--r--contrib/atf/atf-c/macros_test.c29
-rw-r--r--contrib/atf/atf-c/pkg_config_test.sh8
7 files changed, 83 insertions, 42 deletions
diff --git a/contrib/atf/atf-c/config.c b/contrib/atf/atf-c/config.c
index f1047f0..3c2c8a9 100644
--- a/contrib/atf/atf-c/config.c
+++ b/contrib/atf/atf-c/config.c
@@ -45,18 +45,14 @@ static struct var {
const char *value;
bool can_be_empty;
} vars[] = {
- { "atf_arch", ATF_ARCH, NULL, false, },
{ "atf_build_cc", ATF_BUILD_CC, NULL, false, },
{ "atf_build_cflags", ATF_BUILD_CFLAGS, NULL, true, },
{ "atf_build_cpp", ATF_BUILD_CPP, NULL, false, },
{ "atf_build_cppflags", ATF_BUILD_CPPFLAGS, NULL, true, },
{ "atf_build_cxx", ATF_BUILD_CXX, NULL, false, },
{ "atf_build_cxxflags", ATF_BUILD_CXXFLAGS, NULL, true, },
- { "atf_confdir", ATF_CONFDIR, NULL, false, },
{ "atf_includedir", ATF_INCLUDEDIR, NULL, false, },
- { "atf_libdir", ATF_LIBDIR, NULL, false, },
{ "atf_libexecdir", ATF_LIBEXECDIR, NULL, false, },
- { "atf_machine", ATF_MACHINE, NULL, false, },
{ "atf_pkgdatadir", ATF_PKGDATADIR, NULL, false, },
{ "atf_shell", ATF_SHELL, NULL, false, },
{ "atf_workdir", ATF_WORKDIR, NULL, false, },
diff --git a/contrib/atf/atf-c/config_test.c b/contrib/atf/atf-c/config_test.c
index a21d68f..aed1814 100644
--- a/contrib/atf/atf-c/config_test.c
+++ b/contrib/atf/atf-c/config_test.c
@@ -44,18 +44,14 @@ static struct varnames {
const char *uc;
bool can_be_empty;
} all_vars[] = {
- { "atf_arch", "ATF_ARCH", false },
{ "atf_build_cc", "ATF_BUILD_CC", false },
{ "atf_build_cflags", "ATF_BUILD_CFLAGS", true },
{ "atf_build_cpp", "ATF_BUILD_CPP", false },
{ "atf_build_cppflags", "ATF_BUILD_CPPFLAGS", true },
{ "atf_build_cxx", "ATF_BUILD_CXX", false },
{ "atf_build_cxxflags", "ATF_BUILD_CXXFLAGS", true },
- { "atf_confdir", "ATF_CONFDIR", false },
{ "atf_includedir", "ATF_INCLUDEDIR", false },
- { "atf_libdir", "ATF_LIBDIR", false },
{ "atf_libexecdir", "ATF_LIBEXECDIR", false },
- { "atf_machine", "ATF_MACHINE", false },
{ "atf_pkgdatadir", "ATF_PKGDATADIR", false },
{ "atf_shell", "ATF_SHELL", false },
{ "atf_workdir", "ATF_WORKDIR", false },
diff --git a/contrib/atf/atf-c/detail/test_helpers.c b/contrib/atf/atf-c/detail/test_helpers.c
index aa64c12..aacbf32 100644
--- a/contrib/atf/atf-c/detail/test_helpers.c
+++ b/contrib/atf/atf-c/detail/test_helpers.c
@@ -43,10 +43,8 @@
#include "process.h"
#include "test_helpers.h"
-static
-void
-build_check_c_o_aux(const char *path, const char *failmsg,
- const bool expect_pass)
+bool
+build_check_c_o(const char *path)
{
bool success;
atf_dynstr_t iflag;
@@ -63,20 +61,19 @@ build_check_c_o_aux(const char *path, const char *failmsg,
atf_dynstr_fini(&iflag);
- if ((expect_pass && !success) || (!expect_pass && success))
- atf_tc_fail("%s", failmsg);
+ return success;
}
-void
-build_check_c_o(const atf_tc_t *tc, const char *sfile, const char *failmsg,
- const bool expect_pass)
+bool
+build_check_c_o_srcdir(const atf_tc_t *tc, const char *sfile)
{
atf_fs_path_t path;
RE(atf_fs_path_init_fmt(&path, "%s/%s",
atf_tc_get_config_var(tc, "srcdir"), sfile));
- build_check_c_o_aux(atf_fs_path_cstring(&path), failmsg, expect_pass);
+ const bool result = build_check_c_o(atf_fs_path_cstring(&path));
atf_fs_path_fini(&path);
+ return result;
}
void
@@ -93,7 +90,8 @@ header_check(const char *hdrname)
snprintf(failmsg, sizeof(failmsg),
"Header check failed; %s is not self-contained", hdrname);
- build_check_c_o_aux("test.c", failmsg, true);
+ if (!build_check_c_o("test.c"))
+ atf_tc_fail("%s", failmsg);
}
void
diff --git a/contrib/atf/atf-c/detail/test_helpers.h b/contrib/atf/atf-c/detail/test_helpers.h
index 5df034f..3037ba4 100644
--- a/contrib/atf/atf-c/detail/test_helpers.h
+++ b/contrib/atf/atf-c/detail/test_helpers.h
@@ -63,21 +63,12 @@ struct atf_fs_path;
} \
ATF_TC_BODY(name, tc) \
{ \
- build_check_c_o(tc, sfile, failmsg, true); \
+ if (!build_check_c_o_srcdir(tc, sfile)) \
+ atf_tc_fail("%s", failmsg); \
}
-#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);
+bool build_check_c_o(const char *);
+bool build_check_c_o_srcdir(const atf_tc_t *, const char *);
void header_check(const char *);
void get_process_helpers_path(const atf_tc_t *, const bool,
struct atf_fs_path *);
diff --git a/contrib/atf/atf-c/detail/version_helper.c b/contrib/atf/atf-c/detail/version_helper.c
new file mode 100644
index 0000000..b75ff36
--- /dev/null
+++ b/contrib/atf/atf-c/detail/version_helper.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2014 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#if defined(HAVE_CONFIG_H)
+#include "bconfig.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(void)
+{
+ printf("%s\n", PACKAGE_VERSION);
+ return EXIT_SUCCESS;
+}
diff --git a/contrib/atf/atf-c/macros_test.c b/contrib/atf/atf-c/macros_test.c
index f077a27..adfc77c 100644
--- a/contrib/atf/atf-c/macros_test.c
+++ b/contrib/atf/atf-c/macros_test.c
@@ -843,11 +843,30 @@ 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");
+
+ATF_TC(detect_unused_tests);
+ATF_TC_HEAD(detect_unused_tests, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Tests that defining an unused test case raises a "
+ "warning (and thus an error)");
+}
+ATF_TC_BODY(detect_unused_tests, tc)
+{
+ const char* validate_compiler =
+ "struct test_struct { int dummy; };\n"
+ "#define define_unused static struct test_struct unused\n"
+ "define_unused;\n";
+
+ atf_utils_create_file("compiler_test.c", "%s", validate_compiler);
+ if (build_check_c_o("compiler_test.c"))
+ atf_tc_expect_fail("Compiler does not raise a warning on an unused "
+ "static global variable declared by a macro");
+
+ if (build_check_c_o_srcdir(tc, "unused_test.c"))
+ atf_tc_fail("Build of unused_test.c passed; unused test cases are "
+ "not properly detected");
+}
/* ---------------------------------------------------------------------
* Main.
diff --git a/contrib/atf/atf-c/pkg_config_test.sh b/contrib/atf/atf-c/pkg_config_test.sh
index efeae83..d913ec9 100644
--- a/contrib/atf/atf-c/pkg_config_test.sh
+++ b/contrib/atf/atf-c/pkg_config_test.sh
@@ -43,10 +43,8 @@ require_pc()
check_version()
{
- atf_check -s eq:0 -o save:stdout -e empty -x \
- "atf-version | head -n 1 | cut -d ' ' -f 4"
- ver1=$(cat stdout)
- echo "Version reported by atf-version: ${ver1}"
+ ver1=$($(atf_get_srcdir)/detail/version_helper)
+ echo "Version reported by builtin PACKAGE_VERSION: ${ver1}"
atf_check -s eq:0 -o save:stdout -e empty pkg-config --modversion "${1}"
ver2=$(cat stdout)
@@ -59,7 +57,7 @@ atf_test_case version
version_head()
{
atf_set "descr" "Checks that the version in atf-c is correct"
- atf_set "require.progs" "atf-version pkg-config"
+ atf_set "require.progs" "pkg-config"
}
version_body()
{
OpenPOWER on IntegriCloud