2 * Automated Testing Framework (atf)
4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #if !defined(ATF_C_PROCESS_H)
31 #define ATF_C_PROCESS_H
33 #include <sys/types.h>
37 #include <atf-c/error_fwd.h>
39 #include <atf-c/list.h>
40 #include <atf-c/object.h>
42 /* ---------------------------------------------------------------------
43 * The "atf_process_stream" type.
44 * --------------------------------------------------------------------- */
46 struct atf_process_stream
{
47 atf_object_t m_object
;
51 /* Valid if m_type == connect. */
55 /* Valid if m_type == redirect_fd. */
58 /* Valid if m_type == redirect_path. */
59 const atf_fs_path_t
*m_path
;
61 typedef struct atf_process_stream atf_process_stream_t
;
63 extern const int atf_process_stream_type_capture
;
64 extern const int atf_process_stream_type_connect
;
65 extern const int atf_process_stream_type_inherit
;
66 extern const int atf_process_stream_type_redirect_fd
;
67 extern const int atf_process_stream_type_redirect_path
;
69 atf_error_t
atf_process_stream_init_capture(atf_process_stream_t
*);
70 atf_error_t
atf_process_stream_init_connect(atf_process_stream_t
*,
71 const int, const int);
72 atf_error_t
atf_process_stream_init_inherit(atf_process_stream_t
*);
73 atf_error_t
atf_process_stream_init_redirect_fd(atf_process_stream_t
*,
75 atf_error_t
atf_process_stream_init_redirect_path(atf_process_stream_t
*,
76 const atf_fs_path_t
*);
77 void atf_process_stream_fini(atf_process_stream_t
*);
79 int atf_process_stream_type(const atf_process_stream_t
*);
81 /* ---------------------------------------------------------------------
82 * The "atf_process_status" type.
83 * --------------------------------------------------------------------- */
85 struct atf_process_status
{
86 atf_object_t m_object
;
90 typedef struct atf_process_status atf_process_status_t
;
92 void atf_process_status_fini(atf_process_status_t
*);
94 bool atf_process_status_exited(const atf_process_status_t
*);
95 int atf_process_status_exitstatus(const atf_process_status_t
*);
96 bool atf_process_status_signaled(const atf_process_status_t
*);
97 int atf_process_status_termsig(const atf_process_status_t
*);
98 bool atf_process_status_coredump(const atf_process_status_t
*);
100 /* ---------------------------------------------------------------------
101 * The "atf_process_child" type.
102 * --------------------------------------------------------------------- */
104 struct atf_process_child
{
105 atf_object_t m_object
;
112 typedef struct atf_process_child atf_process_child_t
;
114 atf_error_t
atf_process_child_wait(atf_process_child_t
*,
115 atf_process_status_t
*);
116 pid_t
atf_process_child_pid(const atf_process_child_t
*);
117 int atf_process_child_stdout(atf_process_child_t
*);
118 int atf_process_child_stderr(atf_process_child_t
*);
120 /* ---------------------------------------------------------------------
122 * --------------------------------------------------------------------- */
124 atf_error_t
atf_process_fork(atf_process_child_t
*,
126 const atf_process_stream_t
*,
127 const atf_process_stream_t
*,
129 atf_error_t
atf_process_exec_array(atf_process_status_t
*,
130 const atf_fs_path_t
*,
132 const atf_process_stream_t
*,
133 const atf_process_stream_t
*);
134 atf_error_t
atf_process_exec_list(atf_process_status_t
*,
135 const atf_fs_path_t
*,
137 const atf_process_stream_t
*,
138 const atf_process_stream_t
*);
140 #endif /* !defined(ATF_C_PROCESS_H) */