From a638b6c1baea62f6a95af6066c028ab30663c563 Mon Sep 17 00:00:00 2001 From: Sebastian Meiling <s@mlng.net> Date: Mon, 3 Dec 2018 15:41:25 +0100 Subject: [PATCH] tests: verify embunit TEST_ASSERT_EQUAL_STRING --- tests/embunit/Makefile | 9 ++++++ tests/embunit/main.c | 58 +++++++++++++++++++++++++++++++++++ tests/embunit/tests/01-run.py | 18 +++++++++++ 3 files changed, 85 insertions(+) create mode 100644 tests/embunit/Makefile create mode 100644 tests/embunit/main.c create mode 100755 tests/embunit/tests/01-run.py diff --git a/tests/embunit/Makefile b/tests/embunit/Makefile new file mode 100644 index 0000000000..cd1c9e7b8b --- /dev/null +++ b/tests/embunit/Makefile @@ -0,0 +1,9 @@ +include ../Makefile.tests_common + +USEMODULE += embunit + +INCLUDES += -I$(RIOTBASE)/tests/unittests/common + +TEST_ON_CI_WHITELIST += all + +include $(RIOTBASE)/Makefile.include diff --git a/tests/embunit/main.c b/tests/embunit/main.c new file mode 100644 index 0000000000..6d8caaf5d7 --- /dev/null +++ b/tests/embunit/main.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 HAW Hamburg + * + * 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 Unit tests for embUnit + * + * @author Sebastian Meiling <s@mlng.net> + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "assert.h" +#include "embUnit.h" + +#define TEST_STRING_7 ("7") + +static const char *num = "7"; + +static void test_string_macro(void) +{ + TEST_ASSERT_EQUAL_STRING(TEST_STRING_7, num); +} + +static void test_string_array(void) +{ + int digit = 7; + char should_be[2] = { '0' + digit, 0 }; + TEST_ASSERT_EQUAL_STRING(should_be, num); +} + +TestRef test_embunit(void) +{ + EMB_UNIT_TESTFIXTURES(fixtures) { + new_TestFixture(test_string_macro), + new_TestFixture(test_string_array) + }; + + EMB_UNIT_TESTCALLER(tests_embunit, NULL, NULL, fixtures); + return (TestRef) & tests_embunit; +} + +int main(void) +{ + TESTS_START(); + TESTS_RUN(test_embunit()); + TESTS_END(); +} diff --git a/tests/embunit/tests/01-run.py b/tests/embunit/tests/01-run.py new file mode 100755 index 0000000000..5fc8788f24 --- /dev/null +++ b/tests/embunit/tests/01-run.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2017 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(r'OK \(\d+ tests\)') + + +if __name__ == "__main__": + sys.exit(run(testfunc)) -- GitLab