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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2021 embedded brains GmbH & Co. KG
enabled-by: true
links: []
test-actions:
- action-brief: |
Call ${../if/memcpy:/name} for a sample set of buffers.
action-code: |
uint8_t src[sizeof( long ) * 10];
uint8_t dst[sizeof( long ) * 10];
uint8_t *begin;
uint8_t *end;
uint8_t *aligned_src;
uint8_t *aligned_dst;
size_t offset_src;
memset( src, 0x85, sizeof( src ) );
begin = dst;
end = begin + sizeof( dst );
aligned_src = (uint8_t *) RTEMS_ALIGN_UP( (uintptr_t) src, sizeof( long ) );
aligned_dst = (uint8_t *) RTEMS_ALIGN_UP( (uintptr_t) dst, sizeof( long ) );
for ( offset_src = 0; offset_src < sizeof( long ); ++offset_src ) {
size_t offset_dst;
for ( offset_dst = 0; offset_dst < sizeof( long ); ++offset_dst ) {
size_t size;
for ( size = 0; size < sizeof( long ) * 8; ++size ) {
uint8_t *s;
uint8_t *p;
uint8_t *q;
s = aligned_src + offset_src;
p = aligned_dst + offset_dst;
q = p + size;
Clear( begin, end );
memcpy( p, s, size );
T_true( Compare( begin, p, 0 ) );
T_true( Compare( p, q, 0x85 ) );
T_true( Compare( q, end, 0 ) );
}
}
}
checks: []
links:
- role: validation
uid: ../req/memcpy
- action-brief: |
Call ${../if/memset:/name} for a sample set of buffers.
action-code: |
uint8_t dst[sizeof( long ) * 10];
uint8_t *begin;
uint8_t *end;
uint8_t *aligned;
size_t offset;
begin = dst;
end = begin + sizeof( dst );
aligned = (uint8_t *) RTEMS_ALIGN_UP( (uintptr_t) dst, sizeof( long ) );
for ( offset = 0; offset < sizeof( long ); ++offset ) {
size_t size;
for ( size = 0; size < sizeof( long ) * 8; ++size ) {
uint8_t *p;
uint8_t *q;
p = aligned + offset;
q = p + size;
Clear( begin, end );
memset( p, 0x85, size );
T_true( Compare( begin, p, 0 ) );
T_true( Compare( p, q, 0x85 ) );
T_true( Compare( q, end, 0 ) );
}
}
checks: []
links:
- role: validation
uid: ../req/memset
test-brief: |
Tests C library functions.
test-context: []
test-context-support: null
test-description: null
test-header: null
test-includes:
- string.h
- rtems.h
test-local-includes: []
test-setup: null
test-stop: null
test-support: |
static void Clear( volatile uint8_t *b, const volatile uint8_t *e )
{
while ( b != e ) {
*b = 0;
++b;
}
}
static bool Compare(
volatile uint8_t *b,
const volatile uint8_t *e,
uint8_t expected
)
{
bool result;
result = true;
while ( b != e ) {
result = result && *b == expected;
++b;
}
return result;
}
test-target: testsuites/validation/tc-c.c
test-teardown: null
type: test-case
|