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 const char* stderr_c_str() const
95 return &_stderr_buffer
[0];
98 size_t stderr_result_length() const
100 return _stderr_buffer
.size();
105 void use_valgrind(bool arg
= true)
115 void use_gdb(bool arg
= true)
120 void use_ptrcheck(bool arg
= true)
125 std::string
arguments();
127 std::string
gdb_filename()
129 return _gdb_filename
;
138 void create_argv(const char *args
[]);
142 const bool _use_libtool
;
147 std::string _exectuble_name
;
148 std::string _exectuble
;
149 std::string _exectuble_with_path
;
150 std::string _gdb_filename
;
157 libtest::vchar_t _stdout_buffer
;
158 libtest::vchar_t _stderr_buffer
;
161 static inline std::ostream
& operator<<(std::ostream
& output
, const enum Application::error_t
&arg
)
165 case Application::SUCCESS
:
166 output
<< "EXIT_SUCCESS";
169 case Application::FAILURE
:
170 output
<< "EXIT_FAILURE";
173 case Application::INVALID
:
178 output
<< "EXIT_UNKNOWN";
184 int exec_cmdline(const std::string
& executable
, const char *args
[], bool use_libtool
= false);
186 const char *gearmand_binary();