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
|
#include "greatest.h"
#include "testclient.h"
#include "cleanup.c"
#include "topics.c"
TEST overlapping_subscriptions_test()
{
TestClient *client;
int count;
const char *mywildtopics[] = { wildtopics[6], wildtopics[0] };
int qos[] = { 2, 1 };
client = TestClientNew("clienta");
ASSERT(TestClientConnect(client, "localhost", 1883, 60, 1));
ASSERT(TestClientSubscribeMany(client, mywildtopics, qos, 2));
ASSERT(TestClientPublish(client, 2, 0, topics[3],
"overlapping topic filters"));
ASSERT(TestClientWait(client, 1000));
TestClientDisconnect(client);
count = TestClientMessageCount(client);
ASSERT(count == 1 || count == 2);
if (count == 1)
{
printf("this server sends one message for for all matching "
"overlapping subscriptions, not one for each\n");
ASSERT_EQ(2, SIMPLEQ_FIRST(&client->messages)->qos);
}
else
{
printf("this server sends one message per each matching overlapping "
"subscription\n");
int qos1 = SIMPLEQ_FIRST(&client->messages)->qos;
int qos2 = SIMPLEQ_NEXT(SIMPLEQ_FIRST(&client->messages), chain)->qos;
ASSERT((qos1 == 1 && qos2 == 2) || (qos1 == 2 && qos2 == 1));
}
TestClientFree(client);
PASS();
}
GREATEST_MAIN_DEFS();
int main(int argc, char **argv)
{
GREATEST_MAIN_BEGIN();
cleanup();
RUN_TEST(overlapping_subscriptions_test);
GREATEST_MAIN_END();
}
|