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:
George Koehler 2019-09-05 13:13:02 -04:00
parent 15950f9c95
commit 20a4d401d0
7 changed files with 77 additions and 6 deletions

View file

@ -6,7 +6,8 @@ plat_testsuite {
method = "plat/cpm/emu+emu", method = "plat/cpm/emu+emu",
skipsets = { skipsets = {
"b", -- B is broken on i80 "b", -- B is broken on i80
"floats" -- floats aren't supported "floats", -- floats aren't supported
"long-long",
}, },
tests = { "./*.c" }, tests = { "./*.c" },
} }

View file

@ -4,5 +4,8 @@ plat_testsuite {
name = "tests", name = "tests",
plat = "linux68k", plat = "linux68k",
method = "plat/linux68k/emu+emu68k", method = "plat/linux68k/emu+emu68k",
skipsets = {"floats"}, -- FPU instructions not supported by emulator skipsets = {
"floats", -- FPU instructions not supported by emulator
"long-long",
},
} }

View file

@ -4,5 +4,7 @@ plat_testsuite {
name = "tests", name = "tests",
plat = "linuxmips", plat = "linuxmips",
method = "qemu-mipsel", method = "qemu-mipsel",
-- skipsets = {"m2"}, skipsets = {
"long-long",
},
} }

View file

@ -3,5 +3,8 @@ include("tests/plat/build.lua")
plat_testsuite { plat_testsuite {
name = "tests", name = "tests",
plat = "linuxppc", plat = "linuxppc",
method = "plat/linuxppc/emu+emuppc" method = "plat/linuxppc/emu+emuppc",
skipsets = {
"long-long",
},
} }

View file

@ -4,5 +4,8 @@ plat_testsuite {
name = "tests", name = "tests",
plat = "pc86", plat = "pc86",
method = "plat/pc86/emu+pc86emu", method = "plat/pc86/emu+pc86emu",
skipsets = {"floats"}, -- FPU instructions not supported by emulator skipsets = {
"floats", -- FPU instructions not supported by emulator
"long-long",
},
} }

View file

@ -4,7 +4,7 @@ definerule("plat_testsuite",
{ {
plat = { type="string" }, plat = { type="string" },
method = { 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={}}, skipsets = { type="table", default={}},
tests = { type="targets", default={} }, tests = { type="targets", default={} },
}, },

View 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();
}