1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/gcoap_fileserver: add test for PUT

This commit is contained in:
Benjamin Valentin 2022-10-12 00:46:13 +02:00
parent be1c46ef27
commit 7e0aeb3186
4 changed files with 22 additions and 1 deletions

View File

@ -10,6 +10,8 @@ USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += gcoap_fileserver
USEMODULE += gcoap_fileserver_put
USEMODULE += nanocoap_vfs
USEMODULE += constfs

View File

@ -7,6 +7,7 @@ BOARD_INSUFFICIENT_MEMORY := \
atmega1284p \
atmega328p \
atmega328p-xplained-mini \
atxmega-a1-xplained \
atxmega-a3bu-xplained \
blackpill \
bluepill \

View File

@ -28,7 +28,18 @@ static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
/* CoAP resources. Must be sorted by path (ASCII order). */
static const coap_resource_t _resources[] = {
{ "/const", COAP_GET | COAP_MATCH_SUBTREE, gcoap_fileserver_handler, "/const" },
{
.path = "/const",
.methods = COAP_GET | COAP_MATCH_SUBTREE,
.handler = gcoap_fileserver_handler,
.context = "/const"
},
{
.path = "/vfs",
.methods = COAP_GET | COAP_PUT | COAP_MATCH_SUBTREE,
.handler = gcoap_fileserver_handler,
.context = VFS_DEFAULT_DATA
},
};
static gcoap_listener_t _listener = {

View File

@ -98,11 +98,18 @@ def test_linear_topology(factory, zep_dispatch):
# Download file from CoAP server
B.cmd("vfs rm /nvm0/song.txt")
B.cmd("vfs rm /nvm0/song2.txt")
B.cmd("ncget coap://[2001:db8::1]/const/song.txt", timeout=60)
# make sure the content matches
assert A.cmd("md5sum /const/song.txt").split()[2] == B.cmd("md5sum /nvm0/song.txt").split()[2]
# upload the file to node B (only one node should write MEMORY.bin)
A.cmd("ncput /const/song.txt coap://[" + global_addr(B.cmd("ifconfig 7"))[1] + "]/vfs/song2.txt", timeout=60)
# make sure the content matches
assert B.cmd("md5sum /nvm0/song.txt").split()[2] == B.cmd("md5sum /nvm0/song2.txt").split()[2]
# terminate nodes
for n in nodes:
n.stop_term()