]> jfr.im git - solanum.git/blob - tests/client_util.h
tests: send1: add tag tests to all functions
[solanum.git] / tests / client_util.h
1 /*
2 * client_util.c: Utility functions for making test clients
3 * Copyright 2017 Simon Arlott
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18 * USA
19 */
20 #include <stdio.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include <unistd.h>
24
25 #include "stdinc.h"
26 #include "ircd_defs.h"
27 #include "msg.h"
28 #include "client.h"
29
30 #include "ircd_util.h"
31
32 #define TEST_NICK "local_test"
33 #define TEST_USERNAME "username"
34 #define TEST_HOSTNAME "example.test"
35 #define TEST_IP "2001:db8::1:5ee:bad:c0de"
36 #define TEST_REALNAME "Test user"
37 #define TEST_ID TEST_ME_ID "00000"
38
39 #define TEST_ID_SUFFIX "!" TEST_USERNAME "@" TEST_HOSTNAME
40
41 #define TEST_SERVER_NAME "remote.test"
42 #define TEST_SERVER_ID "1BB"
43
44 #define TEST_REMOTE_NICK "remote_test"
45 #define TEST_REMOTE_ID TEST_SERVER_ID "00001"
46
47 #define TEST_SERVER2_NAME "remote2.test"
48 #define TEST_SERVER2_ID "2CC"
49
50 #define TEST_REMOTE2_NICK "remote2_test"
51 #define TEST_REMOTE2_ID TEST_SERVER2_ID "00002"
52
53 #define TEST_SERVER3_NAME "remote3.test"
54 #define TEST_SERVER3_ID "3DD"
55
56 #define TEST_REMOTE3_NICK "remote3_test"
57 #define TEST_REMOTE3_ID TEST_SERVER3_ID "00003"
58
59 #define TEST_CHANNEL "#test"
60
61 #define CRLF "\r\n"
62
63 void client_util_init(void);
64 void client_util_free(void);
65
66 struct Client *make_local_person(void);
67 struct Client *make_local_person_nick(const char *nick);
68 struct Client *make_local_person_full(const char *nick, const char *username, const char *hostname, const char *ip, const char *realname);
69 void make_local_person_oper(struct Client *client);
70 void remove_local_person(struct Client *client);
71
72 struct Client *make_remote_server(struct Client *uplink);
73 struct Client *make_remote_server_name(struct Client *uplink, const char *name);
74 struct Client *make_remote_server_full(struct Client *uplink, const char *name, const char *id);
75 struct Client *make_remote_person(struct Client *server);
76 struct Client *make_remote_person_nick(struct Client *server, const char *nick);
77 struct Client *make_remote_person_full(struct Client *server, const char *nick, const char *username, const char *hostname, const char *ip, const char *realname);
78 void make_remote_person_oper(struct Client *client);
79 void remove_remote_person(struct Client *client);
80 void remove_remote_server(struct Client *server);
81
82 struct Channel *make_channel(void);
83
84 char *get_client_sendq(const struct Client *client);
85
86 #define is_client_sendq_empty(client, message, ...) do { \
87 is_string("", get_client_sendq(client), message, ##__VA_ARGS__); \
88 } while (0)
89
90 #define is_client_sendq(queue, client, message, ...) do { \
91 is_string(queue, get_client_sendq(client), message, ##__VA_ARGS__); \
92 is_client_sendq_empty(client, message, ##__VA_ARGS__); \
93 } while (0)