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
,
56 void close(const close_t
& arg
);
57 void dup_for_spawn(const close_t
& arg
,
58 posix_spawn_file_actions_t
& file_actions
,
69 Application(const std::string
& arg
, const bool _use_libtool_arg
= false);
71 virtual ~Application();
73 void add_option(const std::string
&);
74 void add_option(const std::string
&, const std::string
&);
75 void add_long_option(const std::string
& option_name
, const std::string
& option_value
);
76 error_t
run(const char *args
[]= NULL
);
79 libtest::vchar_t
stdout_result() const
81 return _stdout_buffer
;
84 size_t stdout_result_length() const
86 return _stdout_buffer
.size();
89 libtest::vchar_t
stderr_result() const
91 return _stderr_buffer
;
94 size_t stderr_result_length() const
96 return _stderr_buffer
.size();
101 void use_valgrind(bool arg
= true)
111 void use_gdb(bool arg
= true)
116 std::string
arguments();
118 std::string
gdb_filename()
120 return _gdb_filename
;
124 void create_argv(const char *args
[]);
128 const bool _use_libtool
;
132 std::string _exectuble_name
;
133 std::string _exectuble
;
134 std::string _exectuble_with_path
;
135 std::string _gdb_filename
;
142 libtest::vchar_t _stdout_buffer
;
143 libtest::vchar_t _stderr_buffer
;
146 static inline std::ostream
& operator<<(std::ostream
& output
, const enum Application::error_t
&arg
)
150 case Application::SUCCESS
:
151 output
<< "EXIT_SUCCESS";
154 case Application::FAILURE
:
155 output
<< "EXIT_FAILURE";
158 case Application::INVALID
:
163 output
<< "EXIT_UNKNOWN";
169 int exec_cmdline(const std::string
& executable
, const char *args
[], bool use_libtool
= false);
171 const char *gearmand_binary();