aboutsummaryrefslogtreecommitdiff
path: root/test/validation/std_clib/std_clib.c
blob: e53ad3946b5e1d7289ba7a14dc3455fd330e219d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* Copyright (c) 2015, Linaro Limited
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#include <odp.h>
#include <odp_cunit_common.h>
#include "std_clib.h"

#include <string.h>

#define PATTERN 0x5e

static void std_clib_test_memcpy(void)
{
	uint8_t src[] = {0, 1,  2,  3,  4,  5,  6,  7,
			 8, 9, 10, 11, 12, 13, 14, 15};
	uint8_t dst[16];
	int ret;

	memset(dst, 0, sizeof(dst));

	odp_memcpy(dst, src, sizeof(dst));

	ret = memcmp(dst, src, sizeof(dst));

	CU_ASSERT(ret == 0);
}

static void std_clib_test_memset(void)
{
	uint8_t data[] = {0, 1,  2,  3,  4,  5,  6,  7,
			  8, 9, 10, 11, 12, 13, 14, 15};
	uint8_t ref[16];
	int ret;

	odp_memset(data, PATTERN, sizeof(data));

	memset(ref, PATTERN, sizeof(ref));

	ret = memcmp(data, ref, sizeof(data));

	CU_ASSERT(ret == 0);
}

odp_testinfo_t std_clib_suite[] = {
	ODP_TEST_INFO(std_clib_test_memcpy),
	ODP_TEST_INFO(std_clib_test_memset),
	ODP_TEST_INFO_NULL,
};

odp_suiteinfo_t std_clib_suites[] = {
	{"Std C library", NULL, NULL, std_clib_suite},
	ODP_SUITE_INFO_NULL
};

int std_clib_main(void)
{
	int ret = odp_cunit_register(std_clib_suites);

	if (ret == 0)
		ret = odp_cunit_run();

	return ret;
}