-
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/unittests: add test for kernel_defines
- Loading branch information
Showing
3 changed files
with
95 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 @@ | ||
include $(RIOTBASE)/Makefile.base |
57 changes: 57 additions & 0 deletions
57
tests/unittests/tests-kernel_defines/tests-kernel_defines.c
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,57 @@ | ||
/* | ||
* Copyright (C) 2021 ML!PA Consulting GmbH | ||
* | ||
* 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 | ||
*/ | ||
#include "embUnit.h" | ||
#include "kernel_defines.h" | ||
|
||
static void kernel_version_parse(uint32_t version, uint16_t *mayor, | ||
uint8_t *minor, uint8_t *patch) | ||
{ | ||
*mayor = version >> 16; | ||
*minor = (version >> 8) & 0xFF; | ||
*patch = version & 0xFF; | ||
} | ||
|
||
static void test_kernel_version(void) | ||
{ | ||
uint16_t mayor; | ||
uint8_t minor, patch; | ||
|
||
TEST_ASSERT(RIOT_VERSION_CODE); | ||
TEST_ASSERT(RIOT_VERSION_CODE > KERNEL_VERSION(2020,7,1)); | ||
TEST_ASSERT(RIOT_VERSION_CODE < KERNEL_VERSION(2080,10,2)); | ||
|
||
kernel_version_parse(KERNEL_VERSION(2020,7,1), | ||
&mayor, &minor, &patch); | ||
|
||
TEST_ASSERT_EQUAL_INT(2020, mayor); | ||
TEST_ASSERT_EQUAL_INT(7, minor); | ||
TEST_ASSERT_EQUAL_INT(1, patch); | ||
} | ||
|
||
Test *tests_kernel_defines_tests(void) | ||
{ | ||
EMB_UNIT_TESTFIXTURES(fixtures) { | ||
new_TestFixture(test_kernel_version), | ||
}; | ||
|
||
EMB_UNIT_TESTCALLER(kernel_defines_tests, NULL, NULL, fixtures); | ||
|
||
return (Test *)&kernel_defines_tests; | ||
} | ||
|
||
void tests_kernel_defines(void) | ||
{ | ||
TESTS_RUN(tests_kernel_defines_tests()); | ||
} | ||
/** @} */ |
37 changes: 37 additions & 0 deletions
37
tests/unittests/tests-kernel_defines/tests-kernel_defines.h
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,37 @@ | ||
/* | ||
* Copyright (C) 2021 ML!PA Consulting GmbH | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @addtogroup unittests | ||
* @{ | ||
* | ||
* @file | ||
* @brief Unittests for the ``kernel_defines`` module | ||
* | ||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com> | ||
*/ | ||
#ifndef TESTS_KERNEL_DEFINES_H | ||
#define TESTS_KERNEL_DEFINES_H | ||
|
||
#include "embUnit.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief The entry point of this test suite. | ||
*/ | ||
void tests_kernel_defines(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* TESTS_KERNEL_DEFINES_H */ | ||
/** @} */ |