Skip to content

Commit 59d250d

Browse files
[test] add regression test for #511
1 parent 48982b5 commit 59d250d

File tree

3 files changed

+187
-0
lines changed

3 files changed

+187
-0
lines changed

test/libc/bug_511/autotest.json

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
{
2+
"transfer_files":
3+
[
4+
"bin/DEMO.8xp"
5+
],
6+
"target":
7+
{
8+
"name": "DEMO",
9+
"isASM": true
10+
},
11+
"sequence":
12+
[
13+
"action|launch",
14+
"delay|100",
15+
"hashWait|1",
16+
"key|enter",
17+
"hashWait|2",
18+
"key|enter",
19+
"hashWait|3",
20+
"key|enter",
21+
"hashWait|4",
22+
"key|enter",
23+
"hashWait|5",
24+
"key|enter",
25+
"hashWait|6",
26+
"key|enter",
27+
"hashWait|7",
28+
"key|enter",
29+
"hashWait|8",
30+
"key|enter",
31+
"hashWait|9",
32+
"key|enter",
33+
"hashWait|10",
34+
"key|enter",
35+
"hashWait|11"
36+
],
37+
"hashes":
38+
{
39+
"1":
40+
{
41+
"description": "Test 1",
42+
"start": "vram_start",
43+
"size": "vram_16_size",
44+
"expected_CRCs": [ "0C357809" ]
45+
},
46+
"2":
47+
{
48+
"description": "Test 2",
49+
"start": "vram_start",
50+
"size": "vram_16_size",
51+
"expected_CRCs": [ "C37E4C46" ]
52+
},
53+
"3":
54+
{
55+
"description": "Test 3",
56+
"start": "vram_start",
57+
"size": "vram_16_size",
58+
"expected_CRCs": [ "E680110F" ]
59+
},
60+
"4":
61+
{
62+
"description": "Test 4",
63+
"start": "vram_start",
64+
"size": "vram_16_size",
65+
"expected_CRCs": [ "F0FE4DDC" ]
66+
},
67+
"5":
68+
{
69+
"description": "Test 5",
70+
"start": "vram_start",
71+
"size": "vram_16_size",
72+
"expected_CRCs": [ "67BB7FC3" ]
73+
},
74+
"6":
75+
{
76+
"description": "Test 6",
77+
"start": "vram_start",
78+
"size": "vram_16_size",
79+
"expected_CRCs": [ "0A97FD4D" ]
80+
},
81+
"7":
82+
{
83+
"description": "Test 7",
84+
"start": "vram_start",
85+
"size": "vram_16_size",
86+
"expected_CRCs": [ "8BD8CD6E" ]
87+
},
88+
"8":
89+
{
90+
"description": "Test 8",
91+
"start": "vram_start",
92+
"size": "vram_16_size",
93+
"expected_CRCs": [ "49563B96" ]
94+
},
95+
"9":
96+
{
97+
"description": "Test 9",
98+
"start": "vram_start",
99+
"size": "vram_16_size",
100+
"expected_CRCs": [ "0D88654C" ]
101+
},
102+
"10":
103+
{
104+
"description": "Test 10",
105+
"start": "vram_start",
106+
"size": "vram_16_size",
107+
"expected_CRCs": [ "DE8AD0AF" ]
108+
},
109+
"11":
110+
{
111+
"description": "Test program exit",
112+
"start": "vram_start",
113+
"size": "vram_16_size",
114+
"expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44", "A32840C8", "349F4775" ]
115+
}
116+
}
117+
}

test/libc/bug_511/makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ----------------------------
2+
# Makefile Options
3+
# ----------------------------
4+
5+
NAME = DEMO
6+
ICON = icon.png
7+
DESCRIPTION = "CE C Toolchain Demo"
8+
COMPRESSED = NO
9+
10+
CFLAGS = -Wall -Wextra -Oz
11+
CXXFLAGS = -Wall -Wextra -Oz
12+
13+
# ----------------------------
14+
15+
include $(shell cedev-config --makefile)

test/libc/bug_511/src/main.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <string.h>
2+
#include <stdint.h>
3+
#include <stdio.h>
4+
#include <math.h>
5+
#include <ti/getcsc.h>
6+
#include <ti/screen.h>
7+
8+
int main(void)
9+
{
10+
static const uint8_t values[][4] =
11+
{
12+
{ 0xcf, 0x7f, 0x39, 0xbe }, /* -0.181151 */
13+
{ 0xcf, 0xff, 0x39, 0xbe }, /* -0.181639 */
14+
{ 0x00, 0x00, 0x00, 0x00 }, /* +0 */
15+
{ 0x00, 0x00, 0x00, 0x80 }, /* -0 */
16+
{ 0x00, 0x00, 0x80, 0x7f }, /* +inf */
17+
{ 0x00, 0x00, 0x80, 0xff }, /* -inf */
18+
{ 0x00, 0x01, 0x80, 0x7f }, /* NaN */
19+
{ 0x00, 0x01, 0x80, 0xff }, /* NaN */
20+
{ 0x00, 0x00, 0x10, 0x7f }, /* out-of-range */
21+
{ 0x00, 0x00, 0x10, 0xff }, /* out-of-range */
22+
};
23+
24+
/* expected output */
25+
/*
26+
inf = N, NaN = N: -0.181151 (cf 7f 39 be)
27+
inf = N, NaN = N: -0.181639 (cf ff 39 be)
28+
inf = N, NaN = N: 0.000000 (00 00 00 00)
29+
inf = N, NaN = N: -0.000000 (00 00 00 80)
30+
inf = Y, NaN = N: inf (00 00 80 7f)
31+
inf = Y, NaN = N: -inf (00 00 80 ff)
32+
inf = N, NaN = Y: nan (00 01 80 7f)
33+
inf = N, NaN = Y: -nan (00 01 80 ff)
34+
inf = N, NaN = N: oor (00 00 10 7f)
35+
inf = N, NaN = N: -oor (00 00 10 ff)
36+
*/
37+
38+
for (size_t i = 0; i < sizeof(values) / sizeof(*values); ++i)
39+
{
40+
float dx;
41+
42+
memcpy(&dx, values[i], sizeof dx);
43+
44+
os_ClrHome();
45+
46+
printf("inf = %c, NaN = %c: %f (%02x %02x %02x %02x)\r\n",
47+
isinf(dx) ? 'Y' : 'N',
48+
isnan(dx) ? 'Y' : 'N',
49+
dx, values[i][0], values[i][1], values[i][2], values[i][3]);
50+
51+
while (!os_GetCSC());
52+
}
53+
54+
return 0;
55+
}

0 commit comments

Comments
 (0)