-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: initial import of tests for CongURE and its test framework
- Loading branch information
Showing
7 changed files
with
1,021 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
include ../Makefile.tests_common | ||
|
||
USEMODULE += congure_test | ||
USEMODULE += fmt | ||
USEMODULE += shell | ||
USEMODULE += shell_commands | ||
|
||
INCLUDES += -I$(CURDIR) | ||
|
||
include $(RIOTBASE)/Makefile.include | ||
|
||
ifndef CONFIG_SHELL_NO_ECHO | ||
CFLAGS += -DCONFIG_SHELL_NO_ECHO=1 | ||
endif | ||
|
||
ifndef CONFIG_CONGURE_TEST_LOST_MSG_POOL_SIZE | ||
CFLAGS += -DCONFIG_CONGURE_TEST_LOST_MSG_POOL_SIZE=4 | ||
export LOST_MSG_POOL_SIZE=4 | ||
else | ||
export LOST_MSG_POOL_SIZE=$(CONFIG_CONGURE_TEST_LOST_MSG_POOL_SIZE) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Basic tests for the CongURE API | ||
=============================== | ||
|
||
This test tests the `congure_test` test framework used for the other CongURE | ||
tests. | ||
|
||
Usage | ||
----- | ||
|
||
The test requires an up-to-date version of `riotctrl` with `rapidjson` support: | ||
|
||
```console | ||
$ pip install --upgrade riotctrl[rapidjson] | ||
``` | ||
|
||
Then simply run the application using: | ||
|
||
```console | ||
$ BOARD="<board>" make flash test | ||
``` | ||
|
||
It can also executed with pytest: | ||
|
||
```console | ||
$ pytest tests/01-run.py | ||
``` | ||
|
||
Expected result | ||
--------------- | ||
|
||
The application's test script passes without error code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CONFIG_KCONFIG_USEMODULE_CONGURE_TEST=y | ||
CONFIG_KCONFIG_USEMODULE_SHELL=y | ||
CONFIG_CONGURE_TEST_LOST_MSG_POOL_SIZE=4 | ||
CONFIG_SHELL_NO_ECHO=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* Copyright (C) 2021 Freie Universität Berlin | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @{ | ||
* | ||
* @file | ||
* @author Martine Lenders <m.lenders@fu-berlin.de> | ||
*/ | ||
|
||
#include "congure_impl.h" | ||
|
||
static void _snd_init(congure_snd_t *cong, void *ctx); | ||
static int32_t _snd_inter_msg_interval(congure_snd_t *cong, unsigned msg_size); | ||
static void _snd_report_msg_sent(congure_snd_t *cong, unsigned msg_size); | ||
static void _snd_report_msg_discarded(congure_snd_t *cong, unsigned msg_size); | ||
static void _snd_report_msg_lost(congure_snd_t *cong, congure_snd_msg_t *msgs); | ||
static void _snd_report_msg_timeout(congure_snd_t *cong, congure_snd_msg_t *msgs); | ||
static void _snd_report_msg_acked(congure_snd_t *cong, congure_snd_msg_t *msg, | ||
congure_snd_ack_t *ack); | ||
static void _snd_report_ecn_ce(congure_snd_t *cong, ztimer_now_t time); | ||
|
||
static const congure_snd_driver_t _driver = { | ||
.init = _snd_init, | ||
.inter_msg_interval = _snd_inter_msg_interval, | ||
.report_msg_sent = _snd_report_msg_sent, | ||
.report_msg_discarded = _snd_report_msg_discarded, | ||
.report_msg_timeout = _snd_report_msg_timeout, | ||
.report_msg_lost = _snd_report_msg_lost, | ||
.report_msg_acked = _snd_report_msg_acked, | ||
.report_ecn_ce = _snd_report_ecn_ce, | ||
}; | ||
|
||
int congure_test_snd_setup(congure_test_snd_t *c, unsigned id) | ||
{ | ||
if (id > 0) { | ||
return -1; | ||
} | ||
c->super.driver = &_driver; | ||
return 0; | ||
} | ||
|
||
static void _snd_init(congure_snd_t *cong, void *ctx) | ||
{ | ||
congure_test_snd_t *c = (congure_test_snd_t *)cong; | ||
|
||
c->init_calls++; | ||
c->init_args.c = &c->super; | ||
c->init_args.ctx = ctx; | ||
} | ||
|
||
static int32_t _snd_inter_msg_interval(congure_snd_t *cong, unsigned msg_size) | ||
{ | ||
congure_test_snd_t *c = (congure_test_snd_t *)cong; | ||
|
||
c->inter_msg_interval_calls++; | ||
c->inter_msg_interval_args.c = &c->super; | ||
c->inter_msg_interval_args.msg_size = msg_size; | ||
return -1; | ||
} | ||
|
||
static void _snd_report_msg_sent(congure_snd_t *cong, unsigned msg_size) | ||
{ | ||
congure_test_snd_t *c = (congure_test_snd_t *)cong; | ||
|
||
c->report_msg_sent_calls++; | ||
c->report_msg_sent_args.c = &c->super; | ||
c->report_msg_sent_args.msg_size = msg_size; | ||
} | ||
|
||
static void _snd_report_msg_discarded(congure_snd_t *cong, unsigned msg_size) | ||
{ | ||
congure_test_snd_t *c = (congure_test_snd_t *)cong; | ||
|
||
c->report_msg_discarded_calls++; | ||
c->report_msg_discarded_args.c = &c->super; | ||
c->report_msg_discarded_args.msg_size = msg_size; | ||
} | ||
|
||
static void _snd_report_msg_lost(congure_snd_t *cong, congure_snd_msg_t *msgs) | ||
{ | ||
congure_test_snd_t *c = (congure_test_snd_t *)cong; | ||
|
||
c->report_msg_lost_calls++; | ||
c->report_msg_lost_args.c = &c->super; | ||
c->report_msg_lost_args.msgs = msgs; | ||
} | ||
|
||
static void _snd_report_msg_timeout(congure_snd_t *cong, congure_snd_msg_t *msgs) | ||
{ | ||
congure_test_snd_t *c = (congure_test_snd_t *)cong; | ||
|
||
c->report_msg_timeout_calls++; | ||
c->report_msg_timeout_args.c = &c->super; | ||
c->report_msg_timeout_args.msgs = msgs; | ||
} | ||
|
||
static void _snd_report_msg_acked(congure_snd_t *cong, congure_snd_msg_t *msg, | ||
congure_snd_ack_t *ack) | ||
{ | ||
congure_test_snd_t *c = (congure_test_snd_t *)cong; | ||
|
||
c->report_msg_acked_calls++; | ||
c->report_msg_acked_args.c = &c->super; | ||
c->report_msg_acked_args.msg = msg; | ||
c->report_msg_acked_args.ack = ack; | ||
} | ||
|
||
static void _snd_report_ecn_ce(congure_snd_t *cong, ztimer_now_t time) | ||
{ | ||
congure_test_snd_t *c = (congure_test_snd_t *)cong; | ||
|
||
c->report_ecn_ce_calls++; | ||
c->report_ecn_ce_args.c = &c->super; | ||
c->report_ecn_ce_args.time = time; | ||
} | ||
|
||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (C) 2021 Freie Universität Berlin | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @{ | ||
* | ||
* @file | ||
* | ||
* @author Martine Lenders <m.lenders@fu-berlin.de> | ||
*/ | ||
#ifndef CONGURE_IMPL_H | ||
#define CONGURE_IMPL_H | ||
|
||
#include "congure.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct { | ||
congure_snd_t super; | ||
uint8_t init_calls; | ||
uint8_t inter_msg_interval_calls; | ||
uint8_t report_msg_sent_calls; | ||
uint8_t report_msg_discarded_calls; | ||
uint8_t report_msg_timeout_calls; | ||
uint8_t report_msg_lost_calls; | ||
uint8_t report_msg_acked_calls; | ||
uint8_t report_ecn_ce_calls; | ||
struct { | ||
congure_snd_t *c; | ||
void *ctx; | ||
} init_args; | ||
struct { | ||
congure_snd_t *c; | ||
unsigned msg_size; | ||
} inter_msg_interval_args; | ||
struct { | ||
congure_snd_t *c; | ||
unsigned msg_size; | ||
} report_msg_sent_args; | ||
struct { | ||
congure_snd_t *c; | ||
unsigned msg_size; | ||
} report_msg_discarded_args; | ||
struct { | ||
congure_snd_t *c; | ||
congure_snd_msg_t *msgs; | ||
} report_msg_timeout_args; | ||
struct { | ||
congure_snd_t *c; | ||
congure_snd_msg_t *msgs; | ||
} report_msg_lost_args; | ||
struct { | ||
congure_snd_t *c; | ||
congure_snd_msg_t *msg; | ||
congure_snd_ack_t *ack; | ||
} report_msg_acked_args; | ||
struct { | ||
congure_snd_t *c; | ||
ztimer_now_t time; | ||
} report_ecn_ce_args; | ||
} congure_test_snd_t; | ||
|
||
int congure_test_snd_setup(congure_test_snd_t *c, unsigned id); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* CONGURE_IMPL_H */ | ||
/** @} */ |
Oops, something went wrong.