+ _base_command+= "./libtool --mode=execute ";
+ }
+
+ if (is_debug())
+ {
+ _base_command+= "gdb ";
+ }
+ else if (is_valgrind())
+ {
+ _base_command+= "valgrind --log-file=tests/var/tmp/valgrind.out --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE ";
+
+ }
+ else if (is_helgrind())
+ {
+ _base_command+= "valgrind --log-file=tests/var/tmp/helgrind.out --tool=helgrind --read-var-info=yes --error-exitcode=1 -v ";
+ }
+
+ _base_command+= executable();
+}
+
+void Server::set_extra_args(const std::string &arg)
+{
+ _extra_args= arg;
+}
+
+bool Server::args(std::string& options)
+{
+ std::stringstream arg_buffer;
+
+ // Set a log file if it was requested (and we can)
+ if (getenv("LIBTEST_LOG") and log_file_option())
+ {
+ if (not set_log_file())
+ return false;
+
+ arg_buffer << " " << log_file_option() << _log_file;
+ }
+
+ // Update pid_file
+ if (pid_file_option())
+ {
+ if (not set_pid_file())
+ return false;
+
+ arg_buffer << " " << pid_file_option() << pid_file();
+ }
+
+ assert(daemon_file_option());
+ if (daemon_file_option() and not is_valgrind() and not is_helgrind())
+ {
+ arg_buffer << " " << daemon_file_option();
+ }
+
+ if (_is_socket and socket_file_option())
+ {
+ if (not set_socket_file())
+ return false;
+
+ arg_buffer << " " << socket_file_option() << "\"" << _socket << "\"";
+ }
+
+ assert(port_option());
+ if (port_option() and _port > 0)
+ {
+ arg_buffer << " " << port_option() << _port;
+ }
+
+ options+= arg_buffer.str();
+
+ if (not _extra_args.empty())
+ options+= _extra_args;
+
+ return true;
+}
+
+bool Server::is_debug() const
+{
+ return bool(getenv("LIBTEST_MANUAL_GDB"));
+}
+
+bool Server::is_valgrind() const
+{
+ return bool(getenv("LIBTEST_MANUAL_VALGRIND"));
+}
+
+bool Server::is_helgrind() const
+{
+ return bool(getenv("LIBTEST_MANUAL_HELGRIND"));
+}
+
+bool Server::kill(pid_t pid_arg)
+{
+ if (check_pid(pid_arg) and kill_pid(pid_arg)) // If we kill it, reset
+ {
+ if (broken_pid_file() and not pid_file().empty())