Import atf-0.21:
Released on October 23rd, 2014.
* Restored the atf(7) manual page to serve as a reference to all the other
manual pages shipped by ATF.
* Added the -s flag to atf-sh to support specifying the shell interpreter
to be used.
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
use the standard TMPDIR environment variable. As a benefit, and because
Kyua forces the TMPDIR to live within the test case's work directory,
any stale files left behind by ATF will be automatically cleaned up.
* Documented the environment variables recognized by each component in the
relevant manual pages. This information was lost with the atf-config(1)
removal.
* Added a new "require.diskspace" metadata property to test cases so that
they can specify the minimum amount of disk space required for the test
to run.
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
discoverability purposes. Symbolic links are provided for the time
being to still make the old names visible.
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
macros in the manual pages.
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
propagates the crash to the caller, which in turn allows it to obtain
proper debugging information. In particular, Kyua should now be able to
extract a stacktrace pinpointing the problem.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
explaining how they relate to each other.
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
initially added as a way to enable a "strict" mode in the library and to
make test cases fail fast when they run unprotected commands. However,
doing so in the library is surprising as the responsibility of enabling
'set -e' should be on the user's code. Also, 'set -e' introduces
inconsistent behavior on subshells and users do not expect that.
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
* Issue #16: Fixed test failures (by removing a long-standing hack) on
systems that lack \e support in printf(1).
* Issue #19: Removed stale references to atf-config and atf-run.
2014-10-30 17:14:07 +00:00
|
|
|
/* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
2012-09-04 23:07:32 +00:00
|
|
|
* 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
|
Import atf-0.21:
Released on October 23rd, 2014.
* Restored the atf(7) manual page to serve as a reference to all the other
manual pages shipped by ATF.
* Added the -s flag to atf-sh to support specifying the shell interpreter
to be used.
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
use the standard TMPDIR environment variable. As a benefit, and because
Kyua forces the TMPDIR to live within the test case's work directory,
any stale files left behind by ATF will be automatically cleaned up.
* Documented the environment variables recognized by each component in the
relevant manual pages. This information was lost with the atf-config(1)
removal.
* Added a new "require.diskspace" metadata property to test cases so that
they can specify the minimum amount of disk space required for the test
to run.
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
discoverability purposes. Symbolic links are provided for the time
being to still make the old names visible.
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
macros in the manual pages.
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
propagates the crash to the caller, which in turn allows it to obtain
proper debugging information. In particular, Kyua should now be able to
extract a stacktrace pinpointing the problem.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
explaining how they relate to each other.
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
initially added as a way to enable a "strict" mode in the library and to
make test cases fail fast when they run unprotected commands. However,
doing so in the library is surprising as the responsibility of enabling
'set -e' should be on the user's code. Also, 'set -e' introduces
inconsistent behavior on subshells and users do not expect that.
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
* Issue #16: Fixed test failures (by removing a long-standing hack) on
systems that lack \e support in printf(1).
* Issue #19: Removed stale references to atf-config and atf-run.
2014-10-30 17:14:07 +00:00
|
|
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
2012-09-04 23:07:32 +00:00
|
|
|
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
#include "atf-c/utils.h"
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <regex.h>
|
|
|
|
#include <stdio.h>
|
2012-09-04 23:07:32 +00:00
|
|
|
#include <stdlib.h>
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2012-09-04 23:07:32 +00:00
|
|
|
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
#include <atf-c.h>
|
|
|
|
|
Import atf-0.21:
Released on October 23rd, 2014.
* Restored the atf(7) manual page to serve as a reference to all the other
manual pages shipped by ATF.
* Added the -s flag to atf-sh to support specifying the shell interpreter
to be used.
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
use the standard TMPDIR environment variable. As a benefit, and because
Kyua forces the TMPDIR to live within the test case's work directory,
any stale files left behind by ATF will be automatically cleaned up.
* Documented the environment variables recognized by each component in the
relevant manual pages. This information was lost with the atf-config(1)
removal.
* Added a new "require.diskspace" metadata property to test cases so that
they can specify the minimum amount of disk space required for the test
to run.
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
discoverability purposes. Symbolic links are provided for the time
being to still make the old names visible.
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
macros in the manual pages.
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
propagates the crash to the caller, which in turn allows it to obtain
proper debugging information. In particular, Kyua should now be able to
extract a stacktrace pinpointing the problem.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
explaining how they relate to each other.
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
initially added as a way to enable a "strict" mode in the library and to
make test cases fail fast when they run unprotected commands. However,
doing so in the library is surprising as the responsibility of enabling
'set -e' should be on the user's code. Also, 'set -e' introduces
inconsistent behavior on subshells and users do not expect that.
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
* Issue #16: Fixed test failures (by removing a long-standing hack) on
systems that lack \e support in printf(1).
* Issue #19: Removed stale references to atf-config and atf-run.
2014-10-30 17:14:07 +00:00
|
|
|
#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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
|
|
|
|
/** Searches for a regexp in a string.
|
|
|
|
*
|
|
|
|
* \param regex The regexp to look for.
|
|
|
|
* \param str The string in which to look for the expression.
|
|
|
|
*
|
|
|
|
* \return True if there is a match; false otherwise. */
|
|
|
|
static
|
|
|
|
bool
|
|
|
|
grep_string(const char *regex, const char *str)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
regex_t preg;
|
|
|
|
|
|
|
|
printf("Looking for '%s' in '%s'\n", regex, str);
|
|
|
|
ATF_REQUIRE(regcomp(&preg, regex, REG_EXTENDED) == 0);
|
|
|
|
|
|
|
|
res = regexec(&preg, str, 0, NULL, 0);
|
|
|
|
ATF_REQUIRE(res == 0 || res == REG_NOMATCH);
|
|
|
|
|
|
|
|
regfree(&preg);
|
|
|
|
|
|
|
|
return res == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints the contents of a file to stdout.
|
|
|
|
*
|
|
|
|
* \param name The name of the file to be printed.
|
|
|
|
* \param prefix An string to be prepended to every line of the printed
|
|
|
|
* file. */
|
|
|
|
void
|
|
|
|
atf_utils_cat_file(const char *name, const char *prefix)
|
|
|
|
{
|
|
|
|
const int fd = open(name, O_RDONLY);
|
|
|
|
ATF_REQUIRE_MSG(fd != -1, "Cannot open %s", name);
|
|
|
|
|
|
|
|
char buffer[1024];
|
|
|
|
ssize_t count;
|
|
|
|
bool continued = false;
|
|
|
|
while ((count = read(fd, buffer, sizeof(buffer) - 1)) > 0) {
|
|
|
|
buffer[count] = '\0';
|
|
|
|
|
|
|
|
if (!continued)
|
|
|
|
printf("%s", prefix);
|
|
|
|
|
|
|
|
char *iter = buffer;
|
|
|
|
char *end;
|
|
|
|
while ((end = strchr(iter, '\n')) != NULL) {
|
|
|
|
*end = '\0';
|
|
|
|
printf("%s\n", iter);
|
|
|
|
|
|
|
|
iter = end + 1;
|
|
|
|
if (iter != buffer + count)
|
|
|
|
printf("%s", prefix);
|
|
|
|
else
|
|
|
|
continued = false;
|
|
|
|
}
|
|
|
|
if (iter < buffer + count) {
|
|
|
|
printf("%s", iter);
|
|
|
|
continued = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ATF_REQUIRE(count == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Compares a file against the given golden contents.
|
|
|
|
*
|
|
|
|
* \param name Name of the file to be compared.
|
|
|
|
* \param contents Expected contents of the file.
|
|
|
|
*
|
|
|
|
* \return True if the file matches the contents; false otherwise. */
|
|
|
|
bool
|
|
|
|
atf_utils_compare_file(const char *name, const char *contents)
|
|
|
|
{
|
|
|
|
const int fd = open(name, O_RDONLY);
|
|
|
|
ATF_REQUIRE_MSG(fd != -1, "Cannot open %s", name);
|
|
|
|
|
|
|
|
const char *pos = contents;
|
|
|
|
ssize_t remaining = strlen(contents);
|
|
|
|
|
|
|
|
char buffer[1024];
|
|
|
|
ssize_t count;
|
|
|
|
while ((count = read(fd, buffer, sizeof(buffer))) > 0 &&
|
|
|
|
count <= remaining) {
|
|
|
|
if (memcmp(pos, buffer, count) != 0) {
|
|
|
|
close(fd);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
remaining -= count;
|
|
|
|
pos += count;
|
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
return count == 0 && remaining == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Copies a file.
|
|
|
|
*
|
|
|
|
* \param source Path to the source file.
|
|
|
|
* \param destination Path to the destination file. */
|
|
|
|
void
|
|
|
|
atf_utils_copy_file(const char *source, const char *destination)
|
|
|
|
{
|
|
|
|
const int input = open(source, O_RDONLY);
|
|
|
|
ATF_REQUIRE_MSG(input != -1, "Failed to open source file during "
|
|
|
|
"copy (%s)", source);
|
|
|
|
|
|
|
|
const int output = open(destination, O_WRONLY | O_CREAT | O_TRUNC, 0777);
|
|
|
|
ATF_REQUIRE_MSG(output != -1, "Failed to open destination file during "
|
|
|
|
"copy (%s)", destination);
|
|
|
|
|
|
|
|
char buffer[1024];
|
|
|
|
ssize_t length;
|
|
|
|
while ((length = read(input, buffer, sizeof(buffer))) > 0)
|
|
|
|
ATF_REQUIRE_MSG(write(output, buffer, length) == length,
|
|
|
|
"Failed to write to %s during copy", destination);
|
|
|
|
ATF_REQUIRE_MSG(length != -1, "Failed to read from %s during copy", source);
|
|
|
|
|
|
|
|
struct stat sb;
|
|
|
|
ATF_REQUIRE_MSG(fstat(input, &sb) != -1,
|
|
|
|
"Failed to stat source file %s during copy", source);
|
|
|
|
ATF_REQUIRE_MSG(fchmod(output, sb.st_mode) != -1,
|
|
|
|
"Failed to chmod destination file %s during copy",
|
|
|
|
destination);
|
|
|
|
|
|
|
|
close(output);
|
|
|
|
close(input);
|
|
|
|
}
|
2012-09-04 23:07:32 +00:00
|
|
|
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
/** Creates a file.
|
|
|
|
*
|
|
|
|
* \param name Name of the file to create.
|
|
|
|
* \param contents Text to write into the created file.
|
|
|
|
* \param ... Positional parameters to the contents. */
|
|
|
|
void
|
|
|
|
atf_utils_create_file(const char *name, const char *contents, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
atf_dynstr_t formatted;
|
|
|
|
atf_error_t error;
|
|
|
|
|
|
|
|
va_start(ap, contents);
|
|
|
|
error = atf_dynstr_init_ap(&formatted, contents, ap);
|
|
|
|
va_end(ap);
|
|
|
|
ATF_REQUIRE(!atf_is_error(error));
|
|
|
|
|
|
|
|
const int fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
|
|
|
ATF_REQUIRE_MSG(fd != -1, "Cannot create file %s", name);
|
|
|
|
ATF_REQUIRE(write(fd, atf_dynstr_cstring(&formatted),
|
|
|
|
atf_dynstr_length(&formatted)) != -1);
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
atf_dynstr_fini(&formatted);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Checks if a file exists.
|
|
|
|
*
|
|
|
|
* \param path Location of the file to check for.
|
|
|
|
*
|
|
|
|
* \return True if the file exists, false otherwise. */
|
|
|
|
bool
|
|
|
|
atf_utils_file_exists(const char *path)
|
|
|
|
{
|
|
|
|
const int ret = access(path, F_OK);
|
|
|
|
if (ret == -1) {
|
|
|
|
if (errno != ENOENT)
|
|
|
|
atf_tc_fail("Failed to check the existence of %s: %s", path,
|
|
|
|
strerror(errno));
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
} else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Spawns a subprocess and redirects its output to files.
|
|
|
|
*
|
|
|
|
* Use the atf_utils_wait() function to wait for the completion of the spawned
|
|
|
|
* subprocess and validate its exit conditions.
|
|
|
|
*
|
|
|
|
* \return 0 in the new child; the PID of the new child in the parent. Does
|
|
|
|
* not return in error conditions. */
|
|
|
|
pid_t
|
|
|
|
atf_utils_fork(void)
|
|
|
|
{
|
|
|
|
const pid_t pid = fork();
|
|
|
|
if (pid == -1)
|
|
|
|
atf_tc_fail("fork failed");
|
|
|
|
|
|
|
|
if (pid == 0) {
|
Import atf-0.21:
Released on October 23rd, 2014.
* Restored the atf(7) manual page to serve as a reference to all the other
manual pages shipped by ATF.
* Added the -s flag to atf-sh to support specifying the shell interpreter
to be used.
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
use the standard TMPDIR environment variable. As a benefit, and because
Kyua forces the TMPDIR to live within the test case's work directory,
any stale files left behind by ATF will be automatically cleaned up.
* Documented the environment variables recognized by each component in the
relevant manual pages. This information was lost with the atf-config(1)
removal.
* Added a new "require.diskspace" metadata property to test cases so that
they can specify the minimum amount of disk space required for the test
to run.
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
discoverability purposes. Symbolic links are provided for the time
being to still make the old names visible.
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
macros in the manual pages.
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
propagates the crash to the caller, which in turn allows it to obtain
proper debugging information. In particular, Kyua should now be able to
extract a stacktrace pinpointing the problem.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
explaining how they relate to each other.
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
initially added as a way to enable a "strict" mode in the library and to
make test cases fail fast when they run unprotected commands. However,
doing so in the library is surprising as the responsibility of enabling
'set -e' should be on the user's code. Also, 'set -e' introduces
inconsistent behavior on subshells and users do not expect that.
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
* Issue #16: Fixed test failures (by removing a long-standing hack) on
systems that lack \e support in printf(1).
* Issue #19: Removed stale references to atf-config and atf-run.
2014-10-30 17:14:07 +00:00
|
|
|
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);
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
}
|
|
|
|
return pid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Frees an dynamically-allocated "argv" array.
|
|
|
|
*
|
|
|
|
* \param argv A dynamically-allocated array of dynamically-allocated
|
|
|
|
* strings. */
|
2012-09-04 23:07:32 +00:00
|
|
|
void
|
|
|
|
atf_utils_free_charpp(char **argv)
|
|
|
|
{
|
|
|
|
char **ptr;
|
|
|
|
|
|
|
|
for (ptr = argv; *ptr != NULL; ptr++)
|
|
|
|
free(*ptr);
|
|
|
|
|
|
|
|
free(argv);
|
|
|
|
}
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
|
|
|
|
/** Searches for a regexp in a file.
|
|
|
|
*
|
|
|
|
* \param regex The regexp to look for.
|
|
|
|
* \param file The file in which to look for the expression.
|
|
|
|
* \param ... Positional parameters to the regex.
|
|
|
|
*
|
|
|
|
* \return True if there is a match; false otherwise. */
|
|
|
|
bool
|
|
|
|
atf_utils_grep_file(const char *regex, const char *file, ...)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
va_list ap;
|
|
|
|
atf_dynstr_t formatted;
|
|
|
|
atf_error_t error;
|
|
|
|
|
|
|
|
va_start(ap, file);
|
|
|
|
error = atf_dynstr_init_ap(&formatted, regex, ap);
|
|
|
|
va_end(ap);
|
|
|
|
ATF_REQUIRE(!atf_is_error(error));
|
|
|
|
|
|
|
|
ATF_REQUIRE((fd = open(file, O_RDONLY)) != -1);
|
|
|
|
bool found = false;
|
|
|
|
char *line = NULL;
|
|
|
|
while (!found && (line = atf_utils_readline(fd)) != NULL) {
|
|
|
|
found = grep_string(atf_dynstr_cstring(&formatted), line);
|
|
|
|
free(line);
|
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
atf_dynstr_fini(&formatted);
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Searches for a regexp in a string.
|
|
|
|
*
|
|
|
|
* \param regex The regexp to look for.
|
|
|
|
* \param str The string in which to look for the expression.
|
|
|
|
* \param ... Positional parameters to the regex.
|
|
|
|
*
|
|
|
|
* \return True if there is a match; false otherwise. */
|
|
|
|
bool
|
|
|
|
atf_utils_grep_string(const char *regex, const char *str, ...)
|
|
|
|
{
|
|
|
|
bool res;
|
|
|
|
va_list ap;
|
|
|
|
atf_dynstr_t formatted;
|
|
|
|
atf_error_t error;
|
|
|
|
|
|
|
|
va_start(ap, str);
|
|
|
|
error = atf_dynstr_init_ap(&formatted, regex, ap);
|
|
|
|
va_end(ap);
|
|
|
|
ATF_REQUIRE(!atf_is_error(error));
|
|
|
|
|
|
|
|
res = grep_string(atf_dynstr_cstring(&formatted), str);
|
|
|
|
|
|
|
|
atf_dynstr_fini(&formatted);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Reads a line of arbitrary length.
|
|
|
|
*
|
|
|
|
* \param fd The descriptor from which to read the line.
|
|
|
|
*
|
|
|
|
* \return A pointer to the read line, which must be released with free(), or
|
|
|
|
* NULL if there was nothing to read from the file. */
|
|
|
|
char *
|
|
|
|
atf_utils_readline(const int fd)
|
|
|
|
{
|
|
|
|
char ch;
|
|
|
|
ssize_t cnt;
|
|
|
|
atf_dynstr_t temp;
|
|
|
|
atf_error_t error;
|
|
|
|
|
|
|
|
error = atf_dynstr_init(&temp);
|
|
|
|
ATF_REQUIRE(!atf_is_error(error));
|
|
|
|
|
|
|
|
while ((cnt = read(fd, &ch, sizeof(ch))) == sizeof(ch) &&
|
|
|
|
ch != '\n') {
|
|
|
|
error = atf_dynstr_append_fmt(&temp, "%c", ch);
|
|
|
|
ATF_REQUIRE(!atf_is_error(error));
|
|
|
|
}
|
|
|
|
ATF_REQUIRE(cnt != -1);
|
|
|
|
|
|
|
|
if (cnt == 0 && atf_dynstr_length(&temp) == 0) {
|
|
|
|
atf_dynstr_fini(&temp);
|
|
|
|
return NULL;
|
|
|
|
} else
|
|
|
|
return atf_dynstr_fini_disown(&temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Redirects a file descriptor to a file.
|
|
|
|
*
|
|
|
|
* \param target_fd The file descriptor to be replaced.
|
|
|
|
* \param name The name of the file to direct the descriptor to.
|
|
|
|
*
|
|
|
|
* \pre Should only be called from the process spawned by fork_for_testing
|
|
|
|
* because this exits uncontrolledly.
|
|
|
|
* \post Terminates execution if the redirection fails. */
|
|
|
|
void
|
|
|
|
atf_utils_redirect(const int target_fd, const char *name)
|
|
|
|
{
|
|
|
|
if (target_fd == STDOUT_FILENO)
|
|
|
|
fflush(stdout);
|
|
|
|
else if (target_fd == STDERR_FILENO)
|
|
|
|
fflush(stderr);
|
|
|
|
|
|
|
|
const int new_fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
|
|
|
if (new_fd == -1)
|
|
|
|
err(EXIT_FAILURE, "Cannot create %s", name);
|
|
|
|
if (new_fd != target_fd) {
|
|
|
|
if (dup2(new_fd, target_fd) == -1)
|
|
|
|
err(EXIT_FAILURE, "Cannot redirect to fd %d", target_fd);
|
|
|
|
}
|
|
|
|
close(new_fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Waits for a subprocess and validates its exit condition.
|
|
|
|
*
|
|
|
|
* \param pid The process to be waited for. Must have been started by
|
|
|
|
* testutils_fork().
|
|
|
|
* \param exitstatus Expected exit status.
|
|
|
|
* \param expout Expected contents of stdout.
|
|
|
|
* \param experr Expected contents of stderr. */
|
|
|
|
void
|
|
|
|
atf_utils_wait(const pid_t pid, const int exitstatus, const char *expout,
|
|
|
|
const char *experr)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
ATF_REQUIRE(waitpid(pid, &status, 0) != -1);
|
|
|
|
|
Import atf-0.21:
Released on October 23rd, 2014.
* Restored the atf(7) manual page to serve as a reference to all the other
manual pages shipped by ATF.
* Added the -s flag to atf-sh to support specifying the shell interpreter
to be used.
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
use the standard TMPDIR environment variable. As a benefit, and because
Kyua forces the TMPDIR to live within the test case's work directory,
any stale files left behind by ATF will be automatically cleaned up.
* Documented the environment variables recognized by each component in the
relevant manual pages. This information was lost with the atf-config(1)
removal.
* Added a new "require.diskspace" metadata property to test cases so that
they can specify the minimum amount of disk space required for the test
to run.
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
discoverability purposes. Symbolic links are provided for the time
being to still make the old names visible.
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
macros in the manual pages.
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
propagates the crash to the caller, which in turn allows it to obtain
proper debugging information. In particular, Kyua should now be able to
extract a stacktrace pinpointing the problem.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
explaining how they relate to each other.
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
initially added as a way to enable a "strict" mode in the library and to
make test cases fail fast when they run unprotected commands. However,
doing so in the library is surprising as the responsibility of enabling
'set -e' should be on the user's code. Also, 'set -e' introduces
inconsistent behavior on subshells and users do not expect that.
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
* Issue #16: Fixed test failures (by removing a long-standing hack) on
systems that lack \e support in printf(1).
* Issue #19: Removed stale references to atf-config and atf-run.
2014-10-30 17:14:07 +00:00
|
|
|
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: ");
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
|
|
|
|
ATF_REQUIRE(WIFEXITED(status));
|
|
|
|
ATF_REQUIRE_EQ(exitstatus, WEXITSTATUS(status));
|
|
|
|
|
|
|
|
const char *save_prefix = "save:";
|
|
|
|
const size_t save_prefix_length = strlen(save_prefix);
|
|
|
|
|
|
|
|
if (strlen(expout) > save_prefix_length &&
|
|
|
|
strncmp(expout, save_prefix, save_prefix_length) == 0) {
|
Import atf-0.21:
Released on October 23rd, 2014.
* Restored the atf(7) manual page to serve as a reference to all the other
manual pages shipped by ATF.
* Added the -s flag to atf-sh to support specifying the shell interpreter
to be used.
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
use the standard TMPDIR environment variable. As a benefit, and because
Kyua forces the TMPDIR to live within the test case's work directory,
any stale files left behind by ATF will be automatically cleaned up.
* Documented the environment variables recognized by each component in the
relevant manual pages. This information was lost with the atf-config(1)
removal.
* Added a new "require.diskspace" metadata property to test cases so that
they can specify the minimum amount of disk space required for the test
to run.
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
discoverability purposes. Symbolic links are provided for the time
being to still make the old names visible.
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
macros in the manual pages.
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
propagates the crash to the caller, which in turn allows it to obtain
proper debugging information. In particular, Kyua should now be able to
extract a stacktrace pinpointing the problem.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
explaining how they relate to each other.
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
initially added as a way to enable a "strict" mode in the library and to
make test cases fail fast when they run unprotected commands. However,
doing so in the library is surprising as the responsibility of enabling
'set -e' should be on the user's code. Also, 'set -e' introduces
inconsistent behavior on subshells and users do not expect that.
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
* Issue #16: Fixed test failures (by removing a long-standing hack) on
systems that lack \e support in printf(1).
* Issue #19: Removed stale references to atf-config and atf-run.
2014-10-30 17:14:07 +00:00
|
|
|
atf_utils_copy_file(atf_dynstr_cstring(&out_name),
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
expout + save_prefix_length);
|
|
|
|
} else {
|
Import atf-0.21:
Released on October 23rd, 2014.
* Restored the atf(7) manual page to serve as a reference to all the other
manual pages shipped by ATF.
* Added the -s flag to atf-sh to support specifying the shell interpreter
to be used.
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
use the standard TMPDIR environment variable. As a benefit, and because
Kyua forces the TMPDIR to live within the test case's work directory,
any stale files left behind by ATF will be automatically cleaned up.
* Documented the environment variables recognized by each component in the
relevant manual pages. This information was lost with the atf-config(1)
removal.
* Added a new "require.diskspace" metadata property to test cases so that
they can specify the minimum amount of disk space required for the test
to run.
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
discoverability purposes. Symbolic links are provided for the time
being to still make the old names visible.
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
macros in the manual pages.
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
propagates the crash to the caller, which in turn allows it to obtain
proper debugging information. In particular, Kyua should now be able to
extract a stacktrace pinpointing the problem.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
explaining how they relate to each other.
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
initially added as a way to enable a "strict" mode in the library and to
make test cases fail fast when they run unprotected commands. However,
doing so in the library is surprising as the responsibility of enabling
'set -e' should be on the user's code. Also, 'set -e' introduces
inconsistent behavior on subshells and users do not expect that.
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
* Issue #16: Fixed test failures (by removing a long-standing hack) on
systems that lack \e support in printf(1).
* Issue #19: Removed stale references to atf-config and atf-run.
2014-10-30 17:14:07 +00:00
|
|
|
ATF_REQUIRE(atf_utils_compare_file(atf_dynstr_cstring(&out_name),
|
|
|
|
expout));
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(experr) > save_prefix_length &&
|
|
|
|
strncmp(experr, save_prefix, save_prefix_length) == 0) {
|
Import atf-0.21:
Released on October 23rd, 2014.
* Restored the atf(7) manual page to serve as a reference to all the other
manual pages shipped by ATF.
* Added the -s flag to atf-sh to support specifying the shell interpreter
to be used.
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
use the standard TMPDIR environment variable. As a benefit, and because
Kyua forces the TMPDIR to live within the test case's work directory,
any stale files left behind by ATF will be automatically cleaned up.
* Documented the environment variables recognized by each component in the
relevant manual pages. This information was lost with the atf-config(1)
removal.
* Added a new "require.diskspace" metadata property to test cases so that
they can specify the minimum amount of disk space required for the test
to run.
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
discoverability purposes. Symbolic links are provided for the time
being to still make the old names visible.
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
macros in the manual pages.
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
propagates the crash to the caller, which in turn allows it to obtain
proper debugging information. In particular, Kyua should now be able to
extract a stacktrace pinpointing the problem.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
explaining how they relate to each other.
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
initially added as a way to enable a "strict" mode in the library and to
make test cases fail fast when they run unprotected commands. However,
doing so in the library is surprising as the responsibility of enabling
'set -e' should be on the user's code. Also, 'set -e' introduces
inconsistent behavior on subshells and users do not expect that.
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
* Issue #16: Fixed test failures (by removing a long-standing hack) on
systems that lack \e support in printf(1).
* Issue #19: Removed stale references to atf-config and atf-run.
2014-10-30 17:14:07 +00:00
|
|
|
atf_utils_copy_file(atf_dynstr_cstring(&err_name),
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
experr + save_prefix_length);
|
|
|
|
} else {
|
Import atf-0.21:
Released on October 23rd, 2014.
* Restored the atf(7) manual page to serve as a reference to all the other
manual pages shipped by ATF.
* Added the -s flag to atf-sh to support specifying the shell interpreter
to be used.
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
use the standard TMPDIR environment variable. As a benefit, and because
Kyua forces the TMPDIR to live within the test case's work directory,
any stale files left behind by ATF will be automatically cleaned up.
* Documented the environment variables recognized by each component in the
relevant manual pages. This information was lost with the atf-config(1)
removal.
* Added a new "require.diskspace" metadata property to test cases so that
they can specify the minimum amount of disk space required for the test
to run.
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
discoverability purposes. Symbolic links are provided for the time
being to still make the old names visible.
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
macros in the manual pages.
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
propagates the crash to the caller, which in turn allows it to obtain
proper debugging information. In particular, Kyua should now be able to
extract a stacktrace pinpointing the problem.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
explaining how they relate to each other.
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
initially added as a way to enable a "strict" mode in the library and to
make test cases fail fast when they run unprotected commands. However,
doing so in the library is surprising as the responsibility of enabling
'set -e' should be on the user's code. Also, 'set -e' introduces
inconsistent behavior on subshells and users do not expect that.
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
* Issue #16: Fixed test failures (by removing a long-standing hack) on
systems that lack \e support in printf(1).
* Issue #19: Removed stale references to atf-config and atf-run.
2014-10-30 17:14:07 +00:00
|
|
|
ATF_REQUIRE(atf_utils_compare_file(atf_dynstr_cstring(&err_name),
|
|
|
|
experr));
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
}
|
|
|
|
|
Import atf-0.21:
Released on October 23rd, 2014.
* Restored the atf(7) manual page to serve as a reference to all the other
manual pages shipped by ATF.
* Added the -s flag to atf-sh to support specifying the shell interpreter
to be used.
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
use the standard TMPDIR environment variable. As a benefit, and because
Kyua forces the TMPDIR to live within the test case's work directory,
any stale files left behind by ATF will be automatically cleaned up.
* Documented the environment variables recognized by each component in the
relevant manual pages. This information was lost with the atf-config(1)
removal.
* Added a new "require.diskspace" metadata property to test cases so that
they can specify the minimum amount of disk space required for the test
to run.
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
discoverability purposes. Symbolic links are provided for the time
being to still make the old names visible.
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
macros in the manual pages.
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
propagates the crash to the caller, which in turn allows it to obtain
proper debugging information. In particular, Kyua should now be able to
extract a stacktrace pinpointing the problem.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
explaining how they relate to each other.
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
initially added as a way to enable a "strict" mode in the library and to
make test cases fail fast when they run unprotected commands. However,
doing so in the library is surprising as the responsibility of enabling
'set -e' should be on the user's code. Also, 'set -e' introduces
inconsistent behavior on subshells and users do not expect that.
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
* Issue #16: Fixed test failures (by removing a long-standing hack) on
systems that lack \e support in printf(1).
* Issue #19: Removed stale references to atf-config and atf-run.
2014-10-30 17:14:07 +00:00
|
|
|
ATF_REQUIRE(unlink(atf_dynstr_cstring(&out_name)) != -1);
|
|
|
|
ATF_REQUIRE(unlink(atf_dynstr_cstring(&err_name)) != -1);
|
Import atf-0.17:
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* X-NetBSD-PR bin/45690: Make atf-report convert any non-printable
characters to a plain-text representation (matching their
corresponding hexadecimal entities) in XML output files. This is to
prevent the output of test cases from breaking xsltproc later.
Note that this import, compared to the one for 0.16, brings in all the
files that are part of the release. This is to follow the Subversion
Primer guidelines, which mention that all files should be imported first
and only dropped when merging into contrib/atf/.
Approved by: rpaulo (mentor)
2013-11-15 21:28:06 +00:00
|
|
|
}
|