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
,
67 Application(const std::string
& arg
, const bool _use_libtool_arg
= false);
69 virtual ~Application();
71 void add_option(const std::string
&);
72 void add_option(const std::string
&, const std::string
&);
73 error_t
run(const char *args
[]= NULL
);
76 libtest::vchar_t
stdout_result() const
78 return _stdout_buffer
;
81 size_t stdout_result_length() const
83 return _stdout_buffer
.size();
86 libtest::vchar_t
stderr_result() const
88 return _stderr_buffer
;
91 size_t stderr_result_length() const
93 return _stderr_buffer
.size();
99 void create_argv(const char *args
[]);
103 const bool _use_libtool
;
105 std::string _exectuble
;
106 std::string _exectuble_with_path
;
113 libtest::vchar_t _stdout_buffer
;
114 libtest::vchar_t _stderr_buffer
;
117 static inline std::ostream
& operator<<(std::ostream
& output
, const enum Application::error_t
&arg
)
121 case Application::SUCCESS
:
122 output
<< "EXIT_SUCCESS";
125 case Application::FAILURE
:
126 output
<< "EXIT_FAILURE";
129 case Application::INVALID
:
137 int exec_cmdline(const std::string
& executable
, const char *args
[], bool use_libtool
= false);
139 const char *gearmand_binary();