1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/*
* test-core-signal.cpp - test util functions
*
* Copyright (C) 2021 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
*/
#include "CppUTest/TestHarness.h"
extern "C"
{
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include "tests/tests.h"
#include "src/core/wee-signal.h"
}
TEST_GROUP(CoreSignal)
{
};
/*
* Tests functions:
* signal_search_number
*/
TEST(CoreSignal, SearchNumber)
{
int count, index;
/* make tests fail if the signal_list structure is changed */
for (count = 0; signal_list[count].name; count++)
{
}
LONGS_EQUAL(7, count);
LONGS_EQUAL(-1, signal_search_number (-1));
LONGS_EQUAL(-1, signal_search_number (999999999));
index = signal_search_number (SIGHUP);
LONGS_EQUAL(SIGHUP, signal_list[index].signal);
STRCMP_EQUAL("hup", signal_list[index].name);
index = signal_search_number (SIGINT);
LONGS_EQUAL(SIGINT, signal_list[index].signal);
STRCMP_EQUAL("int", signal_list[index].name);
index = signal_search_number (SIGQUIT);
LONGS_EQUAL(SIGQUIT, signal_list[index].signal);
STRCMP_EQUAL("quit", signal_list[index].name);
index = signal_search_number (SIGKILL);
LONGS_EQUAL(SIGKILL, signal_list[index].signal);
STRCMP_EQUAL("kill", signal_list[index].name);
index = signal_search_number (SIGTERM);
LONGS_EQUAL(SIGTERM, signal_list[index].signal);
STRCMP_EQUAL("term", signal_list[index].name);
index = signal_search_number (SIGUSR1);
LONGS_EQUAL(SIGUSR1, signal_list[index].signal);
STRCMP_EQUAL("usr1", signal_list[index].name);
index = signal_search_number (SIGUSR2);
LONGS_EQUAL(SIGUSR2, signal_list[index].signal);
STRCMP_EQUAL("usr2", signal_list[index].name);
}
/*
* Tests functions:
* signal_search_name
*/
TEST(CoreSignal, SearchName)
{
LONGS_EQUAL(-1, signal_search_name (NULL));
LONGS_EQUAL(-1, signal_search_name (""));
LONGS_EQUAL(-1, signal_search_name ("signal_does_not_exist"));
LONGS_EQUAL(SIGHUP, signal_search_name ("hup"));
LONGS_EQUAL(SIGHUP, signal_search_name ("HUP"));
LONGS_EQUAL(SIGINT, signal_search_name ("int"));
LONGS_EQUAL(SIGINT, signal_search_name ("INT"));
LONGS_EQUAL(SIGQUIT, signal_search_name ("quit"));
LONGS_EQUAL(SIGQUIT, signal_search_name ("QUIT"));
LONGS_EQUAL(SIGKILL, signal_search_name ("kill"));
LONGS_EQUAL(SIGKILL, signal_search_name ("KILL"));
LONGS_EQUAL(SIGTERM, signal_search_name ("term"));
LONGS_EQUAL(SIGTERM, signal_search_name ("TERM"));
LONGS_EQUAL(SIGUSR1, signal_search_name ("usr1"));
LONGS_EQUAL(SIGUSR1, signal_search_name ("USR1"));
LONGS_EQUAL(SIGUSR2, signal_search_name ("usr2"));
LONGS_EQUAL(SIGUSR2, signal_search_name ("USR2"));
}
/*
* Tests functions:
* signal_catch
*/
TEST(CoreSignal, Catch)
{
/* TODO: write tests */
}
/*
* Tests functions:
* signal_send_to_weechat
*/
TEST(CoreSignal, SentToWeechat)
{
/* TODO: write tests */
}
/*
* Tests functions:
* signal_exec_command
*/
TEST(CoreSignal, ExecCommand)
{
/* TODO: write tests */
}
/*
* Tests functions:
* signal_handle_number
*/
TEST(CoreSignal, HandleNumber)
{
/* TODO: write tests */
}
/*
* Tests functions:
* signal_handle
*/
TEST(CoreSignal, Handle)
{
/* TODO: write tests */
}
|