blob: 67f76442b2719b428bebf5ccfd6afe919377f91d [file] [log] [blame]
Heinrich Schuchardtf0266112019-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
Heinrich Schuchardtf0266112019-10-15 21:46:04 +020012#include <command.h>
13#include <errno.h>
14#include <test/lib.h>
15#include <test/test.h>
16#include <test/ut.h>
17
18/**
19 * lib_errno_str() - unit test for errno_str()
20 *
21 * Test errno_str() with varied alignment and length of the copied buffer.
22 *
23 * @uts: unit test state
24 * Return: 0 = success, 1 = failure
25 */
26static int lib_errno_str(struct unit_test_state *uts)
27{
28 const char *msg;
29
30 msg = errno_str(1);
31 ut_asserteq_str("Success", msg);
32
33 msg = errno_str(0);
34 ut_asserteq_str("Success", msg);
35
36 msg = errno_str(-ENOMEM);
37 ut_asserteq_str("Out of memory", msg);
38
39 msg = errno_str(-99999);
40 ut_asserteq_str("Unknown error", msg);
41
42 return 0;
43}
44
45LIB_TEST(lib_errno_str, 0);