Add first long-long test for linux386.
Skip the long-long test set on other platforms, because they don't have long long. Each platform would need to implement 8-byte operations like `adi 8` in its code generator, and set long long to 8 bytes in its descr file. The first test is for negation, addition, and subtraction. It also requires comparison for equality.
This commit is contained in:
parent
15950f9c95
commit
20a4d401d0
|
@ -6,7 +6,8 @@ plat_testsuite {
|
|||
method = "plat/cpm/emu+emu",
|
||||
skipsets = {
|
||||
"b", -- B is broken on i80
|
||||
"floats" -- floats aren't supported
|
||||
"floats", -- floats aren't supported
|
||||
"long-long",
|
||||
},
|
||||
tests = { "./*.c" },
|
||||
}
|
||||
|
|
|
@ -4,5 +4,8 @@ plat_testsuite {
|
|||
name = "tests",
|
||||
plat = "linux68k",
|
||||
method = "plat/linux68k/emu+emu68k",
|
||||
skipsets = {"floats"}, -- FPU instructions not supported by emulator
|
||||
skipsets = {
|
||||
"floats", -- FPU instructions not supported by emulator
|
||||
"long-long",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,5 +4,7 @@ plat_testsuite {
|
|||
name = "tests",
|
||||
plat = "linuxmips",
|
||||
method = "qemu-mipsel",
|
||||
-- skipsets = {"m2"},
|
||||
skipsets = {
|
||||
"long-long",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -3,5 +3,8 @@ include("tests/plat/build.lua")
|
|||
plat_testsuite {
|
||||
name = "tests",
|
||||
plat = "linuxppc",
|
||||
method = "plat/linuxppc/emu+emuppc"
|
||||
method = "plat/linuxppc/emu+emuppc",
|
||||
skipsets = {
|
||||
"long-long",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,5 +4,8 @@ plat_testsuite {
|
|||
name = "tests",
|
||||
plat = "pc86",
|
||||
method = "plat/pc86/emu+pc86emu",
|
||||
skipsets = {"floats"}, -- FPU instructions not supported by emulator
|
||||
skipsets = {
|
||||
"floats", -- FPU instructions not supported by emulator
|
||||
"long-long",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ definerule("plat_testsuite",
|
|||
{
|
||||
plat = { type="string" },
|
||||
method = { type="string" },
|
||||
sets = { type="table", default={"core", "b", "bugs", "m2", "floats"}},
|
||||
sets = { type="table", default={"core", "b", "bugs", "m2", "floats", "long-long"}},
|
||||
skipsets = { type="table", default={}},
|
||||
tests = { type="targets", default={} },
|
||||
},
|
||||
|
|
59
tests/plat/long-long/lladdsub_e.c
Normal file
59
tests/plat/long-long/lladdsub_e.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
#include "test.h"
|
||||
|
||||
struct neg {
|
||||
long long a;
|
||||
long long neg_a; /* -a */
|
||||
} negations[] = {
|
||||
{0LL, 0LL},
|
||||
{2LL, -2LL},
|
||||
{-446020022096LL, 446020022096LL},
|
||||
};
|
||||
|
||||
struct s_addsub {
|
||||
long long a;
|
||||
long long b;
|
||||
long long a_add_b; /* a + b */
|
||||
long long a_sub_b; /* a - b */
|
||||
} s_cases[] = {
|
||||
{2LL, 1LL, 3LL, 1LL},
|
||||
{2LL, -1LL, 1LL, 3LL},
|
||||
/* a + b overflows 32 bits */
|
||||
{1930610480LL, 842500503LL, 2773110983LL, 1088109977LL},
|
||||
{-446020022096LL, 1037107331549LL, 591087309453LL, -1483127353645LL},
|
||||
{-737537585551LL, -847060446507LL, -1584598032058LL, 109522860956LL},
|
||||
};
|
||||
|
||||
struct u_addsub {
|
||||
unsigned long long a;
|
||||
unsigned long long b;
|
||||
unsigned long long a_add_b;
|
||||
unsigned long long a_sub_b;
|
||||
} u_cases[] = {
|
||||
{2ULL, 1ULL, 3ULL, 1ULL},
|
||||
/* a + b overflows 63 bits */
|
||||
{6092994517831567942ULL, 3716888886436146324ULL,
|
||||
9809883404267714266ULL, 2376105631395421618ULL},
|
||||
};
|
||||
|
||||
#define LEN(ary) (sizeof(ary) / sizeof(ary[0]))
|
||||
|
||||
void _m_a_i_n(void) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < LEN(negations); i++) {
|
||||
struct neg *n = &negations[i];
|
||||
ASSERT(n->a == -n->neg_a);
|
||||
ASSERT(-n->a == n->neg_a);
|
||||
}
|
||||
for (i = 0; i < LEN(s_cases); i++) {
|
||||
struct s_addsub *s = &s_cases[i];
|
||||
ASSERT(s->a + s->b == s->a_add_b);
|
||||
ASSERT(s->a - s->b == s->a_sub_b);
|
||||
}
|
||||
for (i = 0; i < LEN(u_cases); i++) {
|
||||
struct u_addsub *u = &u_cases[i];
|
||||
ASSERT(u->a + u->b == u->a_add_b);
|
||||
ASSERT(u->a - u->b == u->a_sub_b);
|
||||
}
|
||||
finished();
|
||||
}
|
Loading…
Reference in a new issue