diff options
| author | Julio Merino <jmmv@FreeBSD.org> | 2014-10-30 17:14:07 +0000 |
|---|---|---|
| committer | Julio Merino <jmmv@FreeBSD.org> | 2014-10-30 17:14:07 +0000 |
| commit | 94d25974a7773307f930a633881744ad9d6d2777 (patch) | |
| tree | ad1d74d2ba71e1c54c3276bb7c67e257831ec21f /atf-c | |
| parent | 9b3afb9f3c00ca9da97167e29f437bdd3036da1a (diff) | |
Diffstat (limited to 'atf-c')
68 files changed, 547 insertions, 1067 deletions
diff --git a/atf-c/Kyuafile b/atf-c/Kyuafile index 2f3b82e100f7..40fdb9215891 100644 --- a/atf-c/Kyuafile +++ b/atf-c/Kyuafile @@ -5,7 +5,6 @@ test_suite("atf") atf_test_program{name="atf_c_test"} atf_test_program{name="build_test"} atf_test_program{name="check_test"} -atf_test_program{name="config_test"} atf_test_program{name="error_test"} atf_test_program{name="macros_test"} atf_test_program{name="pkg_config_test"} diff --git a/atf-c/Makefile.am.inc b/atf-c/Makefile.am.inc index 37d3cf79b239..bcb06da3a149 100644 --- a/atf-c/Makefile.am.inc +++ b/atf-c/Makefile.am.inc @@ -1,6 +1,3 @@ -# -# Automated Testing Framework (atf) -# # Copyright (c) 2007 The NetBSD Foundation, Inc. # All rights reserved. # @@ -25,15 +22,12 @@ # 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. -# lib_LTLIBRARIES += libatf-c.la libatf_c_la_SOURCES = atf-c/build.c \ atf-c/build.h \ atf-c/check.c \ atf-c/check.h \ - atf-c/config.c \ - atf-c/config.h \ atf-c/error.c \ atf-c/error.h \ atf-c/error_fwd.h \ @@ -50,34 +44,22 @@ libatf_c_la_CPPFLAGS = "-DATF_BUILD_CC=\"$(ATF_BUILD_CC)\"" \ "-DATF_BUILD_CPP=\"$(ATF_BUILD_CPP)\"" \ "-DATF_BUILD_CPPFLAGS=\"$(ATF_BUILD_CPPFLAGS)\"" \ "-DATF_BUILD_CXX=\"$(ATF_BUILD_CXX)\"" \ - "-DATF_BUILD_CXXFLAGS=\"$(ATF_BUILD_CXXFLAGS)\"" \ - "-DATF_INCLUDEDIR=\"$(includedir)\"" \ - "-DATF_LIBEXECDIR=\"$(libexecdir)\"" \ - "-DATF_PKGDATADIR=\"$(pkgdatadir)\"" \ - "-DATF_SHELL=\"$(ATF_SHELL)\"" \ - "-DATF_WORKDIR=\"$(ATF_WORKDIR)\"" -libatf_c_la_LDFLAGS = -version-info 0:0:0 - -# XXX For some reason, the nodist line above does not work as expected. -# Work this problem around. -dist-hook: kill-defs-h -kill-defs-h: - rm -f $(distdir)/atf-c/defs.h + "-DATF_BUILD_CXXFLAGS=\"$(ATF_BUILD_CXXFLAGS)\"" +libatf_c_la_LDFLAGS = -version-info 1:0:0 include_HEADERS += atf-c.h atf_c_HEADERS = atf-c/build.h \ atf-c/check.h \ - atf-c/config.h \ - atf-c/defs.h \ atf-c/error.h \ atf-c/error_fwd.h \ atf-c/macros.h \ atf-c/tc.h \ atf-c/tp.h \ atf-c/utils.h +nodist_atf_c_HEADERS = atf-c/defs.h atf_cdir = $(includedir)/atf-c -dist_man_MANS += atf-c/atf-c-api.3 +dist_man_MANS += atf-c/atf-c.3 atf_aclocal_DATA += atf-c/atf-common.m4 atf-c/atf-c.m4 EXTRA_DIST += atf-c/atf-common.m4 atf-c/atf-c.m4 @@ -87,12 +69,12 @@ atf_cpkgconfig_DATA = atf-c/atf-c.pc CLEANFILES += atf-c/atf-c.pc EXTRA_DIST += atf-c/atf-c.pc.in atf-c/atf-c.pc: $(srcdir)/atf-c/atf-c.pc.in Makefile - test -d atf-c || mkdir -p atf-c + $(AM_V_GEN)test -d atf-c || mkdir -p atf-c; \ sed -e 's#__ATF_VERSION__#$(PACKAGE_VERSION)#g' \ -e 's#__CC__#$(CC)#g' \ -e 's#__INCLUDEDIR__#$(includedir)#g' \ -e 's#__LIBDIR__#$(libdir)#g' \ - <$(srcdir)/atf-c/atf-c.pc.in >atf-c/atf-c.pc.tmp + <$(srcdir)/atf-c/atf-c.pc.in >atf-c/atf-c.pc.tmp; \ mv atf-c/atf-c.pc.tmp atf-c/atf-c.pc tests_atf_c_DATA = atf-c/Kyuafile \ @@ -113,10 +95,6 @@ tests_atf_c_PROGRAMS += atf-c/check_test atf_c_check_test_SOURCES = atf-c/check_test.c atf_c_check_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la -tests_atf_c_PROGRAMS += atf-c/config_test -atf_c_config_test_SOURCES = atf-c/config_test.c -atf_c_config_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la - tests_atf_c_PROGRAMS += atf-c/error_test atf_c_error_test_SOURCES = atf-c/error_test.c atf_c_error_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la @@ -129,8 +107,7 @@ tests_atf_c_SCRIPTS = atf-c/pkg_config_test CLEANFILES += atf-c/pkg_config_test EXTRA_DIST += atf-c/pkg_config_test.sh atf-c/pkg_config_test: $(srcdir)/atf-c/pkg_config_test.sh - test -d atf-c || mkdir -p atf-c - @src="$(srcdir)/atf-c/pkg_config_test.sh"; \ + $(AM_V_GEN)src="$(srcdir)/atf-c/pkg_config_test.sh"; \ dst="atf-c/pkg_config_test"; $(BUILD_SH_TP) tests_atf_c_PROGRAMS += atf-c/tc_test diff --git a/atf-c/atf-c-api.3 b/atf-c/atf-c.3 index 366caec79c8f..edb7207d7cda 100644 --- a/atf-c/atf-c-api.3 +++ b/atf-c/atf-c.3 @@ -1,6 +1,3 @@ -.\" -.\" Automated Testing Framework (atf) -.\" .\" Copyright (c) 2008 The NetBSD Foundation, Inc. .\" All rights reserved. .\" @@ -25,12 +22,11 @@ .\" 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. -.\" -.Dd November 15, 2013 -.Dt ATF-C-API 3 +.Dd October 13, 2014 +.Dt ATF-C 3 .Os .Sh NAME -.Nm atf-c-api , +.Nm atf-c , .Nm ATF_CHECK , .Nm ATF_CHECK_MSG , .Nm ATF_CHECK_EQ , @@ -93,24 +89,26 @@ .Nd C API to write ATF-based test programs .Sh SYNOPSIS .In atf-c.h +.\" NO_CHECK_STYLE_BEGIN .Fn ATF_CHECK "expression" .Fn ATF_CHECK_MSG "expression" "fail_msg_fmt" ... -.Fn ATF_CHECK_EQ "expression_1" "expression_2" -.Fn ATF_CHECK_EQ_MSG "expression_1" "expression_2" "fail_msg_fmt" ... +.Fn ATF_CHECK_EQ "expected_expression" "actual_expression" +.Fn ATF_CHECK_EQ_MSG "expected_expression" "actual_expression" "fail_msg_fmt" ... .Fn ATF_CHECK_MATCH "regexp" "string" .Fn ATF_CHECK_MATCH_MSG "regexp" "string" "fail_msg_fmt" ... .Fn ATF_CHECK_STREQ "string_1" "string_2" .Fn ATF_CHECK_STREQ_MSG "string_1" "string_2" "fail_msg_fmt" ... -.Fn ATF_CHECK_ERRNO "exp_errno" "bool_expression" +.Fn ATF_CHECK_ERRNO "expected_errno" "bool_expression" .Fn ATF_REQUIRE "expression" .Fn ATF_REQUIRE_MSG "expression" "fail_msg_fmt" ... -.Fn ATF_REQUIRE_EQ "expression_1" "expression_2" -.Fn ATF_REQUIRE_EQ_MSG "expression_1" "expression_2" "fail_msg_fmt" ... +.Fn ATF_REQUIRE_EQ "expected_expression" "actual_expression" +.Fn ATF_REQUIRE_EQ_MSG "expected_expression" "actual_expression" "fail_msg_fmt" ... .Fn ATF_REQUIRE_MATCH "regexp" "string" .Fn ATF_REQUIRE_MATCH_MSG "regexp" "string" "fail_msg_fmt" ... -.Fn ATF_REQUIRE_STREQ "string_1" "string_2" -.Fn ATF_REQUIRE_STREQ_MSG "string_1" "string_2" "fail_msg_fmt" ... -.Fn ATF_REQUIRE_ERRNO "exp_errno" "bool_expression" +.Fn ATF_REQUIRE_STREQ "expected_string" "actual_string" +.Fn ATF_REQUIRE_STREQ_MSG "expected_string" "actual_string" "fail_msg_fmt" ... +.Fn ATF_REQUIRE_ERRNO "expected_errno" "bool_expression" +.\" NO_CHECK_STYLE_END .Fn ATF_TC "name" .Fn ATF_TC_BODY "name" "tc" .Fn ATF_TC_BODY_NAME "name" @@ -409,9 +407,8 @@ If .Va exitcode is not .Sq -1 , -.Xr atf-run 1 -will validate that the exit code of the test case matches the one provided -in this call. +the runtime engine will validate that the exit code of the test case +matches the one provided in this call. Otherwise, the exact value will be ignored. .It Fn atf_tc_expect_fail "reason" "..." Any failure (be it fatal or non-fatal) raised in this mode is recorded. @@ -443,9 +440,8 @@ If .Va signo is not .Sq -1 , -.Xr atf-run 1 -will validate that the signal that terminated the test case matches the one -provided in this call. +the runtime engine will validate that the signal that terminated the test +case matches the one provided in this call. Otherwise, the exact value will be ignored. .It Fn atf_tc_expect_timeout "reason" "..." Expects the test case to execute for longer than its timeout. @@ -497,6 +493,8 @@ take an expression and fail if the expression evaluates to false. and .Fn ATF_REQUIRE_EQ_MSG take two expressions and fail if the two evaluated values are not equal. +The common style is to put the expected value in the first parameter and the +actual value in the second parameter. .Pp .Fn ATF_CHECK_MATCH , .Fn ATF_CHECK_MATCH_MSG , @@ -514,6 +512,8 @@ the string. and .Fn ATF_REQUIRE_STREQ_MSG take two strings and fail if the two are not equal character by character. +The common style is to put the expected string in the first parameter and the +actual string in the second parameter. .Pp .Fn ATF_CHECK_ERRNO and @@ -698,6 +698,25 @@ strings are prefixed with then they specify the name of the file into which to store the stdout or stderr of the subprocess, and no comparison is performed. .Ed +.Sh ENVIRONMENT +The following variables are recognized by +.Nm +but should not be overridden other than for testing purposes: +.Pp +.Bl -tag -width ATFXBUILDXCXXFLAGSXX -compact +.It Va ATF_BUILD_CC +Path to the C compiler. +.It Va ATF_BUILD_CFLAGS +C compiler flags. +.It Va ATF_BUILD_CPP +Path to the C/C++ preprocessor. +.It Va ATF_BUILD_CPPFLAGS +C/C++ preprocessor flags. +.It Va ATF_BUILD_CXX +Path to the C++ compiler. +.It Va ATF_BUILD_CXXFLAGS +C++ compiler flags. +.El .Sh EXAMPLES The following shows a complete test program with a single test case that validates the addition operator: @@ -712,13 +731,13 @@ ATF_TC_HEAD(addition, tc) } ATF_TC_BODY(addition, tc) { - ATF_CHECK_EQ(0 + 0, 0); - ATF_CHECK_EQ(0 + 1, 1); - ATF_CHECK_EQ(1 + 0, 1); + ATF_CHECK_EQ(0, 0 + 0); + ATF_CHECK_EQ(1, 0 + 1); + ATF_CHECK_EQ(1, 1 + 0); - ATF_CHECK_EQ(1 + 1, 2); + ATF_CHECK_EQ(2, 1 + 1); - ATF_CHECK_EQ(100 + 200, 300); + ATF_CHECK_EQ(300, 100 + 200); } ATF_TC(string_formatting); @@ -771,5 +790,4 @@ ATF_TP_ADD_TCS(tp) .Ed .Sh SEE ALSO .Xr atf-test-program 1 , -.Xr atf-test-case 4 , -.Xr atf 7 +.Xr atf-test-case 4 diff --git a/atf-c/atf-c.m4 b/atf-c/atf-c.m4 index d0237b848206..94288f7e16f5 100644 --- a/atf-c/atf-c.m4 +++ b/atf-c/atf-c.m4 @@ -1,6 +1,3 @@ -dnl -dnl Automated Testing Framework (atf) -dnl dnl Copyright 2011 Google Inc. dnl All rights reserved. dnl @@ -28,7 +25,6 @@ dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -dnl dnl ATF_CHECK_C([version-spec]) dnl diff --git a/atf-c/atf-common.m4 b/atf-c/atf-common.m4 index 464a5a7fa007..f8fc7e9ebba0 100644 --- a/atf-c/atf-common.m4 +++ b/atf-c/atf-common.m4 @@ -1,6 +1,3 @@ -dnl -dnl Automated Testing Framework (atf) -dnl dnl Copyright 2011 Google Inc. dnl All rights reserved. dnl @@ -28,7 +25,6 @@ dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -dnl dnl ATF_ARG_WITH dnl diff --git a/atf-c/atf_c_test.c b/atf-c/atf_c_test.c index f44d87fb09c2..eda9596bd2b8 100644 --- a/atf-c/atf_c_test.c +++ b/atf-c/atf_c_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,12 +21,11 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <atf-c.h> -#include "detail/test_helpers.h" +#include "atf-c/detail/test_helpers.h" /* --------------------------------------------------------------------- * Tests cases for the header file. diff --git a/atf-c/build.c b/atf-c/build.c index 248330373b61..c119fc97a214 100644 --- a/atf-c/build.c +++ b/atf-c/build.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2009 The NetBSD Foundation, Inc. +/* Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,31 +21,31 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/build.h" #include <stdlib.h> #include <string.h> -#include "atf-c/build.h" -#include "atf-c/config.h" +#include "atf-c/detail/env.h" +#include "atf-c/detail/sanity.h" +#include "atf-c/detail/text.h" #include "atf-c/error.h" -#include "detail/sanity.h" -#include "detail/text.h" - /* --------------------------------------------------------------------- * Auxiliary functions. * --------------------------------------------------------------------- */ static atf_error_t -append_config_var(const char *var, atf_list_t *argv) +append_config_var(const char *var, const char *default_value, atf_list_t *argv) { atf_error_t err; atf_list_t words; - err = atf_text_split(atf_config_get(var), " ", &words); + err = atf_text_split(atf_env_get_with_default(var, default_value), + " ", &words); if (atf_is_error(err)) goto out; @@ -158,15 +155,16 @@ atf_build_c_o(const char *sfile, if (atf_is_error(err)) goto out; - err = append_config_var("atf_build_cc", &argv_list); + err = append_config_var("ATF_BUILD_CC", ATF_BUILD_CC, &argv_list); if (atf_is_error(err)) goto out_list; - err = append_config_var("atf_build_cppflags", &argv_list); + err = append_config_var("ATF_BUILD_CPPFLAGS", ATF_BUILD_CPPFLAGS, + &argv_list); if (atf_is_error(err)) goto out_list; - err = append_config_var("atf_build_cflags", &argv_list); + err = append_config_var("ATF_BUILD_CFLAGS", ATF_BUILD_CFLAGS, &argv_list); if (atf_is_error(err)) goto out_list; @@ -203,11 +201,12 @@ atf_build_cpp(const char *sfile, if (atf_is_error(err)) goto out; - err = append_config_var("atf_build_cpp", &argv_list); + err = append_config_var("ATF_BUILD_CPP", ATF_BUILD_CPP, &argv_list); if (atf_is_error(err)) goto out_list; - err = append_config_var("atf_build_cppflags", &argv_list); + err = append_config_var("ATF_BUILD_CPPFLAGS", ATF_BUILD_CPPFLAGS, + &argv_list); if (atf_is_error(err)) goto out_list; @@ -248,15 +247,17 @@ atf_build_cxx_o(const char *sfile, if (atf_is_error(err)) goto out; - err = append_config_var("atf_build_cxx", &argv_list); + err = append_config_var("ATF_BUILD_CXX", ATF_BUILD_CXX, &argv_list); if (atf_is_error(err)) goto out_list; - err = append_config_var("atf_build_cppflags", &argv_list); + err = append_config_var("ATF_BUILD_CPPFLAGS", ATF_BUILD_CPPFLAGS, + &argv_list); if (atf_is_error(err)) goto out_list; - err = append_config_var("atf_build_cxxflags", &argv_list); + err = append_config_var("ATF_BUILD_CXXFLAGS", ATF_BUILD_CXXFLAGS, + &argv_list); if (atf_is_error(err)) goto out_list; diff --git a/atf-c/build.h b/atf-c/build.h index 2e981cfdadba..a263f5063bd4 100644 --- a/atf-c/build.h +++ b/atf-c/build.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2009 The NetBSD Foundation, Inc. +/* Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if !defined(ATF_C_BUILD_H) #define ATF_C_BUILD_H @@ -39,4 +35,4 @@ atf_error_t atf_build_cpp(const char *, const char *, const char *const [], atf_error_t atf_build_cxx_o(const char *, const char *, const char *const [], char ***); -#endif /* ATF_C_BUILD_H */ +#endif /* !defined(ATF_C_BUILD_H) */ diff --git a/atf-c/build_test.c b/atf-c/build_test.c index b08c9a54913c..c24b5737022f 100644 --- a/atf-c/build_test.c +++ b/atf-c/build_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2009 The NetBSD Foundation, Inc. +/* Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/build.h" #include <stdio.h> #include <stdlib.h> @@ -33,20 +31,15 @@ #include <atf-c.h> -#include "atf-c/build.h" -#include "atf-c/config.h" +#include "atf-c/detail/env.h" +#include "atf-c/detail/test_helpers.h" +#include "atf-c/h_build.h" #include "atf-c/utils.h" -#include "detail/env.h" -#include "detail/test_helpers.h" -#include "h_build.h" - /* --------------------------------------------------------------------- * Auxiliary functions. * --------------------------------------------------------------------- */ -void __atf_config_reinit(void); - static bool equal_arrays(const char *const *exp_array, char **actual_array) @@ -167,7 +160,6 @@ ATF_TC_BODY(c_o, tc) verbose_set_env("ATF_BUILD_CC", test->cc); verbose_set_env("ATF_BUILD_CFLAGS", test->cflags); verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags); - __atf_config_reinit(); { char **argv; @@ -196,7 +188,6 @@ ATF_TC_BODY(cpp, tc) verbose_set_env("ATF_BUILD_CPP", test->cpp); verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags); - __atf_config_reinit(); { char **argv; @@ -226,7 +217,6 @@ ATF_TC_BODY(cxx_o, tc) verbose_set_env("ATF_BUILD_CXX", test->cxx); verbose_set_env("ATF_BUILD_CXXFLAGS", test->cxxflags); verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags); - __atf_config_reinit(); { char **argv; @@ -242,12 +232,6 @@ ATF_TC_BODY(cxx_o, tc) } /* --------------------------------------------------------------------- - * Tests cases for the header file. - * --------------------------------------------------------------------- */ - -HEADER_TC(include, "atf-c/build.h"); - -/* --------------------------------------------------------------------- * Main. * --------------------------------------------------------------------- */ @@ -261,8 +245,5 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, cpp); ATF_TP_ADD_TC(tp, cxx_o); - /* Add the test cases for the header file. */ - ATF_TP_ADD_TC(tp, include); - return atf_no_error(); } diff --git a/atf-c/check.c b/atf-c/check.c index d7a908d3c56a..38afdf3743a6 100644 --- a/atf-c/check.c +++ b/atf-c/check.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/check.h" #include <sys/wait.h> @@ -37,18 +35,16 @@ #include <unistd.h> #include "atf-c/build.h" -#include "atf-c/check.h" -#include "atf-c/config.h" #include "atf-c/defs.h" +#include "atf-c/detail/dynstr.h" +#include "atf-c/detail/env.h" +#include "atf-c/detail/fs.h" +#include "atf-c/detail/list.h" +#include "atf-c/detail/process.h" +#include "atf-c/detail/sanity.h" #include "atf-c/error.h" #include "atf-c/utils.h" -#include "detail/dynstr.h" -#include "detail/fs.h" -#include "detail/list.h" -#include "detail/process.h" -#include "detail/sanity.h" - /* --------------------------------------------------------------------- * Auxiliary functions. * --------------------------------------------------------------------- */ @@ -60,7 +56,7 @@ create_tmpdir(atf_fs_path_t *dir) atf_error_t err; err = atf_fs_path_init_fmt(dir, "%s/check.XXXXXX", - atf_config_get("atf_workdir")); + atf_env_get_with_default("TMPDIR", "/tmp")); if (atf_is_error(err)) goto out; diff --git a/atf-c/check.h b/atf-c/check.h index f36aa3eaef79..1eb2267d7e2d 100644 --- a/atf-c/check.h +++ b/atf-c/check.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if !defined(ATF_C_CHECK_H) #define ATF_C_CHECK_H @@ -70,4 +66,4 @@ atf_error_t atf_check_build_cxx_o(const char *, const char *, bool *); atf_error_t atf_check_exec_array(const char *const *, atf_check_result_t *); -#endif /* ATF_C_CHECK_H */ +#endif /* !defined(ATF_C_CHECK_H) */ diff --git a/atf-c/check_test.c b/atf-c/check_test.c index a26e032e11c5..adaca649be25 100644 --- a/atf-c/check_test.c +++ b/atf-c/check_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/check.h" #include <fcntl.h> #include <signal.h> @@ -36,13 +34,10 @@ #include <atf-c.h> -#include "atf-c/check.h" -#include "atf-c/config.h" - -#include "detail/fs.h" -#include "detail/map.h" -#include "detail/process.h" -#include "detail/test_helpers.h" +#include "atf-c/detail/fs.h" +#include "atf-c/detail/map.h" +#include "atf-c/detail/process.h" +#include "atf-c/detail/test_helpers.h" /* --------------------------------------------------------------------- * Auxiliary functions. @@ -494,12 +489,8 @@ ATF_TC_HEAD(exec_unknown, tc) } ATF_TC_BODY(exec_unknown, tc) { - char buf[1024]; - snprintf(buf, sizeof(buf), "%s/non-existent", - atf_config_get("atf_workdir")); - const char *argv[2]; - argv[0] = buf; + argv[0] = "/foo/bar/non-existent"; argv[1] = NULL; atf_check_result_t result; @@ -510,12 +501,6 @@ ATF_TC_BODY(exec_unknown, tc) } /* --------------------------------------------------------------------- - * Tests cases for the header file. - * --------------------------------------------------------------------- */ - -HEADER_TC(include, "atf-c/check.h"); - -/* --------------------------------------------------------------------- * Main. * --------------------------------------------------------------------- */ @@ -532,8 +517,5 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, exec_umask); ATF_TP_ADD_TC(tp, exec_unknown); - /* Add the test cases for the header file. */ - ATF_TP_ADD_TC(tp, include); - return atf_no_error(); } diff --git a/atf-c/config.c b/atf-c/config.c deleted file mode 100644 index 3c2c8a9a61eb..000000000000 --- a/atf-c/config.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 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 <ctype.h> -#include <stdbool.h> -#include <stdlib.h> -#include <string.h> - -#include "atf-c/config.h" - -#include "detail/env.h" -#include "detail/sanity.h" - -static bool initialized = false; - -static struct var { - const char *name; - const char *default_value; - const char *value; - bool can_be_empty; -} vars[] = { - { "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_includedir", ATF_INCLUDEDIR, NULL, false, }, - { "atf_libexecdir", ATF_LIBEXECDIR, NULL, false, }, - { "atf_pkgdatadir", ATF_PKGDATADIR, NULL, false, }, - { "atf_shell", ATF_SHELL, NULL, false, }, - { "atf_workdir", ATF_WORKDIR, NULL, false, }, - { NULL, NULL, NULL, false, }, -}; - -/* Only used for unit testing, so this prototype is private. */ -void __atf_config_reinit(void); - -/* --------------------------------------------------------------------- - * Auxiliary functions. - * --------------------------------------------------------------------- */ - -static -char * -string_to_upper(const char *str) -{ - char *uc; - - uc = (char *)malloc(strlen(str) + 1); - if (uc != NULL) { - char *ucptr = uc; - while (*str != '\0') { - *ucptr = toupper((int)*str); - - str++; - ucptr++; - } - *ucptr = '\0'; - } - - return uc; -} - -static -void -initialize_var(struct var *var, const char *envname) -{ - PRE(var->value == NULL); - - if (atf_env_has(envname)) { - const char *val = atf_env_get(envname); - if (strlen(val) > 0 || var->can_be_empty) - var->value = val; - else - var->value = var->default_value; - } else - var->value = var->default_value; - - POST(var->value != NULL); -} - -static -void -initialize(void) -{ - struct var *var; - - PRE(!initialized); - - for (var = vars; var->name != NULL; var++) { - char *envname; - - envname = string_to_upper(var->name); - initialize_var(var, envname); - free(envname); - } - - initialized = true; -} - -/* --------------------------------------------------------------------- - * Free functions. - * --------------------------------------------------------------------- */ - -const char * -atf_config_get(const char *name) -{ - const struct var *var; - const char *value; - - if (!initialized) { - initialize(); - INV(initialized); - } - - value = NULL; - for (var = vars; value == NULL && var->name != NULL; var++) - if (strcmp(var->name, name) == 0) - value = var->value; - INV(value != NULL); - - return value; -} - -void -__atf_config_reinit(void) -{ - struct var *var; - - initialized = false; - - for (var = vars; var->name != NULL; var++) - var->value = NULL; -} diff --git a/atf-c/config.h b/atf-c/config.h deleted file mode 100644 index 19b86e2c2f65..000000000000 --- a/atf-c/config.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 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. - */ - -#if !defined(ATF_C_CONFIG_H) -#define ATF_C_CONFIG_H - -#include <stdbool.h> - -const char *atf_config_get(const char *); - -#endif /* !defined(ATF_C_CONFIG_H) */ diff --git a/atf-c/config_test.c b/atf-c/config_test.c deleted file mode 100644 index aed181438b59..000000000000 --- a/atf-c/config_test.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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. - */ - -#include <stdio.h> -#include <string.h> - -#include <atf-c.h> - -#include "atf-c/config.h" - -#include "detail/env.h" -#include "detail/test_helpers.h" - -static const char *test_value = "env-value"; - -static struct varnames { - const char *lc; - const char *uc; - bool can_be_empty; -} all_vars[] = { - { "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_includedir", "ATF_INCLUDEDIR", false }, - { "atf_libexecdir", "ATF_LIBEXECDIR", false }, - { "atf_pkgdatadir", "ATF_PKGDATADIR", false }, - { "atf_shell", "ATF_SHELL", false }, - { "atf_workdir", "ATF_WORKDIR", false }, - { NULL, NULL, false } -}; - -/* --------------------------------------------------------------------- - * Auxiliary functions. - * --------------------------------------------------------------------- */ - -void __atf_config_reinit(void); - -static -void -unset_all(void) -{ - const struct varnames *v; - for (v = all_vars; v->lc != NULL; v++) - RE(atf_env_unset(v->uc)); -} - -static -void -compare_one(const char *var, const char *expvalue) -{ - const struct varnames *v; - - printf("Checking that %s is set to %s\n", var, expvalue); - - for (v = all_vars; v->lc != NULL; v++) { - if (strcmp(v->lc, var) == 0) - ATF_CHECK_STREQ(atf_config_get(v->lc), test_value); - else - ATF_CHECK(strcmp(atf_config_get(v->lc), test_value) != 0); - } -} - -/* --------------------------------------------------------------------- - * Test cases for the free functions. - * --------------------------------------------------------------------- */ - -ATF_TC(get); -ATF_TC_HEAD(get, tc) -{ - atf_tc_set_md_var(tc, "descr", "Tests the atf_config_get function"); -} -ATF_TC_BODY(get, tc) -{ - const struct varnames *v; - - /* Unset all known environment variables and make sure the built-in - * values do not match the bogus value we will use for testing. */ - unset_all(); - __atf_config_reinit(); - for (v = all_vars; v->lc != NULL; v++) - ATF_CHECK(strcmp(atf_config_get(v->lc), test_value) != 0); - - /* Test the behavior of empty values. */ - for (v = all_vars; v->lc != NULL; v++) { - unset_all(); - if (strcmp(atf_config_get(v->lc), "") != 0) { - RE(atf_env_set(v->uc, "")); - __atf_config_reinit(); - if (v->can_be_empty) - ATF_CHECK(strlen(atf_config_get(v->lc)) == 0); - else - ATF_CHECK(strlen(atf_config_get(v->lc)) > 0); - } - } - - /* Check if every variable is recognized individually. */ - for (v = all_vars; v->lc != NULL; v++) { - unset_all(); - RE(atf_env_set(v->uc, test_value)); - __atf_config_reinit(); - compare_one(v->lc, test_value); - } -} - -/* --------------------------------------------------------------------- - * Tests cases for the header file. - * --------------------------------------------------------------------- */ - -HEADER_TC(include, "atf-c/config.h"); - -/* --------------------------------------------------------------------- - * Main. - * --------------------------------------------------------------------- */ - -ATF_TP_ADD_TCS(tp) -{ - ATF_TP_ADD_TC(tp, get); - - /* Add the test cases for the header file. */ - ATF_TP_ADD_TC(tp, include); - - return atf_no_error(); -} diff --git a/atf-c/defs.h.in b/atf-c/defs.h.in index 7925107cf83a..6059e7fdb0e6 100644 --- a/atf-c/defs.h.in +++ b/atf-c/defs.h.in @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if !defined(ATF_C_DEFS_H) #define ATF_C_DEFS_H diff --git a/atf-c/detail/Makefile.am.inc b/atf-c/detail/Makefile.am.inc index dbf88f346e1b..22b41f9ec352 100644 --- a/atf-c/detail/Makefile.am.inc +++ b/atf-c/detail/Makefile.am.inc @@ -1,6 +1,3 @@ -# -# Automated Testing Framework (atf) -# # Copyright (c) 2007 The NetBSD Foundation, Inc. # All rights reserved. # @@ -25,7 +22,6 @@ # 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. -# libatf_c_la_SOURCES += atf-c/detail/dynstr.c \ atf-c/detail/dynstr.h \ @@ -54,7 +50,8 @@ EXTRA_DIST += $(tests_atf_c_detail_DATA) noinst_LTLIBRARIES += atf-c/detail/libtest_helpers.la atf_c_detail_libtest_helpers_la_SOURCES = atf-c/detail/test_helpers.c \ atf-c/detail/test_helpers.h -atf_c_detail_libtest_helpers_la_CPPFLAGS = -I$(srcdir)/atf-c +atf_c_detail_libtest_helpers_la_CPPFLAGS = -I$(srcdir)/atf-c \ + -DATF_INCLUDEDIR=\"$(includedir)\" tests_atf_c_detail_PROGRAMS = atf-c/detail/dynstr_test atf_c_detail_dynstr_test_SOURCES = atf-c/detail/dynstr_test.c diff --git a/atf-c/detail/dynstr.c b/atf-c/detail/dynstr.c index e533a811ffc8..424a1c9dac73 100644 --- a/atf-c/detail/dynstr.c +++ b/atf-c/detail/dynstr.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/dynstr.h" #include <errno.h> #include <stdarg.h> @@ -34,12 +32,10 @@ #include <stdlib.h> #include <string.h> +#include "atf-c/detail/sanity.h" +#include "atf-c/detail/text.h" #include "atf-c/error.h" -#include "dynstr.h" -#include "sanity.h" -#include "text.h" - /* --------------------------------------------------------------------- * Auxiliary functions. * --------------------------------------------------------------------- */ diff --git a/atf-c/detail/dynstr.h b/atf-c/detail/dynstr.h index c82209a48046..60b8e422ca9e 100644 --- a/atf-c/detail/dynstr.h +++ b/atf-c/detail/dynstr.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,11 +21,10 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(ATF_C_DYNSTR_H) -#define ATF_C_DYNSTR_H +#if !defined(ATF_C_DETAIL_DYNSTR_H) +#define ATF_C_DETAIL_DYNSTR_H #include <stdarg.h> #include <stdbool.h> @@ -78,4 +74,4 @@ atf_error_t atf_dynstr_prepend_fmt(atf_dynstr_t *, const char *, ...); bool atf_equal_dynstr_cstring(const atf_dynstr_t *, const char *); bool atf_equal_dynstr_dynstr(const atf_dynstr_t *, const atf_dynstr_t *); -#endif /* ATF_C_DYNSTR_H */ +#endif /* !defined(ATF_C_DETAIL_DYNSTR_H) */ diff --git a/atf-c/detail/dynstr_test.c b/atf-c/detail/dynstr_test.c index 1b68d38b7722..25127529f81b 100644 --- a/atf-c/detail/dynstr_test.c +++ b/atf-c/detail/dynstr_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/dynstr.h" #include <stdarg.h> #include <stdint.h> @@ -35,8 +33,7 @@ #include <atf-c.h> -#include "dynstr.h" -#include "test_helpers.h" +#include "atf-c/detail/test_helpers.h" /* --------------------------------------------------------------------- * Tests for the "atf_dynstr" type. diff --git a/atf-c/detail/env.c b/atf-c/detail/env.c index feb4ee53e763..8ee3d697c223 100644 --- a/atf-c/detail/env.c +++ b/atf-c/detail/env.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2007 The NetBSD Foundation, Inc. +/* Copyright (c) 2007 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,22 +21,21 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/env.h" #if defined(HAVE_CONFIG_H) -#include "bconfig.h" +#include "config.h" #endif #include <errno.h> #include <stdlib.h> +#include "atf-c/detail/sanity.h" +#include "atf-c/detail/text.h" #include "atf-c/error.h" -#include "env.h" -#include "sanity.h" -#include "text.h" - const char * atf_env_get(const char *name) { @@ -48,6 +44,16 @@ atf_env_get(const char *name) return val; } +const char * +atf_env_get_with_default(const char *name, const char *default_value) +{ + const char* val = getenv(name); + if (val == NULL) + return default_value; + else + return val; +} + bool atf_env_has(const char *name) { diff --git a/atf-c/detail/env.h b/atf-c/detail/env.h index c0d07a3a337a..5d29440df468 100644 --- a/atf-c/detail/env.h +++ b/atf-c/detail/env.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,19 +21,19 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(ATF_C_ENV_H) -#define ATF_C_ENV_H +#if !defined(ATF_C_DETAIL_ENV_H) +#define ATF_C_DETAIL_ENV_H #include <stdbool.h> #include <atf-c/error_fwd.h> const char *atf_env_get(const char *); +const char *atf_env_get_with_default(const char *, const char *); bool atf_env_has(const char *); atf_error_t atf_env_set(const char *, const char *); atf_error_t atf_env_unset(const char *); -#endif /* !defined(ATF_C_ENV_H) */ +#endif /* !defined(ATF_C_DETAIL_ENV_H) */ diff --git a/atf-c/detail/env_test.c b/atf-c/detail/env_test.c index 6ebf36c8bbef..3909c29fb991 100644 --- a/atf-c/detail/env_test.c +++ b/atf-c/detail/env_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2007 The NetBSD Foundation, Inc. +/* Copyright (c) 2007 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,17 +21,17 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/env.h" #include <stdlib.h> #include <string.h> #include <atf-c.h> -#include "env.h" -#include "test_helpers.h" -#include "text.h" +#include "atf-c/detail/test_helpers.h" +#include "atf-c/detail/text.h" /* --------------------------------------------------------------------- * Test cases for the free functions. @@ -67,6 +64,25 @@ ATF_TC_BODY(get, tc) ATF_REQUIRE(strchr(val, ':') != NULL); } +ATF_TC(get_with_default); +ATF_TC_HEAD(get_with_default, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the atf_env_get_with_default " + "function"); +} +ATF_TC_BODY(get_with_default, tc) +{ + const char *val; + + ATF_REQUIRE(atf_env_has("PATH")); + + val = atf_env_get_with_default("PATH", "unknown"); + ATF_REQUIRE(strcmp(val, "unknown") != 0); + + val = atf_env_get_with_default("_UNKNOWN_VARIABLE_", "foo bar"); + ATF_REQUIRE(strcmp(val, "foo bar") == 0); +} + ATF_TC(set); ATF_TC_HEAD(set, tc) { @@ -109,6 +125,7 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, has); ATF_TP_ADD_TC(tp, get); + ATF_TP_ADD_TC(tp, get_with_default); ATF_TP_ADD_TC(tp, set); ATF_TP_ADD_TC(tp, unset); diff --git a/atf-c/detail/fs.c b/atf-c/detail/fs.c index 22cbca439b36..5ff7648c3c7e 100644 --- a/atf-c/detail/fs.c +++ b/atf-c/detail/fs.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2007 The NetBSD Foundation, Inc. +/* Copyright (c) 2007 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,11 +21,12 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/fs.h" #if defined(HAVE_CONFIG_H) -#include "bconfig.h" +#include "config.h" #endif #include <sys/types.h> @@ -47,13 +45,11 @@ #include <unistd.h> #include "atf-c/defs.h" +#include "atf-c/detail/sanity.h" +#include "atf-c/detail/text.h" +#include "atf-c/detail/user.h" #include "atf-c/error.h" -#include "fs.h" -#include "sanity.h" -#include "text.h" -#include "user.h" - /* --------------------------------------------------------------------- * Prototypes for auxiliary functions. * --------------------------------------------------------------------- */ diff --git a/atf-c/detail/fs.h b/atf-c/detail/fs.h index ec77c3bb73d4..1c6c0eba64b2 100644 --- a/atf-c/detail/fs.h +++ b/atf-c/detail/fs.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,11 +21,10 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(ATF_C_FS_H) -#define ATF_C_FS_H +#if !defined(ATF_C_DETAIL_FS_H) +#define ATF_C_DETAIL_FS_H #include <sys/types.h> #include <sys/stat.h> @@ -36,10 +32,9 @@ #include <stdarg.h> #include <stdbool.h> +#include <atf-c/detail/dynstr.h> #include <atf-c/error_fwd.h> -#include "dynstr.h" - /* --------------------------------------------------------------------- * The "atf_fs_path" type. * --------------------------------------------------------------------- */ @@ -130,4 +125,4 @@ atf_error_t atf_fs_mkstemp(atf_fs_path_t *, int *); atf_error_t atf_fs_rmdir(const atf_fs_path_t *); atf_error_t atf_fs_unlink(const atf_fs_path_t *); -#endif /* !defined(ATF_C_FS_H) */ +#endif /* !defined(ATF_C_DETAIL_FS_H) */ diff --git a/atf-c/detail/fs_test.c b/atf-c/detail/fs_test.c index 043304a0c7d3..3dbc4d3ba7ef 100644 --- a/atf-c/detail/fs_test.c +++ b/atf-c/detail/fs_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2007 The NetBSD Foundation, Inc. +/* Copyright (c) 2007 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/fs.h" #include <sys/types.h> #include <sys/stat.h> @@ -39,9 +37,8 @@ #include <atf-c.h> -#include "fs.h" -#include "test_helpers.h" -#include "user.h" +#include "atf-c/detail/test_helpers.h" +#include "atf-c/detail/user.h" /* --------------------------------------------------------------------- * Auxiliary functions. diff --git a/atf-c/detail/list.c b/atf-c/detail/list.c index 0d005ad05181..d14216eb409f 100644 --- a/atf-c/detail/list.c +++ b/atf-c/detail/list.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,18 +21,17 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/list.h" #include <stdlib.h> #include <string.h> +#include "atf-c/detail/sanity.h" #include "atf-c/error.h" #include "atf-c/utils.h" -#include "list.h" -#include "sanity.h" - /* --------------------------------------------------------------------- * Auxiliary functions. * --------------------------------------------------------------------- */ diff --git a/atf-c/detail/list.h b/atf-c/detail/list.h index 2c0fbcba1eda..b25006680641 100644 --- a/atf-c/detail/list.h +++ b/atf-c/detail/list.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,11 +21,10 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(ATF_C_LIST_H) -#define ATF_C_LIST_H +#if !defined(ATF_C_DETAIL_LIST_H) +#define ATF_C_DETAIL_LIST_H #include <stdarg.h> #include <stdbool.h> @@ -112,4 +108,4 @@ void atf_list_append_list(atf_list_t *, atf_list_t *); !atf_equal_list_citer_list_citer((iter), atf_list_end_c(list)); \ iter = atf_list_citer_next(iter)) -#endif /* ATF_C_LIST_H */ +#endif /* !defined(ATF_C_DETAIL_LIST_H) */ diff --git a/atf-c/detail/list_test.c b/atf-c/detail/list_test.c index 3aa576cae6b3..82a715d28be8 100644 --- a/atf-c/detail/list_test.c +++ b/atf-c/detail/list_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,19 +21,18 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/list.h" #include <stdio.h> #include <string.h> #include <atf-c.h> +#include "atf-c/detail/test_helpers.h" #include "atf-c/utils.h" -#include "list.h" -#include "test_helpers.h" - /* --------------------------------------------------------------------- * Tests for the "atf_list" type. * --------------------------------------------------------------------- */ diff --git a/atf-c/detail/map.c b/atf-c/detail/map.c index 7395adfebd97..34aaae25652b 100644 --- a/atf-c/detail/map.c +++ b/atf-c/detail/map.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,19 +21,18 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/map.h" #include <errno.h> #include <stdlib.h> #include <string.h> +#include "atf-c/detail/sanity.h" #include "atf-c/error.h" #include "atf-c/utils.h" -#include "map.h" -#include "sanity.h" - /* --------------------------------------------------------------------- * Auxiliary functions. * --------------------------------------------------------------------- */ diff --git a/atf-c/detail/map.h b/atf-c/detail/map.h index a3ed7a22745e..7ca8e8ad6cd9 100644 --- a/atf-c/detail/map.h +++ b/atf-c/detail/map.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,19 +21,17 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(ATF_C_MAP_H) -#define ATF_C_MAP_H +#if !defined(ATF_C_DETAIL_MAP_H) +#define ATF_C_DETAIL_MAP_H #include <stdarg.h> #include <stdbool.h> +#include <atf-c/detail/list.h> #include <atf-c/error_fwd.h> -#include "list.h" - /* --------------------------------------------------------------------- * The "atf_map_citer" type. * --------------------------------------------------------------------- */ @@ -116,4 +111,4 @@ atf_error_t atf_map_insert(atf_map_t *, const char *, void *, bool); !atf_equal_map_citer_map_citer((iter), atf_map_end_c(map)); \ iter = atf_map_citer_next(iter)) -#endif /* ATF_C_MAP_H */ +#endif /* !defined(ATF_C_DETAIL_MAP_H) */ diff --git a/atf-c/detail/map_test.c b/atf-c/detail/map_test.c index 644ab6926c15..0982e20f7dd5 100644 --- a/atf-c/detail/map_test.c +++ b/atf-c/detail/map_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,19 +21,18 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/map.h" #include <stdio.h> #include <string.h> #include <atf-c.h> +#include "atf-c/detail/test_helpers.h" #include "atf-c/utils.h" -#include "map.h" -#include "test_helpers.h" - /* --------------------------------------------------------------------- * Tests for the "atf_map" type. * --------------------------------------------------------------------- */ diff --git a/atf-c/detail/process.c b/atf-c/detail/process.c index bc36b570e7d3..8e08b6c57466 100644 --- a/atf-c/detail/process.c +++ b/atf-c/detail/process.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2007 The NetBSD Foundation, Inc. +/* Copyright (c) 2007 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/process.h" #include <sys/types.h> #include <sys/wait.h> @@ -38,11 +36,9 @@ #include <unistd.h> #include "atf-c/defs.h" +#include "atf-c/detail/sanity.h" #include "atf-c/error.h" -#include "process.h" -#include "sanity.h" - /* This prototype is not in the header file because this is a private * function; however, we need to access it during testing. */ atf_error_t atf_process_status_init(atf_process_status_t *, int); diff --git a/atf-c/detail/process.h b/atf-c/detail/process.h index b4aad3d93a18..81158d0a5a41 100644 --- a/atf-c/detail/process.h +++ b/atf-c/detail/process.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,21 +21,19 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(ATF_C_PROCESS_H) -#define ATF_C_PROCESS_H +#if !defined(ATF_C_DETAIL_PROCESS_H) +#define ATF_C_DETAIL_PROCESS_H #include <sys/types.h> #include <stdbool.h> +#include <atf-c/detail/fs.h> +#include <atf-c/detail/list.h> #include <atf-c/error_fwd.h> -#include "fs.h" -#include "list.h" - /* --------------------------------------------------------------------- * The "atf_process_stream" type. * --------------------------------------------------------------------- */ @@ -133,4 +128,4 @@ atf_error_t atf_process_exec_list(atf_process_status_t *, const atf_process_stream_t *, void (*)(void)); -#endif /* !defined(ATF_C_PROCESS_H) */ +#endif /* !defined(ATF_C_DETAIL_PROCESS_H) */ diff --git a/atf-c/detail/process_helpers.c b/atf-c/detail/process_helpers.c index 61f1b67c980e..47b90bccf85e 100644 --- a/atf-c/detail/process_helpers.c +++ b/atf-c/detail/process_helpers.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <sys/types.h> diff --git a/atf-c/detail/process_test.c b/atf-c/detail/process_test.c index 9e55f70e3214..5ae5565b6a2b 100644 --- a/atf-c/detail/process_test.c +++ b/atf-c/detail/process_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/process.h" #include <sys/types.h> #include <sys/time.h> @@ -43,10 +41,8 @@ #include <atf-c.h> #include "atf-c/defs.h" - -#include "process.h" -#include "sanity.h" -#include "test_helpers.h" +#include "atf-c/detail/sanity.h" +#include "atf-c/detail/test_helpers.h" atf_error_t atf_process_status_init(atf_process_status_t *, int); diff --git a/atf-c/detail/sanity.c b/atf-c/detail/sanity.c index d8a8905f2c17..cfc8676bebcb 100644 --- a/atf-c/detail/sanity.c +++ b/atf-c/detail/sanity.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,11 +21,12 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/sanity.h" #if defined(HAVE_CONFIG_H) -#include "bconfig.h" +#include "config.h" #endif #include <err.h> @@ -36,8 +34,6 @@ #include <stdio.h> #include <stdlib.h> -#include "sanity.h" - static void fail(const char *fmt, ...) @@ -53,7 +49,7 @@ fail(const char *fmt, ...) warnx("This is probably a bug in this application or one of the " "libraries it uses. If you believe this problem is caused " "by, or is related to " PACKAGE_STRING ", please report it " - "to " PACKAGE_BUGREPORT " and provide as many detatils as " + "to " PACKAGE_BUGREPORT " and provide as many details as " "possible describing how you got to this condition."); abort(); diff --git a/atf-c/detail/sanity.h b/atf-c/detail/sanity.h index 0b4f3e4756ce..7f51fe03f74b 100644 --- a/atf-c/detail/sanity.h +++ b/atf-c/detail/sanity.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,11 +21,10 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(ATF_C_SANITY_H) -#define ATF_C_SANITY_H +#if !defined(ATF_C_DETAIL_SANITY_H) +#define ATF_C_DETAIL_SANITY_H void atf_sanity_inv(const char *, int, const char *); void atf_sanity_pre(const char *, int, const char *); @@ -70,4 +66,4 @@ void atf_sanity_post(const char *, int, const char *); #define UNREACHABLE INV(0) -#endif /* ATF_C_SANITY_H */ +#endif /* !defined(ATF_C_DETAIL_SANITY_H) */ diff --git a/atf-c/detail/sanity_test.c b/atf-c/detail/sanity_test.c index 7c8285b5193c..a986c32ae3c8 100644 --- a/atf-c/detail/sanity_test.c +++ b/atf-c/detail/sanity_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,11 +21,12 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/sanity.h" #if defined(HAVE_CONFIG_H) -#include "bconfig.h" +#include "config.h" #endif #include <sys/types.h> @@ -42,10 +40,9 @@ #include <atf-c.h> -#include "dynstr.h" -#include "process.h" -#include "sanity.h" -#include "test_helpers.h" +#include "atf-c/detail/dynstr.h" +#include "atf-c/detail/process.h" +#include "atf-c/detail/test_helpers.h" /* --------------------------------------------------------------------- * Auxiliary functions. diff --git a/atf-c/detail/test_helpers.c b/atf-c/detail/test_helpers.c index aacbf32b3746..827d46eeb8b7 100644 --- a/atf-c/detail/test_helpers.c +++ b/atf-c/detail/test_helpers.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,24 +21,24 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/test_helpers.h" #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <atf-c.h> + #include "atf-c/build.h" #include "atf-c/check.h" -#include "atf-c/config.h" +#include "atf-c/detail/dynstr.h" +#include "atf-c/detail/env.h" +#include "atf-c/detail/fs.h" +#include "atf-c/detail/process.h" #include "atf-c/error.h" -#include "atf-c/macros.h" - -#include "dynstr.h" -#include "fs.h" -#include "process.h" -#include "test_helpers.h" bool build_check_c_o(const char *path) @@ -50,7 +47,8 @@ build_check_c_o(const char *path) atf_dynstr_t iflag; const char *optargs[4]; - RE(atf_dynstr_init_fmt(&iflag, "-I%s", atf_config_get("atf_includedir"))); + RE(atf_dynstr_init_fmt(&iflag, "-I%s", atf_env_get_with_default( + "ATF_INCLUDEDIR", ATF_INCLUDEDIR))); optargs[0] = atf_dynstr_cstring(&iflag); optargs[1] = "-Wall"; diff --git a/atf-c/detail/test_helpers.h b/atf-c/detail/test_helpers.h index 3037ba4189c8..a601c293ffe4 100644 --- a/atf-c/detail/test_helpers.h +++ b/atf-c/detail/test_helpers.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,18 +21,20 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if defined(TESTS_ATF_ATF_C_TEST_HELPERS_H) +#if defined(ATF_C_DETAIL_TEST_HELPERS_H) # error "Cannot include test_helpers.h more than once." #else -# define TESTS_ATF_ATF_C_TEST_HELPERS_H +# define ATF_C_DETAIL_TEST_HELPERS_H #endif #include <stdbool.h> -#include "atf-c/error_fwd.h" +#include <atf-c.h> + +#include <atf-c/error_fwd.h> +#include <atf-c/tc.h> struct atf_dynstr; struct atf_fs_path; diff --git a/atf-c/detail/text.c b/atf-c/detail/text.c index d91e8d1dcf7e..3b1d7e7fe2a4 100644 --- a/atf-c/detail/text.c +++ b/atf-c/detail/text.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,20 +21,19 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/text.h" #include <errno.h> #include <limits.h> #include <string.h> #include <stdlib.h> +#include "atf-c/detail/dynstr.h" +#include "atf-c/detail/sanity.h" #include "atf-c/error.h" -#include "dynstr.h" -#include "sanity.h" -#include "text.h" - atf_error_t atf_text_for_each_word(const char *instr, const char *sep, atf_error_t (*func)(const char *, void *), diff --git a/atf-c/detail/text.h b/atf-c/detail/text.h index 8f8ddf4ccbef..b2820b6b7cf8 100644 --- a/atf-c/detail/text.h +++ b/atf-c/detail/text.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,19 +21,17 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(ATF_C_TEXT_H) -#define ATF_C_TEXT_H +#if !defined(ATF_C_DETAIL_TEXT_H) +#define ATF_C_DETAIL_TEXT_H #include <stdarg.h> #include <stdbool.h> +#include <atf-c/detail/list.h> #include <atf-c/error_fwd.h> -#include "list.h" - atf_error_t atf_text_for_each_word(const char *, const char *, atf_error_t (*)(const char *, void *), void *); @@ -46,4 +41,4 @@ atf_error_t atf_text_split(const char *, const char *, atf_list_t *); atf_error_t atf_text_to_bool(const char *, bool *); atf_error_t atf_text_to_long(const char *, long *); -#endif /* ATF_C_TEXT_H */ +#endif /* !defined(ATF_C_DETAIL_TEXT_H) */ diff --git a/atf-c/detail/text_test.c b/atf-c/detail/text_test.c index 7bdf9c83129b..5d6c8e56f4f0 100644 --- a/atf-c/detail/text_test.c +++ b/atf-c/detail/text_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/text.h" #include <stdio.h> #include <stdlib.h> @@ -33,9 +31,8 @@ #include <atf-c.h> -#include "sanity.h" -#include "test_helpers.h" -#include "text.h" +#include "atf-c/detail/sanity.h" +#include "atf-c/detail/test_helpers.h" /* --------------------------------------------------------------------- * Auxiliary functions. diff --git a/atf-c/detail/tp_main.c b/atf-c/detail/tp_main.c index a62ae0ad615b..439384b4950e 100644 --- a/atf-c/detail/tp_main.c +++ b/atf-c/detail/tp_main.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,11 +21,10 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if defined(HAVE_CONFIG_H) -#include "bconfig.h" +#include "config.h" #endif #include <ctype.h> @@ -38,17 +34,16 @@ #include <string.h> #include <unistd.h> +#include "atf-c/detail/dynstr.h" +#include "atf-c/detail/env.h" +#include "atf-c/detail/fs.h" +#include "atf-c/detail/map.h" +#include "atf-c/detail/sanity.h" #include "atf-c/error.h" #include "atf-c/tc.h" #include "atf-c/tp.h" #include "atf-c/utils.h" -#include "dynstr.h" -#include "env.h" -#include "fs.h" -#include "map.h" -#include "sanity.h" - #if defined(HAVE_GNU_GETOPT) # define GETOPT_POSIX "+" #else @@ -499,7 +494,7 @@ run_tc(const atf_tp_t *tp, struct params *p, int *exitcode) if (!atf_env_has("__RUNNING_INSIDE_ATF_RUN") || strcmp(atf_env_get( "__RUNNING_INSIDE_ATF_RUN"), "internal-yes-value") != 0) { - print_warning("Running test cases without atf-run(1) is unsupported"); + print_warning("Running test cases outside of kyua(1) is unsupported"); print_warning("No isolation nor timeout control is being applied; you " "may get unexpected failures; see atf-test-case(4)"); } diff --git a/atf-c/detail/user.c b/atf-c/detail/user.c index 5a89bf42b22a..bbb4ded5e8a8 100644 --- a/atf-c/detail/user.c +++ b/atf-c/detail/user.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2007 The NetBSD Foundation, Inc. +/* Copyright (c) 2007 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,16 +21,16 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/user.h" #include <sys/param.h> #include <sys/types.h> #include <limits.h> #include <unistd.h> -#include "sanity.h" -#include "user.h" +#include "atf-c/detail/sanity.h" /* --------------------------------------------------------------------- * Free functions. diff --git a/atf-c/detail/user.h b/atf-c/detail/user.h index d682bcfb4355..14a3e96cec7a 100644 --- a/atf-c/detail/user.h +++ b/atf-c/detail/user.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2007 The NetBSD Foundation, Inc. +/* Copyright (c) 2007 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,11 +21,10 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(ATF_C_USER_H) -#define ATF_C_USER_H +#if !defined(ATF_C_DETAIL_USER_H) +#define ATF_C_DETAIL_USER_H #include <sys/types.h> @@ -46,4 +42,4 @@ bool atf_user_is_member_of_group(gid_t); bool atf_user_is_root(void); bool atf_user_is_unprivileged(void); -#endif /* !defined(ATF_C_USER_H) */ +#endif /* !defined(ATF_C_DETAIL_USER_H) */ diff --git a/atf-c/detail/user_test.c b/atf-c/detail/user_test.c index 0bf37e7e3eb7..6a0f6e158de7 100644 --- a/atf-c/detail/user_test.c +++ b/atf-c/detail/user_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2007 The NetBSD Foundation, Inc. +/* Copyright (c) 2007 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/detail/user.h" #include <sys/param.h> #include <sys/types.h> @@ -36,8 +34,7 @@ #include <atf-c.h> -#include "test_helpers.h" -#include "user.h" +#include "atf-c/detail/test_helpers.h" /* --------------------------------------------------------------------- * Test cases for the free functions. diff --git a/atf-c/detail/version_helper.c b/atf-c/detail/version_helper.c index b75ff364b5a7..fd48466de06a 100644 --- a/atf-c/detail/version_helper.c +++ b/atf-c/detail/version_helper.c @@ -29,7 +29,7 @@ */ #if defined(HAVE_CONFIG_H) -#include "bconfig.h" +#include "config.h" #endif #include <stdio.h> diff --git a/atf-c/error.c b/atf-c/error.c index aeb55a8ba47b..071daf6d2455 100644 --- a/atf-c/error.c +++ b/atf-c/error.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,17 +21,16 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/error.h" #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "atf-c/error.h" - -#include "detail/sanity.h" +#include "atf-c/detail/sanity.h" /* Theoretically, there can only be a single error intance at any given * point in time, because errors are raised at one point and must be diff --git a/atf-c/error.h b/atf-c/error.h index a8502801b063..260c0d07bf47 100644 --- a/atf-c/error.h +++ b/atf-c/error.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,17 +21,16 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if !defined(ATF_C_ERROR_H) #define ATF_C_ERROR_H +#include <atf-c/error_fwd.h> + #include <stdbool.h> #include <stddef.h> -#include <atf-c/error_fwd.h> - /* --------------------------------------------------------------------- * The "atf_error" type. * --------------------------------------------------------------------- */ @@ -68,4 +64,4 @@ const char *atf_libc_error_msg(const atf_error_t); atf_error_t atf_no_memory_error(void); -#endif /* ATF_C_ERROR_H */ +#endif /* !defined(ATF_C_ERROR_H) */ diff --git a/atf-c/error_fwd.h b/atf-c/error_fwd.h index 69d7e7dadbf5..d73e164b5cec 100644 --- a/atf-c/error_fwd.h +++ b/atf-c/error_fwd.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if !defined(ATF_C_ERROR_FWD_H) #define ATF_C_ERROR_FWD_H @@ -37,4 +33,4 @@ struct atf_error; typedef struct atf_error *atf_error_t; -#endif /* ATF_C_ERROR_FWD_H */ +#endif /* !defined(ATF_C_ERROR_FWD_H) */ diff --git a/atf-c/error_test.c b/atf-c/error_test.c index 2c2a30789b2c..8bfa1249b391 100644 --- a/atf-c/error_test.c +++ b/atf-c/error_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/error.h" #include <errno.h> #include <stdint.h> @@ -35,9 +33,6 @@ #include <atf-c.h> #include "atf-c/defs.h" -#include "atf-c/error.h" - -#include "detail/test_helpers.h" /* --------------------------------------------------------------------- * Auxiliary functions. @@ -277,13 +272,6 @@ ATF_TC_BODY(no_memory_twice, tc) } /* --------------------------------------------------------------------- - * Tests cases for the header file. - * --------------------------------------------------------------------- */ - -HEADER_TC(include, "atf-c/error.h"); -HEADER_TC(include_fwd, "atf-c/error_fwd.h"); - -/* --------------------------------------------------------------------- * Main. * --------------------------------------------------------------------- */ @@ -305,9 +293,5 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, no_memory_format); ATF_TP_ADD_TC(tp, no_memory_twice); - /* Add the test cases for the header file. */ - ATF_TP_ADD_TC(tp, include); - ATF_TP_ADD_TC(tp, include_fwd); - return atf_no_error(); } diff --git a/atf-c/h_build.h b/atf-c/h_build.h index 9454fdfde807..c5ad1c75efbf 100644 --- a/atf-c/h_build.h +++ b/atf-c/h_build.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2009 The NetBSD Foundation, Inc. +/* Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,13 +21,12 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if defined(TESTS_ATF_ATF_C_H_BUILD_H) +#if defined(ATF_C_H_BUILD_H) # error "Cannot include h_build.h more than once." #else -# define TESTS_ATF_ATF_C_H_BUILD_H +# define ATF_C_H_BUILD_H #endif /* --------------------------------------------------------------------- diff --git a/atf-c/macros.h b/atf-c/macros.h index 7c33ccbc1e10..485a159acecb 100644 --- a/atf-c/macros.h +++ b/atf-c/macros.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if !defined(ATF_C_MACROS_H) #define ATF_C_MACROS_H @@ -131,55 +127,63 @@ return atfu_err; \ } while (0) -#define ATF_REQUIRE_MSG(x, fmt, ...) \ +#define ATF_REQUIRE_MSG(expression, fmt, ...) \ do { \ - if (!(x)) \ + if (!(expression)) \ atf_tc_fail_requirement(__FILE__, __LINE__, fmt, ##__VA_ARGS__); \ } while(0) -#define ATF_CHECK_MSG(x, fmt, ...) \ +#define ATF_CHECK_MSG(expression, fmt, ...) \ do { \ - if (!(x)) \ + if (!(expression)) \ atf_tc_fail_check(__FILE__, __LINE__, fmt, ##__VA_ARGS__); \ } while(0) -#define ATF_REQUIRE(x) \ +#define ATF_REQUIRE(expression) \ do { \ - if (!(x)) \ - atf_tc_fail_requirement(__FILE__, __LINE__, "%s", #x " not met"); \ + if (!(expression)) \ + atf_tc_fail_requirement(__FILE__, __LINE__, "%s", \ + #expression " not met"); \ } while(0) -#define ATF_CHECK(x) \ +#define ATF_CHECK(expression) \ do { \ - if (!(x)) \ - atf_tc_fail_check(__FILE__, __LINE__, "%s", #x " not met"); \ + if (!(expression)) \ + atf_tc_fail_check(__FILE__, __LINE__, "%s", \ + #expression " not met"); \ } while(0) -#define ATF_REQUIRE_EQ(x, y) \ - ATF_REQUIRE_MSG((x) == (y), "%s != %s", #x, #y) +#define ATF_REQUIRE_EQ(expected, actual) \ + ATF_REQUIRE_MSG((expected) == (actual), "%s != %s", #expected, #actual) -#define ATF_CHECK_EQ(x, y) \ - ATF_CHECK_MSG((x) == (y), "%s != %s", #x, #y) +#define ATF_CHECK_EQ(expected, actual) \ + ATF_CHECK_MSG((expected) == (actual), "%s != %s", #expected, #actual) -#define ATF_REQUIRE_EQ_MSG(x, y, fmt, ...) \ - ATF_REQUIRE_MSG((x) == (y), "%s != %s: " fmt, #x, #y, ##__VA_ARGS__) +#define ATF_REQUIRE_EQ_MSG(expected, actual, fmt, ...) \ + ATF_REQUIRE_MSG((expected) == (actual), "%s != %s: " fmt, \ + #expected, #actual, ##__VA_ARGS__) -#define ATF_CHECK_EQ_MSG(x, y, fmt, ...) \ - ATF_CHECK_MSG((x) == (y), "%s != %s: " fmt, #x, #y, ##__VA_ARGS__) +#define ATF_CHECK_EQ_MSG(expected, actual, fmt, ...) \ + ATF_CHECK_MSG((expected) == (actual), "%s != %s: " fmt, \ + #expected, #actual, ##__VA_ARGS__) -#define ATF_REQUIRE_STREQ(x, y) \ - ATF_REQUIRE_MSG(strcmp(x, y) == 0, "%s != %s (%s != %s)", #x, #y, x, y) +#define ATF_REQUIRE_STREQ(expected, actual) \ + ATF_REQUIRE_MSG(strcmp(expected, actual) == 0, "%s != %s (%s != %s)", \ + #expected, #actual, expected, actual) -#define ATF_CHECK_STREQ(x, y) \ - ATF_CHECK_MSG(strcmp(x, y) == 0, "%s != %s (%s != %s)", #x, #y, x, y) +#define ATF_CHECK_STREQ(expected, actual) \ + ATF_CHECK_MSG(strcmp(expected, actual) == 0, "%s != %s (%s != %s)", \ + #expected, #actual, expected, actual) -#define ATF_REQUIRE_STREQ_MSG(x, y, fmt, ...) \ - ATF_REQUIRE_MSG(strcmp(x, y) == 0, "%s != %s (%s != %s): " fmt, \ - #x, #y, x, y, ##__VA_ARGS__) +#define ATF_REQUIRE_STREQ_MSG(expected, actual, fmt, ...) \ + ATF_REQUIRE_MSG(strcmp(expected, actual) == 0, \ + "%s != %s (%s != %s): " fmt, \ + #expected, #actual, expected, actual, ##__VA_ARGS__) -#define ATF_CHECK_STREQ_MSG(x, y, fmt, ...) \ - ATF_CHECK_MSG(strcmp(x, y) == 0, "%s != %s (%s != %s): " fmt, \ - #x, #y, x, y, ##__VA_ARGS__) +#define ATF_CHECK_STREQ_MSG(expected, actual, fmt, ...) \ + ATF_CHECK_MSG(strcmp(expected, actual) == 0, \ + "%s != %s (%s != %s): " fmt, \ + #expected, #actual, expected, actual, ##__VA_ARGS__) #define ATF_REQUIRE_MATCH(regexp, string) \ ATF_REQUIRE_MSG(atf_utils_grep_string("%s", string, regexp), \ diff --git a/atf-c/macros_h_test.c b/atf-c/macros_h_test.c index 3dae471e4dd7..9525fcaae259 100644 --- a/atf-c/macros_h_test.c +++ b/atf-c/macros_h_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <atf-c/macros.h> @@ -87,6 +83,7 @@ ATF_TC(TEST_MACRO_1); ATF_TC_HEAD(TEST_MACRO_1, tc) { if (tc != NULL) {} } ATF_TC_BODY(TEST_MACRO_1, tc) { if (tc != NULL) {} } atf_tc_t *test_name_1 = &ATF_TC_NAME(TEST_MACRO_1); +atf_tc_pack_t *test_pack_1 = &ATF_TC_PACK_NAME(TEST_MACRO_1); void (*head_1)(atf_tc_t *) = ATF_TC_HEAD_NAME(TEST_MACRO_1); void (*body_1)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_1); ATF_TC_WITH_CLEANUP(TEST_MACRO_2); @@ -94,10 +91,12 @@ ATF_TC_HEAD(TEST_MACRO_2, tc) { if (tc != NULL) {} } ATF_TC_BODY(TEST_MACRO_2, tc) { if (tc != NULL) {} } ATF_TC_CLEANUP(TEST_MACRO_2, tc) { if (tc != NULL) {} } atf_tc_t *test_name_2 = &ATF_TC_NAME(TEST_MACRO_2); +atf_tc_pack_t *test_pack_2 = &ATF_TC_PACK_NAME(TEST_MACRO_2); void (*head_2)(atf_tc_t *) = ATF_TC_HEAD_NAME(TEST_MACRO_2); void (*body_2)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_2); void (*cleanup_2)(const atf_tc_t *) = ATF_TC_CLEANUP_NAME(TEST_MACRO_2); ATF_TC_WITHOUT_HEAD(TEST_MACRO_3); ATF_TC_BODY(TEST_MACRO_3, tc) { if (tc != NULL) {} } atf_tc_t *test_name_3 = &ATF_TC_NAME(TEST_MACRO_3); +atf_tc_pack_t *test_pack_3 = &ATF_TC_PACK_NAME(TEST_MACRO_3); void (*body_3)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_3); diff --git a/atf-c/macros_test.c b/atf-c/macros_test.c index adfc77c0ba0d..83578cda595f 100644 --- a/atf-c/macros_test.c +++ b/atf-c/macros_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/macros.h" #include <sys/types.h> #include <sys/wait.h> @@ -41,10 +39,10 @@ #include <atf-c.h> -#include "detail/fs.h" -#include "detail/process.h" -#include "detail/test_helpers.h" -#include "detail/text.h" +#include "atf-c/detail/fs.h" +#include "atf-c/detail/process.h" +#include "atf-c/detail/test_helpers.h" +#include "atf-c/detail/text.h" /* --------------------------------------------------------------------- * Auxiliary functions. @@ -837,7 +835,6 @@ ATF_TC_BODY(msg_embedded_fmt, tc) * Tests cases for the header file. * --------------------------------------------------------------------- */ -HEADER_TC(include, "atf-c/macros.h"); BUILD_TC(use, "macros_h_test.c", "Tests that the macros provided by the atf-c/macros.h file " "do not cause syntax errors when used", @@ -889,7 +886,6 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, msg_embedded_fmt); /* 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); diff --git a/atf-c/pkg_config_test.sh b/atf-c/pkg_config_test.sh index d913ec91012d..ddffdb0ca1f7 100644 --- a/atf-c/pkg_config_test.sh +++ b/atf-c/pkg_config_test.sh @@ -1,6 +1,3 @@ -# -# Automated Testing Framework (atf) -# # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. # @@ -25,7 +22,6 @@ # 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. -# # The following tests assume that the atf-c.pc file is installed in a # directory that is known by pkg-config. Otherwise they will fail, diff --git a/atf-c/tc.c b/atf-c/tc.c index cbdd00c4e0b0..92c3e12c99b1 100644 --- a/atf-c/tc.c +++ b/atf-c/tc.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/tc.h" #include <sys/types.h> #include <sys/stat.h> @@ -41,14 +39,12 @@ #include <unistd.h> #include "atf-c/defs.h" +#include "atf-c/detail/env.h" +#include "atf-c/detail/fs.h" +#include "atf-c/detail/map.h" +#include "atf-c/detail/sanity.h" +#include "atf-c/detail/text.h" #include "atf-c/error.h" -#include "atf-c/tc.h" - -#include "detail/env.h" -#include "detail/fs.h" -#include "detail/map.h" -#include "detail/sanity.h" -#include "detail/text.h" /* --------------------------------------------------------------------- * Auxiliary functions. diff --git a/atf-c/tc.h b/atf-c/tc.h index 3f24186b0264..3fb695562ac8 100644 --- a/atf-c/tc.h +++ b/atf-c/tc.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if !defined(ATF_C_TC_H) #define ATF_C_TC_H @@ -137,4 +133,4 @@ void atf_tc_check_errno(const char *, const size_t, const int, void atf_tc_require_errno(const char *, const size_t, const int, const char *, const bool); -#endif /* ATF_C_TC_H */ +#endif /* !defined(ATF_C_TC_H) */ diff --git a/atf-c/tc_test.c b/atf-c/tc_test.c index 4aaf9a54c242..616c37e94e68 100644 --- a/atf-c/tc_test.c +++ b/atf-c/tc_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,15 +21,16 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/tc.h" #include <stdbool.h> #include <string.h> #include <atf-c.h> -#include "detail/test_helpers.h" +#include "atf-c/detail/test_helpers.h" /* --------------------------------------------------------------------- * Auxiliary test cases. @@ -167,12 +165,6 @@ ATF_TC_BODY(config, tcin) * testing done later on. */ /* --------------------------------------------------------------------- - * Tests cases for the header file. - * --------------------------------------------------------------------- */ - -HEADER_TC(include, "atf-c/tc.h"); - -/* --------------------------------------------------------------------- * Main. * --------------------------------------------------------------------- */ @@ -187,8 +179,5 @@ ATF_TP_ADD_TCS(tp) /* Add the test cases for the free functions. */ /* TODO */ - /* Add the test cases for the header file. */ - ATF_TP_ADD_TC(tp, include); - return atf_no_error(); } diff --git a/atf-c/tp.c b/atf-c/tp.c index 7833498ac15e..f4f225772ca2 100644 --- a/atf-c/tp.c +++ b/atf-c/tp.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,21 +21,20 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/tp.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "atf-c/detail/fs.h" +#include "atf-c/detail/map.h" +#include "atf-c/detail/sanity.h" #include "atf-c/error.h" #include "atf-c/tc.h" -#include "atf-c/tp.h" - -#include "detail/fs.h" -#include "detail/map.h" -#include "detail/sanity.h" struct atf_tp_impl { atf_list_t m_tcs; diff --git a/atf-c/tp.h b/atf-c/tp.h index e4f9ba46e936..c176f7d96f5e 100644 --- a/atf-c/tp.h +++ b/atf-c/tp.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2008 The NetBSD Foundation, Inc. +/* Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if !defined(ATF_C_TP_H) #define ATF_C_TP_H @@ -66,4 +62,4 @@ atf_error_t atf_tp_add_tc(atf_tp_t *, struct atf_tc *); atf_error_t atf_tp_run(const atf_tp_t *, const char *, const char *); atf_error_t atf_tp_cleanup(const atf_tp_t *, const char *); -#endif /* ATF_C_TP_H */ +#endif /* !defined(ATF_C_TP_H) */ diff --git a/atf-c/tp_test.c b/atf-c/tp_test.c index 5da18b20bdac..de334a97483b 100644 --- a/atf-c/tp_test.c +++ b/atf-c/tp_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2010 The NetBSD Foundation, Inc. +/* Copyright (c) 2010 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,16 +21,15 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/tp.h" #include <string.h> #include <unistd.h> #include <atf-c.h> -#include "detail/test_helpers.h" - ATF_TC(getopt); ATF_TC_HEAD(getopt, tc) { @@ -81,12 +77,6 @@ ATF_TC_BODY(getopt, tc) } /* --------------------------------------------------------------------- - * Tests cases for the header file. - * --------------------------------------------------------------------- */ - -HEADER_TC(include, "atf-c/tp.h"); - -/* --------------------------------------------------------------------- * Main. * --------------------------------------------------------------------- */ @@ -94,8 +84,5 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, getopt); - /* Add the test cases for the header file. */ - ATF_TP_ADD_TC(tp, include); - return atf_no_error(); } diff --git a/atf-c/unused_test.c b/atf-c/unused_test.c index e8de6823a374..1c5fda93230f 100644 --- a/atf-c/unused_test.c +++ b/atf-c/unused_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2012 The NetBSD Foundation, Inc. +/* Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,10 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <atf-c/macros.h> +#include <atf-c.h> ATF_TC(this_is_used); ATF_TC_HEAD(this_is_used, tc) diff --git a/atf-c/utils.c b/atf-c/utils.c index 4409f7a4fb9e..1e2aac1ed3b6 100644 --- a/atf-c/utils.c +++ b/atf-c/utils.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2010 The NetBSD Foundation, Inc. +/* Copyright (c) 2010 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "atf-c/utils.h" @@ -43,7 +39,35 @@ #include <atf-c.h> -#include "detail/dynstr.h" +#include "atf-c/detail/dynstr.h" + +/** Allocate a filename to be used by atf_utils_{fork,wait}. + * + * In case of a failure, marks the calling test as failed when in_parent is + * true, else terminates execution. + * + * \param [out] name String to contain the generated file. + * \param pid PID of the process that will write to the file. + * \param suffix Either "out" or "err". + * \param in_parent If true, fail with atf_tc_fail; else use err(3). */ +static void +init_out_filename(atf_dynstr_t *name, const pid_t pid, const char *suffix, + const bool in_parent) +{ + atf_error_t error; + + error = atf_dynstr_init_fmt(name, "atf_utils_fork_%d_%s.txt", + (int)pid, suffix); + if (atf_is_error(error)) { + char buffer[1024]; + atf_error_format(error, buffer, sizeof(buffer)); + if (in_parent) { + atf_tc_fail("Failed to create output file: %s", buffer); + } else { + err(EXIT_FAILURE, "Failed to create output file: %s", buffer); + } + } +} /** Searches for a regexp in a string. * @@ -232,8 +256,17 @@ atf_utils_fork(void) atf_tc_fail("fork failed"); if (pid == 0) { - atf_utils_redirect(STDOUT_FILENO, "atf_utils_fork_out.txt"); - atf_utils_redirect(STDERR_FILENO, "atf_utils_fork_err.txt"); + atf_dynstr_t out_name; + init_out_filename(&out_name, getpid(), "out", false); + + atf_dynstr_t err_name; + init_out_filename(&err_name, getpid(), "err", false); + + atf_utils_redirect(STDOUT_FILENO, atf_dynstr_cstring(&out_name)); + atf_utils_redirect(STDERR_FILENO, atf_dynstr_cstring(&err_name)); + + atf_dynstr_fini(&err_name); + atf_dynstr_fini(&out_name); } return pid; } @@ -385,8 +418,14 @@ atf_utils_wait(const pid_t pid, const int exitstatus, const char *expout, int status; ATF_REQUIRE(waitpid(pid, &status, 0) != -1); - atf_utils_cat_file("atf_utils_fork_out.txt", "subprocess stdout: "); - atf_utils_cat_file("atf_utils_fork_err.txt", "subprocess stderr: "); + atf_dynstr_t out_name; + init_out_filename(&out_name, pid, "out", true); + + atf_dynstr_t err_name; + init_out_filename(&err_name, pid, "err", true); + + atf_utils_cat_file(atf_dynstr_cstring(&out_name), "subprocess stdout: "); + atf_utils_cat_file(atf_dynstr_cstring(&err_name), "subprocess stderr: "); ATF_REQUIRE(WIFEXITED(status)); ATF_REQUIRE_EQ(exitstatus, WEXITSTATUS(status)); @@ -396,20 +435,22 @@ atf_utils_wait(const pid_t pid, const int exitstatus, const char *expout, if (strlen(expout) > save_prefix_length && strncmp(expout, save_prefix, save_prefix_length) == 0) { - atf_utils_copy_file("atf_utils_fork_out.txt", + atf_utils_copy_file(atf_dynstr_cstring(&out_name), expout + save_prefix_length); } else { - ATF_REQUIRE(atf_utils_compare_file("atf_utils_fork_out.txt", expout)); + ATF_REQUIRE(atf_utils_compare_file(atf_dynstr_cstring(&out_name), + expout)); } if (strlen(experr) > save_prefix_length && strncmp(experr, save_prefix, save_prefix_length) == 0) { - atf_utils_copy_file("atf_utils_fork_err.txt", + atf_utils_copy_file(atf_dynstr_cstring(&err_name), experr + save_prefix_length); } else { - ATF_REQUIRE(atf_utils_compare_file("atf_utils_fork_err.txt", experr)); + ATF_REQUIRE(atf_utils_compare_file(atf_dynstr_cstring(&err_name), + experr)); } - ATF_REQUIRE(unlink("atf_utils_fork_out.txt") != -1); - ATF_REQUIRE(unlink("atf_utils_fork_err.txt") != -1); + ATF_REQUIRE(unlink(atf_dynstr_cstring(&out_name)) != -1); + ATF_REQUIRE(unlink(atf_dynstr_cstring(&err_name)) != -1); } diff --git a/atf-c/utils.h b/atf-c/utils.h index 666804d3a2c1..e4162b215fe5 100644 --- a/atf-c/utils.h +++ b/atf-c/utils.h @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2010 The NetBSD Foundation, Inc. +/* Copyright (c) 2010 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,7 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if !defined(ATF_C_UTILS_H) #define ATF_C_UTILS_H @@ -51,4 +47,4 @@ char *atf_utils_readline(int); void atf_utils_redirect(const int, const char *); void atf_utils_wait(const pid_t, const int, const char *, const char *); -#endif /* ATF_C_UTILS_H */ +#endif /* !defined(ATF_C_UTILS_H) */ diff --git a/atf-c/utils_test.c b/atf-c/utils_test.c index 57d6af8d2a25..fb81cd3a1d9e 100644 --- a/atf-c/utils_test.c +++ b/atf-c/utils_test.c @@ -1,7 +1,4 @@ -/* - * Automated Testing Framework (atf) - * - * Copyright (c) 2010 The NetBSD Foundation, Inc. +/* Copyright (c) 2010 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,8 +21,9 @@ * 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "atf-c/utils.h" #include <sys/stat.h> #include <sys/wait.h> @@ -39,9 +37,8 @@ #include <atf-c.h> -#include "atf-c/utils.h" - -#include "detail/test_helpers.h" +#include "atf-c/detail/dynstr.h" +#include "atf-c/detail/test_helpers.h" /** Reads the contents of a file into a buffer. * @@ -246,11 +243,19 @@ ATF_TC_BODY(fork, tc) ATF_REQUIRE(WIFEXITED(status)); ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status)); + atf_dynstr_t out_name; + RE(atf_dynstr_init_fmt(&out_name, "atf_utils_fork_%d_out.txt", (int)pid)); + atf_dynstr_t err_name; + RE(atf_dynstr_init_fmt(&err_name, "atf_utils_fork_%d_err.txt", (int)pid)); + char buffer[1024]; - read_file("atf_utils_fork_out.txt", buffer, sizeof(buffer)); + read_file(atf_dynstr_cstring(&out_name), buffer, sizeof(buffer)); ATF_REQUIRE_STREQ("Child stdout\n", buffer); - read_file("atf_utils_fork_err.txt", buffer, sizeof(buffer)); + read_file(atf_dynstr_cstring(&err_name), buffer, sizeof(buffer)); ATF_REQUIRE_STREQ("Child stderr\n", buffer); + + atf_dynstr_fini(&err_name); + atf_dynstr_fini(&out_name); } ATF_TC_WITHOUT_HEAD(free_charpp__empty); @@ -384,6 +389,7 @@ static void fork_and_wait(const int exitstatus, const char* expout, const char* experr) { const pid_t pid = atf_utils_fork(); + ATF_REQUIRE(pid != -1); if (pid == 0) { fprintf(stdout, "Some output\n"); fprintf(stderr, "Some error\n"); @@ -408,6 +414,35 @@ ATF_TC_BODY(wait__ok, tc) } } +ATF_TC_WITHOUT_HEAD(wait__ok_nested); +ATF_TC_BODY(wait__ok_nested, tc) +{ + const pid_t parent = atf_utils_fork(); + ATF_REQUIRE(parent != -1); + if (parent == 0) { + const pid_t child = atf_utils_fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + fflush(stderr); + fprintf(stdout, "Child output\n"); + fflush(stdout); + fprintf(stderr, "Child error\n"); + exit(50); + } else { + fprintf(stdout, "Parent output\n"); + fprintf(stderr, "Parent error\n"); + atf_utils_wait(child, 50, "Child output\n", "Child error\n"); + exit(40); + } + } else { + atf_utils_wait(parent, 40, + "Parent output\n" + "subprocess stdout: Child output\n" + "subprocess stderr: Child error\n", + "Parent error\n"); + } +} + ATF_TC_WITHOUT_HEAD(wait__invalid_exitstatus); ATF_TC_BODY(wait__invalid_exitstatus, tc) { @@ -487,8 +522,6 @@ ATF_TC_BODY(wait__save_stderr, tc) } } -HEADER_TC(include, "atf-c/utils.h"); - ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, cat_file__empty); @@ -526,13 +559,12 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, redirect__other); ATF_TP_ADD_TC(tp, wait__ok); + ATF_TP_ADD_TC(tp, wait__ok_nested); ATF_TP_ADD_TC(tp, wait__save_stdout); ATF_TP_ADD_TC(tp, wait__save_stderr); ATF_TP_ADD_TC(tp, wait__invalid_exitstatus); ATF_TP_ADD_TC(tp, wait__invalid_stdout); ATF_TP_ADD_TC(tp, wait__invalid_stderr); - ATF_TP_ADD_TC(tp, include); - return atf_no_error(); } |
