tests/gnrc_sock_{udp,ip}: test sock_aux_rssi
Extend tests to also cover testing sock_aux_rssi
This commit is contained in:
parent
c0765d9e07
commit
3944af2046
@ -2,6 +2,7 @@ include ../Makefile.tests_common
|
|||||||
|
|
||||||
AUX_LOCAL ?= 1
|
AUX_LOCAL ?= 1
|
||||||
AUX_TIMESTAMP ?= 1
|
AUX_TIMESTAMP ?= 1
|
||||||
|
AUX_RSSI ?= 1
|
||||||
|
|
||||||
ifeq (1, $(AUX_LOCAL))
|
ifeq (1, $(AUX_LOCAL))
|
||||||
USEMODULE += sock_aux_local
|
USEMODULE += sock_aux_local
|
||||||
@ -11,6 +12,10 @@ ifeq (1, $(AUX_TIMESTAMP))
|
|||||||
USEMODULE += sock_aux_timestamp
|
USEMODULE += sock_aux_timestamp
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq (1, $(AUX_RSSI))
|
||||||
|
USEMODULE += sock_aux_rssi
|
||||||
|
endif
|
||||||
|
|
||||||
USEMODULE += sock_ip
|
USEMODULE += sock_ip
|
||||||
USEMODULE += gnrc_ipv6
|
USEMODULE += gnrc_ipv6
|
||||||
USEMODULE += ps
|
USEMODULE += ps
|
||||||
|
|||||||
@ -352,7 +352,7 @@ static void test_sock_ip_recv__aux(void)
|
|||||||
static const inject_aux_t inject_aux = { .timestamp = 42 };
|
static const inject_aux_t inject_aux = { .timestamp = 42 };
|
||||||
sock_ip_ep_t result;
|
sock_ip_ep_t result;
|
||||||
sock_ip_aux_rx_t aux = {
|
sock_ip_aux_rx_t aux = {
|
||||||
.flags = SOCK_AUX_GET_LOCAL | SOCK_AUX_GET_TIMESTAMP
|
.flags = SOCK_AUX_GET_LOCAL | SOCK_AUX_GET_TIMESTAMP | SOCK_AUX_GET_RSSI
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(0 == sock_ip_create(&_sock, &local, NULL, _TEST_PROTO,
|
expect(0 == sock_ip_create(&_sock, &local, NULL, _TEST_PROTO,
|
||||||
@ -376,6 +376,12 @@ static void test_sock_ip_recv__aux(void)
|
|||||||
expect(aux.timestamp == inject_aux.timestamp);
|
expect(aux.timestamp == inject_aux.timestamp);
|
||||||
#else
|
#else
|
||||||
expect(aux.flags & SOCK_AUX_GET_TIMESTAMP);
|
expect(aux.flags & SOCK_AUX_GET_TIMESTAMP);
|
||||||
|
#endif
|
||||||
|
#if IS_USED(MODULE_SOCK_AUX_RSSI)
|
||||||
|
expect(!(aux.flags & SOCK_AUX_GET_RSSI));
|
||||||
|
expect(aux.rssi == inject_aux.rssi);
|
||||||
|
#else
|
||||||
|
expect(aux.flags & SOCK_AUX_GET_RSSI);
|
||||||
#endif
|
#endif
|
||||||
expect(_check_net());
|
expect(_check_net());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,6 +72,7 @@ static gnrc_pktsnip_t *_build_ipv6_packet(const ipv6_addr_t *src,
|
|||||||
netif_hdr->if_pid = (kernel_pid_t)netif;
|
netif_hdr->if_pid = (kernel_pid_t)netif;
|
||||||
if (aux) {
|
if (aux) {
|
||||||
gnrc_netif_hdr_set_timestamp(netif_hdr, aux->timestamp);
|
gnrc_netif_hdr_set_timestamp(netif_hdr, aux->timestamp);
|
||||||
|
netif_hdr->rssi = aux->rssi;
|
||||||
}
|
}
|
||||||
return gnrc_pkt_append(payload, netif_hdr_snip);
|
return gnrc_pkt_append(payload, netif_hdr_snip);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,7 @@ void _prepare_send_checks(void);
|
|||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t timestamp; /**< Timestamp of reception */
|
uint64_t timestamp; /**< Timestamp of reception */
|
||||||
|
int16_t rssi; /**< Fake RSSI value */
|
||||||
} inject_aux_t;
|
} inject_aux_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2,6 +2,7 @@ include ../Makefile.tests_common
|
|||||||
|
|
||||||
AUX_LOCAL ?= 1
|
AUX_LOCAL ?= 1
|
||||||
AUX_TIMESTAMP ?= 1
|
AUX_TIMESTAMP ?= 1
|
||||||
|
AUX_RSSI ?= 1
|
||||||
|
|
||||||
ifeq (1, $(AUX_LOCAL))
|
ifeq (1, $(AUX_LOCAL))
|
||||||
USEMODULE += sock_aux_local
|
USEMODULE += sock_aux_local
|
||||||
@ -11,6 +12,10 @@ ifeq (1, $(AUX_TIMESTAMP))
|
|||||||
USEMODULE += sock_aux_timestamp
|
USEMODULE += sock_aux_timestamp
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq (1, $(AUX_RSSI))
|
||||||
|
USEMODULE += sock_aux_rssi
|
||||||
|
endif
|
||||||
|
|
||||||
USEMODULE += gnrc_sock_check_reuse
|
USEMODULE += gnrc_sock_check_reuse
|
||||||
USEMODULE += sock_udp
|
USEMODULE += sock_udp
|
||||||
USEMODULE += gnrc_ipv6
|
USEMODULE += gnrc_ipv6
|
||||||
|
|||||||
@ -429,10 +429,10 @@ static void test_sock_udp_recv__aux(void)
|
|||||||
static const ipv6_addr_t dst_addr = { .u8 = _TEST_ADDR_LOCAL };
|
static const ipv6_addr_t dst_addr = { .u8 = _TEST_ADDR_LOCAL };
|
||||||
static const sock_udp_ep_t local = { .family = AF_INET6,
|
static const sock_udp_ep_t local = { .family = AF_INET6,
|
||||||
.port = _TEST_PORT_LOCAL };
|
.port = _TEST_PORT_LOCAL };
|
||||||
static const inject_aux_t inject_aux = { .timestamp = 1337 };
|
static const inject_aux_t inject_aux = { .timestamp = 1337, .rssi = -11 };
|
||||||
sock_udp_ep_t result;
|
sock_udp_ep_t result;
|
||||||
sock_udp_aux_rx_t aux = {
|
sock_udp_aux_rx_t aux = {
|
||||||
.flags = SOCK_AUX_GET_LOCAL | SOCK_AUX_GET_TIMESTAMP
|
.flags = SOCK_AUX_GET_LOCAL | SOCK_AUX_GET_TIMESTAMP | SOCK_AUX_GET_RSSI
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(0 == sock_udp_create(&_sock, &local, NULL, SOCK_FLAGS_REUSE_EP));
|
expect(0 == sock_udp_create(&_sock, &local, NULL, SOCK_FLAGS_REUSE_EP));
|
||||||
@ -458,6 +458,12 @@ static void test_sock_udp_recv__aux(void)
|
|||||||
expect(inject_aux.timestamp == aux.timestamp);
|
expect(inject_aux.timestamp == aux.timestamp);
|
||||||
#else
|
#else
|
||||||
expect(aux.flags & SOCK_AUX_GET_TIMESTAMP);
|
expect(aux.flags & SOCK_AUX_GET_TIMESTAMP);
|
||||||
|
#endif
|
||||||
|
#if IS_USED(MODULE_SOCK_AUX_RSSI)
|
||||||
|
expect(!(aux.flags & SOCK_AUX_GET_RSSI));
|
||||||
|
expect(inject_aux.rssi == aux.rssi);
|
||||||
|
#else
|
||||||
|
expect(aux.flags & SOCK_AUX_GET_RSSI);
|
||||||
#endif
|
#endif
|
||||||
expect(_check_net());
|
expect(_check_net());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,6 +95,7 @@ static gnrc_pktsnip_t *_build_udp_packet(const ipv6_addr_t *src,
|
|||||||
netif_hdr->if_pid = (kernel_pid_t)netif;
|
netif_hdr->if_pid = (kernel_pid_t)netif;
|
||||||
if (aux) {
|
if (aux) {
|
||||||
gnrc_netif_hdr_set_timestamp(netif_hdr, aux->timestamp);
|
gnrc_netif_hdr_set_timestamp(netif_hdr, aux->timestamp);
|
||||||
|
netif_hdr->rssi = aux->rssi;
|
||||||
}
|
}
|
||||||
return gnrc_pkt_append(udp, netif_hdr_snip);
|
return gnrc_pkt_append(udp, netif_hdr_snip);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,7 @@ void _prepare_send_checks(void);
|
|||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t timestamp; /**< Timestamp of reception */
|
uint64_t timestamp; /**< Timestamp of reception */
|
||||||
|
int16_t rssi; /**< Fake RSSI value */
|
||||||
} inject_aux_t;
|
} inject_aux_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user