diff --git a/tests/plat/_dummy_e.c b/tests/plat/_dummy_e.c index 48104b5aa..39262eaaa 100644 --- a/tests/plat/_dummy_e.c +++ b/tests/plat/_dummy_e.c @@ -1,6 +1,6 @@ #include "test.h" -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT(0 == 0); diff --git a/tests/plat/bss_e.c b/tests/plat/bss_e.c new file mode 100644 index 000000000..547e7f7f1 --- /dev/null +++ b/tests/plat/bss_e.c @@ -0,0 +1,27 @@ +#include "test.h" + +/* + * EM puts these variables in BSS. Their initial values must be zero. + * Some platforms, like Linux, clear the BSS before they run the + * program. For other platforms, like pc86, we clear the BSS in + * boot.s before we call _m_a_i_n. + */ +char c; +int array[9000]; +short s; + +/* Bypasses the CRT, so there's no stdio. */ +void _m_a_i_n(void) +{ + int bad, i; + + ASSERT(c == 0); + bad = 0; + for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) { + if(array[i]) + bad++; + } + ASSERT(bad == 0); + ASSERT(s == 0); + finished(); +} diff --git a/tests/plat/bugs/bug-62-notvar_var_e.c b/tests/plat/bugs/bug-62-notvar_var_e.c index d3813bb91..cde84eed1 100644 --- a/tests/plat/bugs/bug-62-notvar_var_e.c +++ b/tests/plat/bugs/bug-62-notvar_var_e.c @@ -40,7 +40,7 @@ void c(int i, int tru, int fal) { ASSERT((i != i) == fal); } -/* Bypasses the CRT. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { a(); b(); diff --git a/tests/plat/build.lua b/tests/plat/build.lua index 42ca441d0..26676b0b1 100644 --- a/tests/plat/build.lua +++ b/tests/plat/build.lua @@ -9,22 +9,14 @@ definerule("plat_testsuite", -- Remember this is executed from the caller's directory; local -- target names will resolve there. local testfiles = filenamesof( + -- added structcopy_e.c "tests/plat/*.c", - "tests/plat/dup_e.e", - "tests/plat/exg_e.e", - "tests/plat/inn_e.e", - "tests/plat/rck_e.e", - "tests/plat/rotate_e.e", + "tests/plat/*.e", "tests/plat/*.p", "tests/plat/b/*.b", - "tests/plat/bugs/bug-22-inn_mod.mod", - "tests/plat/bugs/bug-62-notvar_var_e.c", - "tests/plat/m2/ConvTest_mod.mod", - "tests/plat/m2/NestProc_mod.mod", - "tests/plat/m2/OpenArray_mod.mod", - "tests/plat/m2/SemaTest_mod.mod", - "tests/plat/m2/Set100_mod.mod", - "tests/plat/m2/StringTest_mod.mod" + "tests/plat/bugs/*.c", + "tests/plat/bugs/*.mod", + "tests/plat/m2/*.mod" ) acklibrary { diff --git a/tests/plat/csa_e.c b/tests/plat/csa_e.c index 355b75ee7..470fbebc5 100644 --- a/tests/plat/csa_e.c +++ b/tests/plat/csa_e.c @@ -11,7 +11,7 @@ int csa(int i) } } -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT(csa(0) == 0); @@ -23,4 +23,4 @@ void _m_a_i_n(void) ASSERT(csa(6) == 0); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/csb_e.c b/tests/plat/csb_e.c index c86d31fa6..38ce05402 100644 --- a/tests/plat/csb_e.c +++ b/tests/plat/csb_e.c @@ -11,7 +11,7 @@ int csa(int i) } } -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT(csa(0) == 0); @@ -23,4 +23,4 @@ void _m_a_i_n(void) ASSERT(csa(600) == 0); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/doublecmp_e.c b/tests/plat/doublecmp_e.c index f6c1582dc..b6fe5bbad 100644 --- a/tests/plat/doublecmp_e.c +++ b/tests/plat/doublecmp_e.c @@ -4,7 +4,7 @@ double one = 1.0; double zero = 0.0; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT(zero == zero); @@ -17,4 +17,4 @@ void _m_a_i_n(void) ASSERT(one >= one); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/from_d_to_si_e.c b/tests/plat/from_d_to_si_e.c index 7f51e6c5b..bc06c755c 100644 --- a/tests/plat/from_d_to_si_e.c +++ b/tests/plat/from_d_to_si_e.c @@ -8,7 +8,7 @@ double minusone = -1.0; double big = (double)INT_MAX; double minusbig = (double)INT_MIN; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT((int)zero == 0); @@ -18,4 +18,4 @@ void _m_a_i_n(void) ASSERT((int)minusbig == INT_MIN); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/from_d_to_ui_e.c b/tests/plat/from_d_to_ui_e.c index 811780b87..7d18ca9e5 100644 --- a/tests/plat/from_d_to_ui_e.c +++ b/tests/plat/from_d_to_ui_e.c @@ -6,7 +6,7 @@ double one = 1.0; double zero = 0.0; double big = (double)UINT_MAX; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT((unsigned int)zero == 0); @@ -14,4 +14,4 @@ void _m_a_i_n(void) ASSERT((unsigned int)big == UINT_MAX); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/from_si_to_d_e.c b/tests/plat/from_si_to_d_e.c index b6c7a25ba..172361dfa 100644 --- a/tests/plat/from_si_to_d_e.c +++ b/tests/plat/from_si_to_d_e.c @@ -8,7 +8,7 @@ int minusone = -1; int big = INT_MAX; int minusbig = INT_MIN; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT((double)zero == 0.0); @@ -18,4 +18,4 @@ void _m_a_i_n(void) /* ASSERT((double)minusbig == (double)INT_MIN); FIXME: fails for now */ finished(); -} \ No newline at end of file +} diff --git a/tests/plat/from_ui_to_d_e.c b/tests/plat/from_ui_to_d_e.c index b8e017c99..383d9afad 100644 --- a/tests/plat/from_ui_to_d_e.c +++ b/tests/plat/from_ui_to_d_e.c @@ -6,7 +6,7 @@ unsigned int one_u = 1; unsigned int zero_u = 0; unsigned int big_u = UINT_MAX; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT((double)zero_u == 0.0); @@ -14,4 +14,4 @@ void _m_a_i_n(void) ASSERT((double)big_u == (double)UINT_MAX); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/intadd_e.c b/tests/plat/intadd_e.c index 8e4868a62..94549814c 100644 --- a/tests/plat/intadd_e.c +++ b/tests/plat/intadd_e.c @@ -6,7 +6,7 @@ int one = 1; int zero = 0; int minusone = -1; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT((two + one) == 3); @@ -28,4 +28,4 @@ void _m_a_i_n(void) ASSERT(((unsigned int)-1 + (unsigned int)two) == 1); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/intcmp_e.c b/tests/plat/intcmp_e.c index dd7f1da75..72cfc06b1 100644 --- a/tests/plat/intcmp_e.c +++ b/tests/plat/intcmp_e.c @@ -4,7 +4,7 @@ int one = 1; int zero = 0; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT(zero == zero); @@ -62,4 +62,4 @@ void _m_a_i_n(void) ASSERT((unsigned int)1 >= (unsigned int)one); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/intdiv_e.c b/tests/plat/intdiv_e.c index c90964ced..cab76cdad 100644 --- a/tests/plat/intdiv_e.c +++ b/tests/plat/intdiv_e.c @@ -6,7 +6,7 @@ int two = 2; int one = 1; int zero = 0; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT((three / two) == 1); @@ -25,4 +25,4 @@ void _m_a_i_n(void) ASSERT((3 / -two) == -1); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/intrem_e.c b/tests/plat/intrem_e.c index 40f68d654..424152106 100644 --- a/tests/plat/intrem_e.c +++ b/tests/plat/intrem_e.c @@ -6,7 +6,7 @@ int two = 2; int one = 1; int zero = 0; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT((three % two) == 1); @@ -25,4 +25,4 @@ void _m_a_i_n(void) ASSERT((3 % -two) == 1); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/intshift_e.c b/tests/plat/intshift_e.c index 3cc6d52f9..08ef05ca1 100644 --- a/tests/plat/intshift_e.c +++ b/tests/plat/intshift_e.c @@ -6,7 +6,7 @@ int one = 1; int zero = 0; int minusone = -1; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT((one <>(unsigned int)1) == (UINT_MAX>>1)); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/intsub_e.c b/tests/plat/intsub_e.c index d8f67d3a3..b0cf08ae6 100644 --- a/tests/plat/intsub_e.c +++ b/tests/plat/intsub_e.c @@ -7,7 +7,7 @@ int one = 1; int zero = 0; int minusone = -1; -/* Bypasses the CRT, so there's no stdio or BSS initialisation. */ +/* Bypasses the CRT, so there's no stdio. */ void _m_a_i_n(void) { ASSERT((two - one) == 1); @@ -29,4 +29,4 @@ void _m_a_i_n(void) ASSERT(((unsigned int)1 - (unsigned int)two) == UINT_MAX); finished(); -} \ No newline at end of file +} diff --git a/tests/plat/structcopy_e.c b/tests/plat/structcopy_e.c new file mode 100644 index 000000000..74a9e2d30 --- /dev/null +++ b/tests/plat/structcopy_e.c @@ -0,0 +1,113 @@ +#include "test.h" + +/* ACK's C compiler uses EM's loi, sti, blm, or an inline loop to copy + * these structs. The compiler doesn't call memcpy() or other + * functions in libc, so this test passes without linking the CRT. + */ + +struct c5 { /* not a whole number of words */ + char one[5]; +}; + +struct ii { /* two words */ + int one; + int two; +}; + +struct iii { /* three words */ + int one; + int two; + int three; +}; + +int equal5(char *a, char *b) { /* a, b must have 5 characters */ + int i; + + for (i = 0; i < 5; i++) + if (a[i] != b[i]) return 0; + return 1; +} + +struct c5 make_c5(char *str) { /* str must have 5 characters */ + struct c5 out; + int i; + + for (i = 0; i < 5; i++) + out.one[i] = str[i]; + return out; +} + +struct ii make_ii(int i, int j) { + struct ii out; + + out.one = i; + out.two = j; + return out; +} + +struct iii make_iii(struct ii in, int k) { + struct iii out; + + out.one = in.one; + out.two = in.two; + out.three = k; + return out; +} + +struct c5 rotate_left_c5(struct c5 in) { + int i; + char c = in.one[0]; + + /* Modifies our copy of _in_, not caller's copy. */ + for (i = 0; i < 4; i++) + in.one[i] = in.one[i + 1]; + in.one[4] = c; + return in; +} + +struct iii rotate_left_iii(struct iii in) { + int i = in.one; + + /* Modifies our copy of _in_, not caller's copy. */ + in.one = in.two; + in.two = in.three; + in.three = i; + return in; +} + +/* Bypasses the CRT, so there's no stdio. */ +void _m_a_i_n(void) { + struct c5 earth, heart, dup_heart, rol_heart; + struct ii pair, dup_pair; + struct iii triple, dup_triple, rol_triple; + + earth = make_c5("earth"); + heart = make_c5("heart"); + dup_heart = heart; + rol_heart = rotate_left_c5(heart); + ASSERT(equal5(earth.one, "earth")); + ASSERT(equal5(heart.one, "heart")); + ASSERT(equal5(dup_heart.one, "heart")); + ASSERT(equal5(rol_heart.one, "earth")); + + pair = make_ii(29, 31); + dup_pair = pair; + triple = make_iii(pair, -9); + dup_triple = triple; + rol_triple = rotate_left_iii(triple); + ASSERT(pair.one == 29); + ASSERT(pair.two == 31); + ASSERT(dup_pair.one == 29); + ASSERT(dup_pair.two == 31); + ASSERT(triple.one == 29); + ASSERT(triple.two == 31); + ASSERT(triple.three == -9); + ASSERT(dup_triple.one == 29); + ASSERT(dup_triple.two == 31); + ASSERT(dup_triple.three == -9); + ASSERT(rol_triple.one == 31); + ASSERT(rol_triple.two == -9); + ASSERT(rol_triple.three == 29); + + finished(); +}