From 4337f97662697946ea9a8c6a8f21b3160c25bb1a Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Mon, 22 Nov 2021 09:30:01 +0100 Subject: [PATCH] tests/turo_txt: Add turo_txt tests --- tests/turo_txt/Makefile | 7 +++++ tests/turo_txt/README.md | 4 +++ tests/turo_txt/app.config.test | 4 +++ tests/turo_txt/main.c | 1 + tests/turo_txt/tests/01-run.py | 55 ++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 tests/turo_txt/Makefile create mode 100644 tests/turo_txt/README.md create mode 100644 tests/turo_txt/app.config.test create mode 120000 tests/turo_txt/main.c create mode 100755 tests/turo_txt/tests/01-run.py diff --git a/tests/turo_txt/Makefile b/tests/turo_txt/Makefile new file mode 100644 index 0000000000..053b6491d4 --- /dev/null +++ b/tests/turo_txt/Makefile @@ -0,0 +1,7 @@ +include ../Makefile.tests_common + +USEMODULE += test_utils_result_output +USEMODULE += test_utils_result_output_txt +USEMODULE += shell + +include $(RIOTBASE)/Makefile.include diff --git a/tests/turo_txt/README.md b/tests/turo_txt/README.md new file mode 100644 index 0000000000..e772df8eab --- /dev/null +++ b/tests/turo_txt/README.md @@ -0,0 +1,4 @@ +# TURO (Test Utils Result Output) Test - TXT + +This is only to test the txt variant of turo. +Please check [the turo test](../turo) for more info. diff --git a/tests/turo_txt/app.config.test b/tests/turo_txt/app.config.test new file mode 100644 index 0000000000..d7cf937d21 --- /dev/null +++ b/tests/turo_txt/app.config.test @@ -0,0 +1,4 @@ +CONFIG_MODULE_FMT=y +CONFIG_MODULE_SHELL=y +CONFIG_MODULE_TEST_UTILS_RESULT_OUTPUT=y +CONFIG_MODULE_TEST_UTILS_RESULT_OUTPUT_TXT=y diff --git a/tests/turo_txt/main.c b/tests/turo_txt/main.c new file mode 120000 index 0000000000..af1b98031f --- /dev/null +++ b/tests/turo_txt/main.c @@ -0,0 +1 @@ +../turo/main.c \ No newline at end of file diff --git a/tests/turo_txt/tests/01-run.py b/tests/turo_txt/tests/01-run.py new file mode 100755 index 0000000000..3e9e180c88 --- /dev/null +++ b/tests/turo_txt/tests/01-run.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2017 Alexandre Abadie +# +# 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 + + +PASSING_CMDS = [ + 'turo_simple_s32 0', + 'turo_simple_s32 -1', + 'turo_simple_s32 0x7FFFFFFF', + 'turo_simple_s32 -2147483648', + 'turo_simple_array_u8 1', + 'turo_simple_array_u8 2 255', + 'turo_simple_array_s32 0 -1 0x7FFFFFFF -2147483648', + 'turo_simple_dict_string foo bar', + 'turo_simple_dict_s32 baz -2147483648', + 'turo_simple_exit_status 0', + 'test_multi_element_dict a b c d', + 'test_netif' +] + + +FAILING_CMDS = [ + 'turo_simple_s32 a', + 'turo_simple_s32 0x100000000', + 'turo_simple_s32 -2147483649', + 'turo_simple_array_u8 -1', + 'turo_simple_array_u8 2 256', + 'turo_simple_array_s32 a b', + 'turo_simple_array_s32 -2147483649', + 'turo_simple_dict_s32 baz s', + 'turo_simple_dict_s32 baz -2147483649', + 'turo_simple_exit_status 1' +] + + +def testfunc(child): + + # Simple checking if the exit code works across everything + for cmd in PASSING_CMDS: + child.sendline(cmd) + child.expect('Success') + for cmd in FAILING_CMDS: + child.sendline(cmd) + child.expect('Error') + + +if __name__ == "__main__": + sys.exit(run(testfunc))