]> jfr.im git - solanum.git/blame - tests/client_util.h
reference.conf: Document the common syntax for flags
[solanum.git] / tests / client_util.h
CommitLineData
d2b5f411
SA
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
60f1d711
SA
30#include "ircd_util.h"
31
32#define TEST_NICK "local_test"
d2b5f411
SA
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"
60f1d711
SA
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"
d2b5f411 46
54f75d36
SA
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
d2b5f411
SA
61#define CRLF "\r\n"
62
63void client_util_init(void);
64void client_util_free(void);
65
958c354c 66struct Client *make_local_unknown(void);
d2b5f411
SA
67struct Client *make_local_person(void);
68struct Client *make_local_person_nick(const char *nick);
69struct Client *make_local_person_full(const char *nick, const char *username, const char *hostname, const char *ip, const char *realname);
6af47466 70void make_local_person_oper(struct Client *client);
d2b5f411
SA
71void remove_local_person(struct Client *client);
72
60f1d711
SA
73struct Client *make_remote_server(struct Client *uplink);
74struct Client *make_remote_server_name(struct Client *uplink, const char *name);
75struct Client *make_remote_server_full(struct Client *uplink, const char *name, const char *id);
76struct Client *make_remote_person(struct Client *server);
77struct Client *make_remote_person_nick(struct Client *server, const char *nick);
78struct Client *make_remote_person_full(struct Client *server, const char *nick, const char *username, const char *hostname, const char *ip, const char *realname);
79void make_remote_person_oper(struct Client *client);
80void remove_remote_person(struct Client *client);
81void remove_remote_server(struct Client *server);
82
54f75d36
SA
83struct Channel *make_channel(void);
84
d2b5f411
SA
85char *get_client_sendq(const struct Client *client);
86
958c354c
SA
87void client_util_parse(struct Client *client, const char *message);
88
d2b5f411
SA
89#define is_client_sendq_empty(client, message, ...) do { \
90 is_string("", get_client_sendq(client), message, ##__VA_ARGS__); \
91 } while (0)
92
958c354c 93#define is_client_sendq_one(queue, client, message, ...) do { \
d2b5f411 94 is_string(queue, get_client_sendq(client), message, ##__VA_ARGS__); \
958c354c
SA
95 } while (0)
96
97#define is_client_sendq(queue, client, message, ...) do { \
98 is_client_sendq_one(queue, client, message, ##__VA_ARGS__); \
d2b5f411
SA
99 is_client_sendq_empty(client, message, ##__VA_ARGS__); \
100 } while (0)