head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.2
	netbsd-11-0-RC3:1.1.1.2
	netbsd-11-0-RC2:1.1.1.2
	netbsd-11-0-RC1:1.1.1.2
	perseant-exfatfs-base-20250801:1.1.1.2
	netbsd-11:1.1.1.2.0.62
	netbsd-11-base:1.1.1.2
	netbsd-10-1-RELEASE:1.1.1.2
	perseant-exfatfs-base-20240630:1.1.1.2
	perseant-exfatfs:1.1.1.2.0.60
	perseant-exfatfs-base:1.1.1.2
	netbsd-8-3-RELEASE:1.1.1.2
	netbsd-9-4-RELEASE:1.1.1.2
	netbsd-10-0-RELEASE:1.1.1.2
	netbsd-10-0-RC6:1.1.1.2
	netbsd-10-0-RC5:1.1.1.2
	netbsd-10-0-RC4:1.1.1.2
	netbsd-10-0-RC3:1.1.1.2
	netbsd-10-0-RC2:1.1.1.2
	netbsd-10-0-RC1:1.1.1.2
	netbsd-10:1.1.1.2.0.58
	netbsd-10-base:1.1.1.2
	netbsd-9-3-RELEASE:1.1.1.2
	cjep_sun2x-base1:1.1.1.2
	cjep_sun2x:1.1.1.2.0.56
	cjep_sun2x-base:1.1.1.2
	cjep_staticlib_x-base1:1.1.1.2
	netbsd-9-2-RELEASE:1.1.1.2
	cjep_staticlib_x:1.1.1.2.0.54
	cjep_staticlib_x-base:1.1.1.2
	netbsd-9-1-RELEASE:1.1.1.2
	phil-wifi-20200421:1.1.1.2
	phil-wifi-20200411:1.1.1.2
	is-mlppp:1.1.1.2.0.52
	is-mlppp-base:1.1.1.2
	phil-wifi-20200406:1.1.1.2
	netbsd-8-2-RELEASE:1.1.1.2
	netbsd-9-0-RELEASE:1.1.1.2
	netbsd-9-0-RC2:1.1.1.2
	netbsd-9-0-RC1:1.1.1.2
	phil-wifi-20191119:1.1.1.2
	netbsd-9:1.1.1.2.0.50
	netbsd-9-base:1.1.1.2
	phil-wifi-20190609:1.1.1.2
	netbsd-8-1-RELEASE:1.1.1.2
	netbsd-8-1-RC1:1.1.1.2
	pgoyette-compat-merge-20190127:1.1.1.2
	pgoyette-compat-20190127:1.1.1.2
	pgoyette-compat-20190118:1.1.1.2
	pgoyette-compat-1226:1.1.1.2
	pgoyette-compat-1126:1.1.1.2
	pgoyette-compat-1020:1.1.1.2
	pgoyette-compat-0930:1.1.1.2
	pgoyette-compat-0906:1.1.1.2
	netbsd-7-2-RELEASE:1.1.1.2
	pgoyette-compat-0728:1.1.1.2
	netbsd-8-0-RELEASE:1.1.1.2
	phil-wifi:1.1.1.2.0.48
	phil-wifi-base:1.1.1.2
	pgoyette-compat-0625:1.1.1.2
	netbsd-8-0-RC2:1.1.1.2
	pgoyette-compat-0521:1.1.1.2
	pgoyette-compat-0502:1.1.1.2
	pgoyette-compat-0422:1.1.1.2
	netbsd-8-0-RC1:1.1.1.2
	pgoyette-compat-0415:1.1.1.2
	pgoyette-compat-0407:1.1.1.2
	pgoyette-compat-0330:1.1.1.2
	pgoyette-compat-0322:1.1.1.2
	pgoyette-compat-0315:1.1.1.2
	netbsd-7-1-2-RELEASE:1.1.1.2
	pgoyette-compat:1.1.1.2.0.46
	pgoyette-compat-base:1.1.1.2
	netbsd-7-1-1-RELEASE:1.1.1.2
	matt-nb8-mediatek:1.1.1.2.0.44
	matt-nb8-mediatek-base:1.1.1.2
	perseant-stdc-iso10646:1.1.1.2.0.42
	perseant-stdc-iso10646-base:1.1.1.2
	netbsd-8:1.1.1.2.0.40
	netbsd-8-base:1.1.1.2
	prg-localcount2-base3:1.1.1.2
	prg-localcount2-base2:1.1.1.2
	prg-localcount2-base1:1.1.1.2
	prg-localcount2:1.1.1.2.0.38
	prg-localcount2-base:1.1.1.2
	pgoyette-localcount-20170426:1.1.1.2
	bouyer-socketcan-base1:1.1.1.2
	pgoyette-localcount-20170320:1.1.1.2
	netbsd-7-1:1.1.1.2.0.36
	netbsd-7-1-RELEASE:1.1.1.2
	netbsd-7-1-RC2:1.1.1.2
	netbsd-7-nhusb-base-20170116:1.1.1.2
	bouyer-socketcan:1.1.1.2.0.34
	bouyer-socketcan-base:1.1.1.2
	pgoyette-localcount-20170107:1.1.1.2
	netbsd-7-1-RC1:1.1.1.2
	pgoyette-localcount-20161104:1.1.1.2
	netbsd-7-0-2-RELEASE:1.1.1.2
	localcount-20160914:1.1.1.2
	netbsd-7-nhusb:1.1.1.2.0.32
	netbsd-7-nhusb-base:1.1.1.2
	pgoyette-localcount-20160806:1.1.1.2
	pgoyette-localcount-20160726:1.1.1.2
	pgoyette-localcount:1.1.1.2.0.30
	pgoyette-localcount-base:1.1.1.2
	netbsd-7-0-1-RELEASE:1.1.1.2
	netbsd-7-0:1.1.1.2.0.28
	netbsd-7-0-RELEASE:1.1.1.2
	netbsd-7-0-RC3:1.1.1.2
	netbsd-7-0-RC2:1.1.1.2
	netbsd-7-0-RC1:1.1.1.2
	netbsd-6-0-6-RELEASE:1.1.1.2
	netbsd-6-1-5-RELEASE:1.1.1.2
	netbsd-7:1.1.1.2.0.26
	netbsd-7-base:1.1.1.2
	yamt-pagecache-base9:1.1.1.2
	yamt-pagecache-tag8:1.1.1.2
	netbsd-6-1-4-RELEASE:1.1.1.2
	netbsd-6-0-5-RELEASE:1.1.1.2
	tls-earlyentropy:1.1.1.2.0.24
	tls-earlyentropy-base:1.1.1.2
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.2
	riastradh-drm2-base3:1.1.1.2
	atf-0-20:1.1.1.2
	atf-0-19:1.1.1.2
	GITHUB_JMMV:1.1.1
	netbsd-6-1-3-RELEASE:1.1.1.2
	netbsd-6-0-4-RELEASE:1.1.1.2
	netbsd-6-1-2-RELEASE:1.1.1.2
	netbsd-6-0-3-RELEASE:1.1.1.2
	netbsd-6-1-1-RELEASE:1.1.1.2
	riastradh-drm2-base2:1.1.1.2
	riastradh-drm2-base1:1.1.1.2
	riastradh-drm2:1.1.1.2.0.16
	riastradh-drm2-base:1.1.1.2
	netbsd-6-1:1.1.1.2.0.22
	netbsd-6-0-2-RELEASE:1.1.1.2
	netbsd-6-1-RELEASE:1.1.1.2
	khorben-n900:1.1.1.2.0.20
	netbsd-6-1-RC4:1.1.1.2
	netbsd-6-1-RC3:1.1.1.2
	agc-symver:1.1.1.2.0.18
	agc-symver-base:1.1.1.2
	netbsd-6-1-RC2:1.1.1.2
	netbsd-6-1-RC1:1.1.1.2
	atf-0-17:1.1.1.2
	yamt-pagecache-base8:1.1.1.2
	netbsd-6-0-1-RELEASE:1.1.1.2
	yamt-pagecache-base7:1.1.1.2
	matt-nb6-plus-nbase:1.1.1.2
	yamt-pagecache-base6:1.1.1.2
	netbsd-6-0:1.1.1.2.0.14
	netbsd-6-0-RELEASE:1.1.1.2
	netbsd-6-0-RC2:1.1.1.2
	tls-maxphys:1.1.1.2.0.12
	tls-maxphys-base:1.1.1.2
	matt-nb6-plus:1.1.1.2.0.10
	matt-nb6-plus-base:1.1.1.2
	netbsd-6-0-RC1:1.1.1.2
	atf-0-16:1.1.1.2
	yamt-pagecache-base5:1.1.1.2
	yamt-pagecache-base4:1.1.1.2
	netbsd-6:1.1.1.2.0.8
	netbsd-6-base:1.1.1.2
	atf-0-15:1.1.1.2
	yamt-pagecache-base3:1.1.1.2
	yamt-pagecache-base2:1.1.1.2
	yamt-pagecache:1.1.1.2.0.6
	yamt-pagecache-base:1.1.1.2
	atf-0-14:1.1.1.2
	cherry-xenmp:1.1.1.2.0.4
	cherry-xenmp-base:1.1.1.2
	atf-0-13:1.1.1.2
	bouyer-quota2-nbase:1.1.1.2
	bouyer-quota2:1.1.1.2.0.2
	bouyer-quota2-base:1.1.1.2
	matt-mips64-premerge-20101231:1.1.1.2
	atf-0-12:1.1.1.2
	atf-0-11:1.1.1.2
	atf-0-10:1.1.1.1
	TNF:1.1.1;
locks; strict;
comment	@// @;


1.1
date	2010.07.03.08.04.51;	author jmmv;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2010.07.03.08.04.51;	author jmmv;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2010.10.20.09.14.20;	author jmmv;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@//
// Automated Testing Framework (atf)
//
// Copyright (c) 2009 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 <cstring>
#include <iostream>

#include "atf-c++/build.hpp"
#include "atf-c++/config.hpp"
#include "atf-c++/env.hpp"
#include "atf-c++/macros.hpp"
#include "atf-c++/process.hpp"

#include "../atf-c/h_build.h"

#include "test_helpers.hpp"

// ------------------------------------------------------------------------
// Auxiliary functions.
// ------------------------------------------------------------------------

namespace atf {
    namespace config {
        void __reinit(void);
    }
}

template< class C >
void
print_col(const char* prefix, const C& c)
{
    std::cout << prefix << ":";
    for (typename C::const_iterator iter = c.begin(); iter != c.end();
         iter++)
        std::cout << " '" << *iter << "'";
    std::cout << "\n";
}

static
void
print_array(const char* prefix, const char* const* a)
{
    std::cout << prefix << ":";
    for (; *a != NULL; a++)
        std::cout << " '" << *a << "'";
    std::cout << "\n";
}

static
void
verbose_set_env(const char *var, const char *val)
{
    std::cout << "Setting " << var << " to '" << val << "'\n";
    atf::env::set(var, val);
}

static
bool
equal_argvs(const atf::process::argv_array& aa, const char* const* array)
{
    bool equal = true;

    atf::process::argv_array::size_type i = 0;
    while (equal && (i < aa.size() && array[i] != NULL)) {
        if (std::strcmp(aa[i], array[i]) != 0)
            equal = false;
        else
            i++;
    }

    if (equal && (i < aa.size() || array[i] != NULL))
        equal = false;

    return equal;
}

static
void
check_equal_argvs(const atf::process::argv_array& aa, const char* const* array)
{
    print_array("Expected arguments", array);
    print_col("Arguments returned", aa);

    if (!equal_argvs(aa, array))
        ATF_FAIL("The constructed argv differs from the expected values");
}

// ------------------------------------------------------------------------
// Internal test cases.
// ------------------------------------------------------------------------

ATF_TEST_CASE(equal_argvs);
ATF_TEST_CASE_HEAD(equal_argvs)
{
    set_md_var("descr", "Tests the test case internal equal_argvs function");
}
ATF_TEST_CASE_BODY(equal_argvs)
{
    {
        const char* const array[] = { NULL };
        const char* const argv[] = { NULL };

        ATF_CHECK(equal_argvs(atf::process::argv_array(argv), array));
    }

    {
        const char* const array[] = { NULL };
        const char* const argv[] = { "foo", NULL };

        ATF_CHECK(!equal_argvs(atf::process::argv_array(argv), array));
    }

    {
        const char* const array[] = { "foo", NULL };
        const char* const argv[] = { NULL };

        ATF_CHECK(!equal_argvs(atf::process::argv_array(argv), array));
    }

    {
        const char* const array[] = { "foo", NULL };
        const char* const argv[] = { "foo", NULL };

        ATF_CHECK(equal_argvs(atf::process::argv_array(argv), array));
    }
}

// ------------------------------------------------------------------------
// Test cases for the free functions.
// ------------------------------------------------------------------------

ATF_TEST_CASE(c_o);
ATF_TEST_CASE_HEAD(c_o)
{
    set_md_var("descr", "Tests the c_o function");
}
ATF_TEST_CASE_BODY(c_o)
{
    for (struct c_o_test* test = c_o_tests; test->expargv[0] != NULL;
         test++) {
        std::cout << "> Test: " << test->msg << "\n";

        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();

        atf::process::argv_array argv =
            atf::build::c_o(test->sfile, test->ofile,
                            atf::process::argv_array(test->optargs));
        check_equal_argvs(argv, test->expargv);
    }
}

ATF_TEST_CASE(cpp);
ATF_TEST_CASE_HEAD(cpp)
{
    set_md_var("descr", "Tests the cpp function");
}
ATF_TEST_CASE_BODY(cpp)
{
    for (struct cpp_test* test = cpp_tests; test->expargv[0] != NULL;
         test++) {
        std::cout << "> Test: " << test->msg << "\n";

        verbose_set_env("ATF_BUILD_CPP", test->cpp);
        verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
        atf::config::__reinit();

        atf::process::argv_array argv =
            atf::build::cpp(test->sfile, test->ofile,
                            atf::process::argv_array(test->optargs));
        check_equal_argvs(argv, test->expargv);
    }
}

ATF_TEST_CASE(cxx_o);
ATF_TEST_CASE_HEAD(cxx_o)
{
    set_md_var("descr", "Tests the cxx_o function");
}
ATF_TEST_CASE_BODY(cxx_o)
{
    for (struct cxx_o_test* test = cxx_o_tests; test->expargv[0] != NULL;
         test++) {
        std::cout << "> Test: " << test->msg << "\n";

        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();

        atf::process::argv_array argv =
            atf::build::cxx_o(test->sfile, test->ofile,
                              atf::process::argv_array(test->optargs));
        check_equal_argvs(argv, test->expargv);
    }
}

// ------------------------------------------------------------------------
// Tests cases for the header file.
// ------------------------------------------------------------------------

HEADER_TC(include, "atf-c++/build.hpp");

// ------------------------------------------------------------------------
// Main.
// ------------------------------------------------------------------------

ATF_INIT_TEST_CASES(tcs)
{
    // Add the internal test cases.
    ATF_ADD_TEST_CASE(tcs, equal_argvs);

    // Add the test cases for the free functions.
    ATF_ADD_TEST_CASE(tcs, c_o);
    ATF_ADD_TEST_CASE(tcs, cpp);
    ATF_ADD_TEST_CASE(tcs, cxx_o);

    // Add the test cases for the header file.
    ATF_ADD_TEST_CASE(tcs, include);
}
@


1.1.1.1
log
@Import atf 0.10:

Miscellaneous features

* Added expected failures support to test cases and atf-run.  These
  include, for example, expected clean exits, expected reception of fatal
  signals, expected timeouts and expected errors in condition checks.
  These statuses can be used to denote test cases that are known to fail
  due to a bug in the code they are testing.  atf-report reports these
  tests separately but they do not count towards the failed test cases
  amount.

* Added the ATF_CHECK_ERRNO and ATF_REQUIRE_ERRNO to the C library to
  allow easy checking of call failures that update errno.

* Added the has.cleanup meta-data property to test caes that specifies
  whether the test case has a cleanup routine or not; its value is
  automatically set.  This property is read by atf-run to know if it has to
  run the cleanup routine; skipping this run for every test case
  significantly speeds up the run time of test suites.

* Reversed the order of the ATF_CHECK_THROW macro in the C++ binding to
  take the expected exception as the first argument and the statement to
  execute as the second argument.

Changes in atf-check

* Changed atf-check to support negating the status and output checks by
  prefixing them with not- and added support to specify multiple checkers
  for stdout and stderr, not only one.

* Added the match output checker to atf-check to look for regular
  expressions in the stdout and stderr of commands.

* Modified the exit checks in atf-check to support checking for the
  reception of signals.

Code simplifications and cleanups

* Removed usage messages from test programs to simplify the
  implementation of every binding by a significant amount.  They just now
  refer the user to the appropriate manual page and do not attempt to wrap
  lines on terminal boundaries.  Test programs are not supposed to be run
  by users directly so this minor interface regression is not important.

* Removed the atf-format internal utility, which is unused after the
  change documented above.

* Removed the atf-cleanup internal utility.  It has been unused since the
  test case isolation was moved to atf-run in 0.8

* Splitted the Makefile.am into smaller files for easier maintenance and
  dropped the use of M4.  Only affects users building from the repository
  sources.

* Intermixed tests with the source files in the source tree to provide
  them more visibility and easier access.  The tests directory is gone from
  the source tree and tests are now suffixed by _test, not prefixed by t_.

* Simplifications to the atf-c library: removed the io, tcr and ui
  modules as they had become unnecessary after all simplifications
  introduced since the 0.8 release.

* Removed the application/X-atf-tcr format introduced in 0.8 release.
  Tests now print a much simplified format that is easy to parse and nicer
  to read by end users.  As a side effect, the default for test cases is
  now to print their results to stdout unless otherwise stated by providing
  the -r flag.

* Removed XML distribution documents and replaced them with plain-text
  documents.  They provided little value and introduced a lot of complexity
  to the build system.

* Simplified the output of atf-version by not attempting to print a
  revision number when building form a distfile.  Makes the build system
  easier to maintain.
@
text
@@


1.1.1.2
log
@Import atf-0.11:

Experimental version released on October 20th, 2010.

* The ATF_CHECK* macros in atf-c++ were renamed to ATF_REQUIRE* to match
  their counterparts in atf-c.

* Clearly separated the modules in atf-c that are supposed to be public
  from those that are implementation details.  The header files for the
  internal modules are not installed any more.

* Made the atf-check tool private.  It is only required by atf-sh and being
  public has the danger of causing confusion.  Also, making it private
  simplifies the public API of atf.

* Changed atf-sh to enable per-command error checking (set -e) by default.
  This catches many cases in which a test case is broken but it is not
  reported as such because execution continues.

* Fixed the XSTL and CSS stylesheets to support expected failures.
@
text
@d33 6
d41 1
a41 7
#include "build.hpp"
#include "config.hpp"
#include "macros.hpp"

#include "detail/env.hpp"
#include "detail/process.hpp"
#include "detail/test_helpers.hpp"
d128 1
a128 1
        ATF_REQUIRE(equal_argvs(atf::process::argv_array(argv), array));
d135 1
a135 1
        ATF_REQUIRE(!equal_argvs(atf::process::argv_array(argv), array));
d142 1
a142 1
        ATF_REQUIRE(!equal_argvs(atf::process::argv_array(argv), array));
d149 1
a149 1
        ATF_REQUIRE(equal_argvs(atf::process::argv_array(argv), array));
@

