ReactOS 0.4.16-dev-257-g6aa11ac
test_mqtt.c File Reference
#include "test_mqtt.h"
#include "lwip/pbuf.h"
#include "lwip/apps/mqtt.h"
#include "lwip/apps/mqtt_priv.h"
#include "lwip/netif.h"
Include dependency graph for test_mqtt.c:

Go to the source code of this file.

Functions

static err_t test_mqtt_netif_output (struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr)
 
static void test_mqtt_init_netif (struct netif *netif, const ip_addr_t *ip_addr, const ip_addr_t *netmask)
 
static void mqtt_setup (void)
 
static void mqtt_teardown (void)
 
static void test_mqtt_connection_cb (mqtt_client_t *client, void *arg, mqtt_connection_status_t status)
 
 START_TEST (basic_connect)
 
END_TEST Suite * mqtt_suite (void)
 

Variables

const ip_addr_t test_mqtt_local_ip = IPADDR4_INIT_BYTES(192, 168, 1, 1)
 
const ip_addr_t test_mqtt_remote_ip = IPADDR4_INIT_BYTES(192, 168, 1, 2)
 
const ip_addr_t test_mqtt_netmask = IPADDR4_INIT_BYTES(255, 255, 255, 0)
 
static struct netifold_netif_list
 
static struct netifold_netif_default
 

Function Documentation

◆ mqtt_setup()

static void mqtt_setup ( void  )
static

Definition at line 44 of file test_mqtt.c.

45{
50 lwip_check_ensure_no_alloc(SKIP_POOL(MEMP_SYS_TIMEOUT));
51}
#define NULL
Definition: types.h:112
#define SKIP_POOL(x)
Definition: lwip_check.h:48
void lwip_check_ensure_no_alloc(unsigned int skip)
struct netif * netif_list
Definition: netif.c:113
struct netif * netif_default
Definition: netif.c:115
static struct netif * old_netif_list
Definition: test_mqtt.c:40
static struct netif * old_netif_default
Definition: test_mqtt.c:41

Referenced by mqtt_suite().

◆ mqtt_suite()

END_TEST Suite * mqtt_suite ( void  )

Definition at line 109 of file test_mqtt.c.

110{
111 testfunc tests[] = {
112 TESTFUNC(basic_connect),
113 };
114 return create_suite("MQTT", tests, sizeof(tests)/sizeof(testfunc), mqtt_setup, mqtt_teardown);
115}
Suite * create_suite(const char *name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown)
#define TESTFUNC(x)
Definition: lwip_check.h:22
static struct test_info tests[]
static void mqtt_teardown(void)
Definition: test_mqtt.c:54
static void mqtt_setup(void)
Definition: test_mqtt.c:44

Referenced by main().

◆ mqtt_teardown()

static void mqtt_teardown ( void  )
static

Definition at line 54 of file test_mqtt.c.

55{
58 /* restore netif_list for next tests (e.g. loopif) */
61 lwip_check_ensure_no_alloc(SKIP_POOL(MEMP_SYS_TIMEOUT));
62}

Referenced by mqtt_suite().

◆ START_TEST()

START_TEST ( basic_connect  )

Definition at line 71 of file test_mqtt.c.

72{
74 struct netif netif;
75 err_t err;
77 "dumm",
78 NULL, NULL,
79 10,
80 NULL, NULL, 0, 0
81 };
82 struct pbuf *p;
83 unsigned char rxbuf[] = {0x20, 0x02, 0x00, 0x00};
85
87
89 fail_unless(client != NULL);
91 fail_unless(err == ERR_OK);
92
93 client->conn->connected(client->conn->callback_arg, client->conn, ERR_OK);
94 p = pbuf_alloc(PBUF_RAW, sizeof(rxbuf), PBUF_REF);
95 fail_unless(p != NULL);
96 p->payload = rxbuf;
97 /* since we hack the rx path, we have to hack the rx window, too: */
98 client->conn->rcv_wnd -= p->tot_len;
99 if (client->conn->recv(client->conn->callback_arg, client->conn, p, ERR_OK) != ERR_OK) {
100 pbuf_free(p);
101 }
102
104 /* fixme: mqtt_client_fre() is missing... */
106}
#define mem_free(ptr, bsize)
Definition: types.h:124
GLfloat GLfloat p
Definition: glext.h:8902
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:373
s8_t err_t
Definition: err.h:96
@ ERR_OK
Definition: err.h:55
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
Definition: pbuf.c:224
u8_t pbuf_free(struct pbuf *p)
Definition: pbuf.c:727
@ PBUF_REF
Definition: pbuf.h:160
@ PBUF_RAW
Definition: pbuf.h:111
void mqtt_disconnect(mqtt_client_t *client)
err_t mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ipaddr, u16_t port, mqtt_connection_cb_t cb, void *arg, const struct mqtt_connect_client_info_t *client_info)
mqtt_client_t * mqtt_client_new(void)
#define err(...)
static FILE * client
Definition: client.c:41
Definition: netif.h:269
Definition: pbuf.h:186
const ip_addr_t test_mqtt_remote_ip
Definition: test_mqtt.c:9
const ip_addr_t test_mqtt_local_ip
Definition: test_mqtt.c:8
static void test_mqtt_connection_cb(mqtt_client_t *client, void *arg, mqtt_connection_status_t status)
Definition: test_mqtt.c:64
static void test_mqtt_init_netif(struct netif *netif, const ip_addr_t *ip_addr, const ip_addr_t *netmask)
Definition: test_mqtt.c:22
const ip_addr_t test_mqtt_netmask
Definition: test_mqtt.c:10

◆ test_mqtt_connection_cb()

static void test_mqtt_connection_cb ( mqtt_client_t client,
void arg,
mqtt_connection_status_t  status 
)
static

Definition at line 64 of file test_mqtt.c.

Referenced by START_TEST().

◆ test_mqtt_init_netif()

static void test_mqtt_init_netif ( struct netif netif,
const ip_addr_t ip_addr,
const ip_addr_t netmask 
)
static

Definition at line 22 of file test_mqtt.c.

23{
24 struct netif *n;
25 memset(netif, 0, sizeof(struct netif));
28 ip_addr_copy_from_ip4(netif->netmask, *ip_2_ip4(netmask));
29 ip_addr_copy_from_ip4(netif->ip_addr, *ip_2_ip4(ip_addr));
30 for (n = netif_list; n != NULL; n = n->next) {
31 if (n == netif) {
32 return;
33 }
34 }
35 netif->next = NULL;
37}
GLdouble n
Definition: glext.h:7729
#define NETIF_FLAG_LINK_UP
Definition: netif.h:93
#define NETIF_FLAG_UP
Definition: netif.h:84
#define memset(x, y, z)
Definition: compat.h:39
struct define * next
Definition: compiler.c:65
u8_t flags
Definition: netif.h:354
struct netif * next
Definition: netif.h:272
static err_t test_mqtt_netif_output(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr)
Definition: test_mqtt.c:12

Referenced by START_TEST().

◆ test_mqtt_netif_output()

static err_t test_mqtt_netif_output ( struct netif netif,
struct pbuf p,
const ip4_addr_t *  ipaddr 
)
static

Definition at line 12 of file test_mqtt.c.

14{
16 LWIP_UNUSED_ARG(ipaddr);
18 return ERR_OK;
19}

Referenced by test_mqtt_init_netif().

Variable Documentation

◆ old_netif_default

struct netif* old_netif_default
static

Definition at line 41 of file test_mqtt.c.

Referenced by mqtt_setup(), and mqtt_teardown().

◆ old_netif_list

struct netif* old_netif_list
static

Definition at line 40 of file test_mqtt.c.

Referenced by mqtt_setup(), and mqtt_teardown().

◆ test_mqtt_local_ip

const ip_addr_t test_mqtt_local_ip = IPADDR4_INIT_BYTES(192, 168, 1, 1)

Definition at line 8 of file test_mqtt.c.

Referenced by START_TEST().

◆ test_mqtt_netmask

const ip_addr_t test_mqtt_netmask = IPADDR4_INIT_BYTES(255, 255, 255, 0)

Definition at line 10 of file test_mqtt.c.

Referenced by START_TEST().

◆ test_mqtt_remote_ip

const ip_addr_t test_mqtt_remote_ip = IPADDR4_INIT_BYTES(192, 168, 1, 2)

Definition at line 9 of file test_mqtt.c.

Referenced by START_TEST().