#include <climits>
#include <cstdlib>
#include <iostream>
+#include <string>
#include <algorithm>
#include <functional>
bool Server::check()
{
- _app.slurp();
- _app.check();
- return true;
+ _app.clear();
+ return _app.check();
}
bool Server::validate()
return wait.successful();
}
+bool Server::init(const char *argv[])
+{
+ if (argv)
+ {
+ for (const char **ptr= argv; *ptr ; ++ptr)
+ {
+ if (ptr)
+ {
+ add_option(*ptr);
+ }
+ }
+ }
+
+ return build();
+}
+
bool Server::has_pid() const
{
return (_app.pid() > 1);
bool Server::start()
{
- // If we find that we already have a pid then kill it.
- if (has_pid() == true)
- {
-#if 0
- fatal_message("has_pid() failed, programer error");
-#endif
- }
-
if (getenv("YATL_GDB_SERVER"))
{
_app.use_gdb(true);
if (pinged == false)
{
- Error << "ping(" << _app.pid() << ") wait: " << this_wait << " " << hostname() << ":" << port() << " run:" << _running << " " << error();
+#if 0
+ Error << "Failed to ping(" << _app.pid() << ") wait: " << this_wait << " " << hostname() << ":" << port() << " run:" << _running << " " << error();
+#endif
// If we happen to have a pid file, lets try to kill it
if ((pid_file().empty() == false) and (access(pid_file().c_str(), R_OK) == 0))
for (Options::const_iterator iter= _options.begin(); iter != _options.end(); ++iter)
{
- if ((*iter).second.empty() == false)
- {
- app.add_option((*iter).first, (*iter).second);
- }
- else
+ if ((*iter).first.empty() == false)
{
- app.add_option((*iter).first);
+ if ((*iter).second.empty() == false)
+ {
+ app.add_option((*iter).first, (*iter).second);
+ }
+ else
+ {
+ app.add_option((*iter).first);
+ }
}
}
return false;
}
+std::pair<std::string, std::string> Server::output()
+{
+ _app.slurp();
+ return {
+ std::string {
+ _app.stdout_result().data(),
+ _app.stdout_result().size()
+ },
+ std::string {
+ _app.stderr_result().data(),
+ _app.stderr_result().size()
+ }
+ };
+}
+
+
} // namespace libtest