Merge in tests for SASL
[awesomized/libmemcached] / libtest / server_container.h
1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * libtest
4 *
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 *
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.
11 *
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.
16 *
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
20 */
21
22 #pragma once
23
24 #include <cassert>
25 #include <cstdio>
26 #include <cstring>
27 #include <netdb.h>
28 #include <netinet/in.h>
29 #include <string>
30 #include <unistd.h>
31 #include <vector>
32
33 namespace libtest {
34
35 class server_startup_st
36 {
37 private:
38 std::string server_list;
39 bool _socket;
40 bool _sasl;
41 std::string _username;
42 std::string _password;
43
44 public:
45
46 uint8_t udp;
47 std::vector<Server *> servers;
48
49 server_startup_st() :
50 _socket(false),
51 _sasl(false),
52 udp(0)
53 { }
54
55 bool start_socket_server(const std::string& server_type, const in_port_t try_port, int argc, const char *argv[]);
56
57 std::string option_string() const;
58
59 size_t count() const
60 {
61 return servers.size();
62 }
63
64 const std::string& password() const
65 {
66 return _password;
67 }
68
69 const std::string& username() const
70 {
71 return _username;
72 }
73
74
75 bool is_debug() const;
76 bool is_helgrind() const;
77 bool is_valgrind() const;
78
79 bool socket()
80 {
81 return _socket;
82 }
83
84 bool sasl()
85 {
86 return _sasl;
87 }
88
89 void set_socket()
90 {
91 _socket= true;
92 }
93
94 void set_sasl(const std::string& username_arg, const std::string& password_arg)
95 {
96 _sasl= true;
97 _username= username_arg;
98 _password= password_arg;
99 }
100
101
102 void shutdown(bool remove= false);
103 void push_server(Server *);
104 Server *pop_server();
105
106 ~server_startup_st();
107 };
108
109 bool server_startup(server_startup_st&, const std::string&, in_port_t try_port, int argc, const char *argv[]);
110
111 } // namespace libtest