Home | History | Annotate | Line # | Download | only in detail
      1  1.1  jmmv /*
      2  1.1  jmmv  * Automated Testing Framework (atf)
      3  1.1  jmmv  *
      4  1.3  jmmv  * Copyright (c) 2008 The NetBSD Foundation, Inc.
      5  1.1  jmmv  * All rights reserved.
      6  1.1  jmmv  *
      7  1.1  jmmv  * Redistribution and use in source and binary forms, with or without
      8  1.1  jmmv  * modification, are permitted provided that the following conditions
      9  1.1  jmmv  * are met:
     10  1.1  jmmv  * 1. Redistributions of source code must retain the above copyright
     11  1.1  jmmv  *    notice, this list of conditions and the following disclaimer.
     12  1.1  jmmv  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  jmmv  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  jmmv  *    documentation and/or other materials provided with the distribution.
     15  1.1  jmmv  *
     16  1.1  jmmv  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
     17  1.1  jmmv  * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
     18  1.1  jmmv  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     19  1.1  jmmv  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  1.1  jmmv  * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
     21  1.1  jmmv  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22  1.1  jmmv  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     23  1.1  jmmv  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24  1.1  jmmv  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
     25  1.1  jmmv  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     26  1.1  jmmv  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
     27  1.1  jmmv  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  1.1  jmmv  */
     29  1.1  jmmv 
     30  1.1  jmmv #if !defined(ATF_C_PROCESS_H)
     31  1.1  jmmv #define ATF_C_PROCESS_H
     32  1.1  jmmv 
     33  1.1  jmmv #include <sys/types.h>
     34  1.1  jmmv 
     35  1.1  jmmv #include <stdbool.h>
     36  1.1  jmmv 
     37  1.1  jmmv #include <atf-c/error_fwd.h>
     38  1.1  jmmv 
     39  1.1  jmmv #include "fs.h"
     40  1.1  jmmv #include "list.h"
     41  1.1  jmmv 
     42  1.1  jmmv /* ---------------------------------------------------------------------
     43  1.1  jmmv  * The "atf_process_stream" type.
     44  1.1  jmmv  * --------------------------------------------------------------------- */
     45  1.1  jmmv 
     46  1.1  jmmv struct atf_process_stream {
     47  1.1  jmmv     int m_type;
     48  1.1  jmmv 
     49  1.1  jmmv     /* Valid if m_type == connect. */
     50  1.1  jmmv     int m_src_fd;
     51  1.1  jmmv     int m_tgt_fd;
     52  1.1  jmmv 
     53  1.1  jmmv     /* Valid if m_type == redirect_fd. */
     54  1.1  jmmv     int m_fd;
     55  1.1  jmmv 
     56  1.1  jmmv     /* Valid if m_type == redirect_path. */
     57  1.1  jmmv     const atf_fs_path_t *m_path;
     58  1.1  jmmv };
     59  1.1  jmmv typedef struct atf_process_stream atf_process_stream_t;
     60  1.1  jmmv 
     61  1.1  jmmv extern const int atf_process_stream_type_capture;
     62  1.1  jmmv extern const int atf_process_stream_type_connect;
     63  1.1  jmmv extern const int atf_process_stream_type_inherit;
     64  1.1  jmmv extern const int atf_process_stream_type_redirect_fd;
     65  1.1  jmmv extern const int atf_process_stream_type_redirect_path;
     66  1.1  jmmv 
     67  1.1  jmmv atf_error_t atf_process_stream_init_capture(atf_process_stream_t *);
     68  1.1  jmmv atf_error_t atf_process_stream_init_connect(atf_process_stream_t *,
     69  1.1  jmmv                                             const int, const int);
     70  1.1  jmmv atf_error_t atf_process_stream_init_inherit(atf_process_stream_t *);
     71  1.1  jmmv atf_error_t atf_process_stream_init_redirect_fd(atf_process_stream_t *,
     72  1.1  jmmv                                                 const int fd);
     73  1.1  jmmv atf_error_t atf_process_stream_init_redirect_path(atf_process_stream_t *,
     74  1.1  jmmv                                                   const atf_fs_path_t *);
     75  1.1  jmmv void atf_process_stream_fini(atf_process_stream_t *);
     76  1.1  jmmv 
     77  1.1  jmmv int atf_process_stream_type(const atf_process_stream_t *);
     78  1.1  jmmv 
     79  1.1  jmmv /* ---------------------------------------------------------------------
     80  1.1  jmmv  * The "atf_process_status" type.
     81  1.1  jmmv  * --------------------------------------------------------------------- */
     82  1.1  jmmv 
     83  1.1  jmmv struct atf_process_status {
     84  1.1  jmmv     int m_status;
     85  1.1  jmmv };
     86  1.1  jmmv typedef struct atf_process_status atf_process_status_t;
     87  1.1  jmmv 
     88  1.1  jmmv void atf_process_status_fini(atf_process_status_t *);
     89  1.1  jmmv 
     90  1.1  jmmv bool atf_process_status_exited(const atf_process_status_t *);
     91  1.1  jmmv int atf_process_status_exitstatus(const atf_process_status_t *);
     92  1.1  jmmv bool atf_process_status_signaled(const atf_process_status_t *);
     93  1.1  jmmv int atf_process_status_termsig(const atf_process_status_t *);
     94  1.1  jmmv bool atf_process_status_coredump(const atf_process_status_t *);
     95  1.1  jmmv 
     96  1.1  jmmv /* ---------------------------------------------------------------------
     97  1.1  jmmv  * The "atf_process_child" type.
     98  1.1  jmmv  * --------------------------------------------------------------------- */
     99  1.1  jmmv 
    100  1.1  jmmv struct atf_process_child {
    101  1.1  jmmv     pid_t m_pid;
    102  1.1  jmmv 
    103  1.1  jmmv     int m_stdout;
    104  1.1  jmmv     int m_stderr;
    105  1.1  jmmv };
    106  1.1  jmmv typedef struct atf_process_child atf_process_child_t;
    107  1.1  jmmv 
    108  1.1  jmmv atf_error_t atf_process_child_wait(atf_process_child_t *,
    109  1.1  jmmv                                    atf_process_status_t *);
    110  1.1  jmmv pid_t atf_process_child_pid(const atf_process_child_t *);
    111  1.1  jmmv int atf_process_child_stdout(atf_process_child_t *);
    112  1.1  jmmv int atf_process_child_stderr(atf_process_child_t *);
    113  1.1  jmmv 
    114  1.1  jmmv /* ---------------------------------------------------------------------
    115  1.1  jmmv  * Free functions.
    116  1.1  jmmv  * --------------------------------------------------------------------- */
    117  1.1  jmmv 
    118  1.1  jmmv atf_error_t atf_process_fork(atf_process_child_t *,
    119  1.1  jmmv                              void (*)(void *),
    120  1.1  jmmv                              const atf_process_stream_t *,
    121  1.1  jmmv                              const atf_process_stream_t *,
    122  1.1  jmmv                              void *);
    123  1.1  jmmv atf_error_t atf_process_exec_array(atf_process_status_t *,
    124  1.1  jmmv                                    const atf_fs_path_t *,
    125  1.1  jmmv                                    const char *const *,
    126  1.1  jmmv                                    const atf_process_stream_t *,
    127  1.2  jmmv                                    const atf_process_stream_t *,
    128  1.2  jmmv                                    void (*)(void));
    129  1.1  jmmv atf_error_t atf_process_exec_list(atf_process_status_t *,
    130  1.1  jmmv                                   const atf_fs_path_t *,
    131  1.1  jmmv                                   const atf_list_t *,
    132  1.1  jmmv                                   const atf_process_stream_t *,
    133  1.2  jmmv                                   const atf_process_stream_t *,
    134  1.2  jmmv                                   void (*)(void));
    135  1.1  jmmv 
    136  1.1  jmmv #endif /* !defined(ATF_C_PROCESS_H) */
    137