diff options
author | Tom Rini <trini@konsulko.com> | 2019-11-01 09:23:21 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-11-01 09:23:21 -0400 |
commit | 82679624f9aa6d1be733c46f3555d5166b6f5b72 (patch) | |
tree | 8a99cf79bc520b833e155094ef134c0526b1f005 /test/lib/test_errno_str.c | |
parent | 412326d1bc2d346d7b4faad6fa547eaf065681a2 (diff) | |
parent | 5d80a1a93d42c8325d65516cc654ff6a9ceec58a (diff) |
Merge branch '2019-10-30-master-imports'
- Migrate test.py to use python3 and current pytest.
- NVMe bugfixes
- Assorted other fixes
- Android AVB updates.
Diffstat (limited to 'test/lib/test_errno_str.c')
-rw-r--r-- | test/lib/test_errno_str.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/lib/test_errno_str.c b/test/lib/test_errno_str.c new file mode 100644 index 00000000000..8a9f1fd9805 --- /dev/null +++ b/test/lib/test_errno_str.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2019 Heinrich Schuchardt <xypron.glpk@gmx.de> + * + * Unit tests for memory functions + * + * The architecture dependent implementations run through different lines of + * code depending on the alignment and length of memory regions copied or set. + * This has to be considered in testing. + */ + +#include <common.h> +#include <command.h> +#include <errno.h> +#include <test/lib.h> +#include <test/test.h> +#include <test/ut.h> + +/** + * lib_errno_str() - unit test for errno_str() + * + * Test errno_str() with varied alignment and length of the copied buffer. + * + * @uts: unit test state + * Return: 0 = success, 1 = failure + */ +static int lib_errno_str(struct unit_test_state *uts) +{ + const char *msg; + + msg = errno_str(1); + ut_asserteq_str("Success", msg); + + msg = errno_str(0); + ut_asserteq_str("Success", msg); + + msg = errno_str(-ENOMEM); + ut_asserteq_str("Out of memory", msg); + + msg = errno_str(-99999); + ut_asserteq_str("Unknown error", msg); + + return 0; +} + +LIB_TEST(lib_errno_str, 0); |