4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews/* Copyright (c) 2008 The NetBSD Foundation, Inc.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * All rights reserved.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Redistribution and use in source and binary forms, with or without
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * modification, are permitted provided that the following conditions
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * 1. Redistributions of source code must retain the above copyright
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * notice, this list of conditions and the following disclaimer.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * 2. Redistributions in binary form must reproduce the above copyright
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * notice, this list of conditions and the following disclaimer in the
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * documentation and/or other materials provided with the distribution.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntatf_error_t atf_process_status_init(atf_process_status_t *, int);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt/* ---------------------------------------------------------------------
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Auxiliary functions for testing of 'atf_process_fork'.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * --------------------------------------------------------------------- */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Testing of atf_process_fork is quite messy. We want to be able to test
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * all the possible combinations of stdout and stderr behavior to ensure
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * that the streams are manipulated correctly.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * To do this, the do_fork function is a wrapper for atf_process_fork that
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * issues stream-specific hooks before fork, while the child is running and
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * after the child terminates. We then provide test cases that just call
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * do_fork with different hooks.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * The hooks are described by base_stream, and we then have one *_stream
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * type for ever possible stream behavior.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* m_sb is initialized by subclasses that need it, but all consumers
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * must use m_sb_ptr, which may or may not point to m_sb. This allows
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * us to test the interface with a NULL value, which triggers a
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * default behavior. */
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK(atf_utils_grep_file("stdout: msg", "stdout"));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK(!atf_utils_grep_file("stderr: msg", "stdout"));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK(atf_utils_grep_file("stderr: msg", "stderr"));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK(!atf_utils_grep_file("stdout: msg", "stderr"));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt struct capture_stream *s = v;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_stream_init_capture(&s->m_base.m_sb));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntcapture_stream_process(void *v, atf_process_child_t *c)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt struct capture_stream *s = v;
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt s->m_msg = atf_utils_readline(atf_process_child_stdout(c));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt s->m_msg = atf_utils_readline(atf_process_child_stderr(c));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt struct capture_stream *s = v;
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK(atf_utils_grep_string("stdout: msg", s->m_msg));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK(!atf_utils_grep_string("stderr: msg", s->m_msg));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK(!atf_utils_grep_string("stdout: msg", s->m_msg));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK(atf_utils_grep_string("stderr: msg", s->m_msg));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt struct connect_stream *s = v;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt s->m_fd = open("stdout", O_WRONLY | O_CREAT | O_TRUNC, 0644);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt s->m_fd = open("stderr", O_WRONLY | O_CREAT | O_TRUNC, 0644);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_stream_init_connect(&s->m_base.m_sb, src_fd, s->m_fd));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt struct connect_stream *s = v;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt struct inherit_stream *s = v;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_stream_init_inherit(&s->m_base.m_sb));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_REQUIRE_EQ(open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644),
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt struct inherit_stream *s = v;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt struct inherit_stream *s = v;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt { .m_base = BASE_STREAM(redirect_fd_stream_init, \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt s->m_fd = open("stdout", O_WRONLY | O_CREAT | O_TRUNC, 0644);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt s->m_fd = open("stderr", O_WRONLY | O_CREAT | O_TRUNC, 0644);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_stream_init_redirect_fd(&s->m_base.m_sb, s->m_fd));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt { .m_base = BASE_STREAM(redirect_path_stream_init, \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_stream_init_redirect_path(&s->m_base.m_sb, &s->m_path));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntstatic void child_print(void *) ATF_DEFS_ATTRIBUTE_NORETURN;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdo_fork(const struct base_stream *outfs, void *out,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_fork(&child, child_print, outfs->m_sb_ptr,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt/* ---------------------------------------------------------------------
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Test cases for the "stream" type.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * --------------------------------------------------------------------- */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "atf_process_stream_init_capture function");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "atf_process_stream_init_connect function");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "atf_process_stream_init_inherit function");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "atf_process_stream_init_redirect_fd function");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "atf_process_stream_init_redirect_path function");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_stream_init_redirect_path(&sb, &path));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt/* ---------------------------------------------------------------------
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Test cases for the "status" type.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * --------------------------------------------------------------------- */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntstatic void child_exit_success(void) ATF_DEFS_ATTRIBUTE_NORETURN;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntstatic void child_exit_failure(void) ATF_DEFS_ATTRIBUTE_NORETURN;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntstatic void child_sigkill(void) ATF_DEFS_ATTRIBUTE_NORETURN;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntstatic void child_sigquit(void) ATF_DEFS_ATTRIBUTE_NORETURN;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntstatic void child_sigterm(void) ATF_DEFS_ATTRIBUTE_NORETURN;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (pid == 0) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_set_md_var(tc, "descr", "Tests the status type for processes "
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "that exit cleanly");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt const int rawstatus = fork_and_wait_child(child_exit_success);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(atf_process_status_exitstatus(&s), EXIT_SUCCESS);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt const int rawstatus = fork_and_wait_child(child_exit_failure);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(atf_process_status_exitstatus(&s), EXIT_FAILURE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_set_md_var(tc, "descr", "Tests the status type for processes "
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "that end due to a signal");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt const int rawstatus = fork_and_wait_child(child_sigkill);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(atf_process_status_termsig(&s), SIGKILL);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt const int rawstatus = fork_and_wait_child(child_sigterm);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(atf_process_status_termsig(&s), SIGTERM);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_set_md_var(tc, "descr", "Tests the status type for processes "
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "that crash");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_skip("Cannot unlimit the core file size; check limits "
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "manually");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt const int rawstatus = fork_and_wait_child(child_sigquit);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(atf_process_status_termsig(&s), SIGQUIT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt/* ---------------------------------------------------------------------
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Test cases for the "child" type.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * --------------------------------------------------------------------- */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntstatic void child_report_pid(void *) ATF_DEFS_ATTRIBUTE_NORETURN;
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Huntchild_report_pid(void *v ATF_DEFS_ATTRIBUTE_UNUSED)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (write(STDOUT_FILENO, &pid, sizeof(pid)) != sizeof(pid))
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt fprintf(stderr, "Reporting %d to parent\n", (int)getpid());
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_set_md_var(tc, "descr", "Tests the correctness of the pid "
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "stored in the child type");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_fork(&child, child_report_pid, &outsb, &errsb, NULL));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(read(atf_process_child_stdout(&child), &pid, sizeof(pid)),
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt printf("Expected PID: %d\n", (int)atf_process_child_pid(&child));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Huntchild_spawn_loop_and_wait_eintr(void *v ATF_DEFS_ATTRIBUTE_UNUSED)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE_ABORT(atf_process_stream_init_capture(&outsb));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE_ABORT(atf_process_stream_init_inherit(&errsb));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE_ABORT(atf_process_fork(&child, child_loop, &outsb, &errsb, NULL));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (sigaction(SIGHUP, &sighup, &old_sighup) == -1)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_error_t err = atf_process_child_wait(&child, &status);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt fprintf(stderr, "wait completed successfully (not interrupted)\n");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt fprintf(stderr, "wait did not raise libc_error\n");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE_ABORT(atf_process_child_wait(&child, &status));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_set_md_var(tc, "descr", "Tests the interruption of the wait "
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "method by an external signal, and the return of "
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "an EINTR error");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_fork(&child, child_spawn_loop_and_wait_eintr,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Wait until the child process performs the wait call. This is
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * racy, because the message we get from it is sent *before*
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * doing the real system call... but I can't figure any other way
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * to do this. */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_REQUIRE(read(atf_process_child_stdout(&child), buf,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sizeof(buf)) > 0);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_REQUIRE_EQ(atf_process_status_exitstatus(&status), EXIT_SUCCESS);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt/* ---------------------------------------------------------------------
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Tests cases for the free functions.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * --------------------------------------------------------------------- */
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Huntdo_exec(const atf_tc_t *tc, const char *helper_name, atf_process_status_t *s,
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt void (*prehook)(void))
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt get_process_helpers_path(tc, true, &process_helpers);
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt RE(atf_process_exec_array(s, &process_helpers, argv, NULL, NULL, prehook));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK_STREQ_MSG(exp, line, "read: '%s', expected: '%s'", line, exp);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_set_md_var(tc, "descr", "Tests execing a command");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(atf_process_status_exitstatus(&status), EXIT_FAILURE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_set_md_var(tc, "descr", "Tests execing a command");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt get_process_helpers_path(tc, true, &process_helpers);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_list_append(&argv, strdup(atf_fs_path_cstring(&process_helpers)), true);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_list_append(&argv, strdup("test-message"), true);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_stream_init_redirect_path(&outsb, &outpath));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_exec_list(&status, &process_helpers, &argv, &outsb,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(atf_process_status_exitstatus(&status), EXIT_SUCCESS);
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt atf_tc_set_md_var(tc, "descr", "Tests execing a command with a prehook");
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK_EQ(atf_process_status_exitstatus(&status), 80);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_set_md_var(tc, "descr", "Tests execing a command");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(atf_process_status_exitstatus(&status), EXIT_SUCCESS);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_set_md_var(tc, "descr", "Tests forking a child, with "
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "a null and non-null data cookie");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_fork(&child, child_cookie, &outsb, &errsb, NULL));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(atf_process_status_exitstatus(&status), exit_v_null);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt RE(atf_process_fork(&child, child_cookie, &outsb, &errsb, &dummy_int));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_EQ(atf_process_status_exitstatus(&status), exit_v_notnull);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#define TC_FORK_STREAMS(outlc, outuc, errlc, erruc) \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TC_HEAD(fork_out_ ## outlc ## _err_ ## errlc, tc) \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_set_md_var(tc, "descr", "Tests forking a child, with " \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TC_BODY(fork_out_ ## outlc ## _err_ ## errlc, tc) \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt struct outlc ## _stream out = outuc ## _STREAM(stdout_type); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt struct errlc ## _stream err = erruc ## _STREAM(stderr_type); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(capture, CAPTURE, capture, CAPTURE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(capture, CAPTURE, connect, CONNECT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(capture, CAPTURE, default, DEFAULT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(capture, CAPTURE, inherit, INHERIT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(capture, CAPTURE, redirect_fd, REDIRECT_FD);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(capture, CAPTURE, redirect_path, REDIRECT_PATH);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(connect, CONNECT, capture, CAPTURE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(connect, CONNECT, connect, CONNECT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(connect, CONNECT, default, DEFAULT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(connect, CONNECT, inherit, INHERIT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(connect, CONNECT, redirect_fd, REDIRECT_FD);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(connect, CONNECT, redirect_path, REDIRECT_PATH);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(default, DEFAULT, capture, CAPTURE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(default, DEFAULT, connect, CONNECT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(default, DEFAULT, default, DEFAULT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(default, DEFAULT, inherit, INHERIT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(default, DEFAULT, redirect_fd, REDIRECT_FD);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(default, DEFAULT, redirect_path, REDIRECT_PATH);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(inherit, INHERIT, capture, CAPTURE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(inherit, INHERIT, connect, CONNECT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(inherit, INHERIT, default, DEFAULT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(inherit, INHERIT, inherit, INHERIT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(inherit, INHERIT, redirect_fd, REDIRECT_FD);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(inherit, INHERIT, redirect_path, REDIRECT_PATH);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_fd, REDIRECT_FD, capture, CAPTURE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_fd, REDIRECT_FD, connect, CONNECT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_fd, REDIRECT_FD, default, DEFAULT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_fd, REDIRECT_FD, inherit, INHERIT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_fd, REDIRECT_FD, redirect_fd, REDIRECT_FD);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_fd, REDIRECT_FD, redirect_path, REDIRECT_PATH);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_path, REDIRECT_PATH, capture, CAPTURE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_path, REDIRECT_PATH, connect, CONNECT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_path, REDIRECT_PATH, default, DEFAULT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_path, REDIRECT_PATH, inherit, INHERIT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_path, REDIRECT_PATH, redirect_fd, REDIRECT_FD);
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntTC_FORK_STREAMS(redirect_path, REDIRECT_PATH, redirect_path, REDIRECT_PATH);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt/* ---------------------------------------------------------------------
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * --------------------------------------------------------------------- */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Add the tests for the "stream" type. */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Add the tests for the "status" type. */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Add the tests for the "child" type. */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Add the tests for the free functions. */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_capture_err_redirect_fd);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_capture_err_redirect_path);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_connect_err_redirect_fd);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_connect_err_redirect_path);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_default_err_redirect_fd);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_default_err_redirect_path);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_inherit_err_redirect_fd);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_inherit_err_redirect_path);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_fd_err_capture);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_fd_err_connect);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_fd_err_default);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_fd_err_inherit);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_fd_err_redirect_fd);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_fd_err_redirect_path);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_path_err_capture);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_path_err_connect);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_path_err_default);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_path_err_inherit);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_TP_ADD_TC(tp, fork_out_redirect_path_err_redirect_fd);