From 13d5f6e6b459b25d4e39555fc539f0845654fc3d Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Wed, 18 Dec 2019 12:15:33 +0100 Subject: [PATCH] tests: provide test for `vfs`+`fmt` corner-case On `native` when using `vfs` the `fmt` print functions do not work. This is because the `fmt` module uses the `write()` system call which is bend by the `native_vfs` module to use `vfs_write()`. However, `native` does not use a `stdio` module to print. Instead, it just writes to the hosts standard I/O directly. As such, STDIN, STDOUT, and STDERR are never initialized for `vfs` so `vfs` does not recognize `STDIN_FILENO`, `STDOUT_FILENO` and `STDERR_FILENO` as valid file descriptors. This test case showcases this bug. --- tests/vfs_plus_stdio/Makefile | 7 +++++++ tests/vfs_plus_stdio/main.c | 27 +++++++++++++++++++++++++++ tests/vfs_plus_stdio/tests/01-run.py | 18 ++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 tests/vfs_plus_stdio/Makefile create mode 100644 tests/vfs_plus_stdio/main.c create mode 100755 tests/vfs_plus_stdio/tests/01-run.py diff --git a/tests/vfs_plus_stdio/Makefile b/tests/vfs_plus_stdio/Makefile new file mode 100644 index 0000000000..86625c0bea --- /dev/null +++ b/tests/vfs_plus_stdio/Makefile @@ -0,0 +1,7 @@ +DEVELHELP=0 +include ../Makefile.tests_common + +USEMODULE += vfs +USEMODULE += fmt + +include $(RIOTBASE)/Makefile.include diff --git a/tests/vfs_plus_stdio/main.c b/tests/vfs_plus_stdio/main.c new file mode 100644 index 0000000000..48890c09e8 --- /dev/null +++ b/tests/vfs_plus_stdio/main.c @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2019 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. + */ + +/** + * @ingroup tests + * @{ + * + * @file + * @brief Tests VFS together with stdio on a board + * + * @author Martine S. Lenders + * + * @} + */ + +#include "fmt.h" + +int main(void) +{ + print_str("SUCCESS\n"); + return 0; +} diff --git a/tests/vfs_plus_stdio/tests/01-run.py b/tests/vfs_plus_stdio/tests/01-run.py new file mode 100755 index 0000000000..d16f4a5268 --- /dev/null +++ b/tests/vfs_plus_stdio/tests/01-run.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2019 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. + +import sys +from testrunner import run + + +def testfunc(child): + child.expect_exact('SUCCESS') + + +if __name__ == "__main__": + sys.exit(run(testfunc, timeout=1))