blob: 8a9f1fd9805abeb2cc5b8ee3494fdfc4165f314d [file] [log] [blame]
Heinrich Schuchardt79c84de2019-10-15 21:46:04 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (c) 2019 Heinrich Schuchardt <xypron.glpk@gmx.de>
4 *
5 * Unit tests for memory functions
6 *
7 * The architecture dependent implementations run through different lines of
8 * code depending on the alignment and length of memory regions copied or set.
9 * This has to be considered in testing.
10 */
11
12#include <common.h>
13#include <command.h>
14#include <errno.h>
15#include <test/lib.h>
16#include <test/test.h>
17#include <test/ut.h>
18
19/**
20 * lib_errno_str() - unit test for errno_str()
21 *
22 * Test errno_str() with varied alignment and length of the copied buffer.
23 *
24 * @uts: unit test state
25 * Return: 0 = success, 1 = failure
26 */
27static int lib_errno_str(struct unit_test_state *uts)
28{
29 const char *msg;
30
31 msg = errno_str(1);
32 ut_asserteq_str("Success", msg);
33
34 msg = errno_str(0);
35 ut_asserteq_str("Success", msg);
36
37 msg = errno_str(-ENOMEM);
38 ut_asserteq_str("Out of memory", msg);
39
40 msg = errno_str(-99999);
41 ut_asserteq_str("Unknown error", msg);
42
43 return 0;
44}
45
46LIB_TEST(lib_errno_str, 0);