1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 3 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 typedef std::vector
< std::pair
<std::string
, std::string
> > Options
;
35 SUCCESS
= EXIT_SUCCESS
,
36 FAILURE
= EXIT_FAILURE
,
53 void close(const close_t
& arg
);
54 void dup_for_spawn(const close_t
& arg
,
55 posix_spawn_file_actions_t
& file_actions
);
59 bool read(libtest::vchar_t
&);
68 Application(const std::string
& arg
, const bool _use_libtool_arg
= false);
70 virtual ~Application();
72 void add_option(const std::string
&);
73 void add_option(const std::string
&, const std::string
&);
74 void add_long_option(const std::string
& option_name
, const std::string
& option_value
);
75 error_t
run(const char *args
[]= NULL
);
76 error_t
wait(bool nohang
= true);
78 libtest::vchar_t
stdout_result() const
80 return _stdout_buffer
;
83 size_t stdout_result_length() const
85 return _stdout_buffer
.size();
88 libtest::vchar_t
stderr_result() const
90 return _stderr_buffer
;
93 size_t stderr_result_length() const
95 return _stderr_buffer
.size();
100 void use_valgrind(bool arg
= true)
110 void use_gdb(bool arg
= true)
115 std::string
arguments();
117 std::string
gdb_filename()
119 return _gdb_filename
;
128 void create_argv(const char *args
[]);
132 const bool _use_libtool
;
136 std::string _exectuble_name
;
137 std::string _exectuble
;
138 std::string _exectuble_with_path
;
139 std::string _gdb_filename
;
146 libtest::vchar_t _stdout_buffer
;
147 libtest::vchar_t _stderr_buffer
;
150 static inline std::ostream
& operator<<(std::ostream
& output
, const enum Application::error_t
&arg
)
154 case Application::SUCCESS
:
155 output
<< "EXIT_SUCCESS";
158 case Application::FAILURE
:
159 output
<< "EXIT_FAILURE";
162 case Application::INVALID
:
167 output
<< "EXIT_UNKNOWN";
173 int exec_cmdline(const std::string
& executable
, const char *args
[], bool use_libtool
= false);
175 const char *gearmand_binary();