From f32d1b7f589d70c6f5e15f83b0f6f94ef18bb1dd Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 8 Mar 2014 00:21:13 -0500 Subject: [PATCH] sim: msp430: start a test framework The current sim lacks any sort of tests. Start a basic framework and add a simple one to test the add insn. --- sim/ChangeLog | 5 ++ sim/configure | 1 + sim/configure.tgt | 1 + sim/testsuite/ChangeLog | 4 ++ sim/testsuite/configure | 1 + sim/testsuite/sim/msp430/ChangeLog | 3 ++ sim/testsuite/sim/msp430/add.s | 20 ++++++++ sim/testsuite/sim/msp430/allinsn.exp | 15 ++++++ sim/testsuite/sim/msp430/testutils.inc | 70 ++++++++++++++++++++++++++ 9 files changed, 120 insertions(+) create mode 100644 sim/testsuite/sim/msp430/ChangeLog create mode 100644 sim/testsuite/sim/msp430/add.s create mode 100644 sim/testsuite/sim/msp430/allinsn.exp create mode 100644 sim/testsuite/sim/msp430/testutils.inc diff --git a/sim/ChangeLog b/sim/ChangeLog index 71d9db92246..32feec8d676 100644 --- a/sim/ChangeLog +++ b/sim/ChangeLog @@ -1,3 +1,8 @@ +2014-03-10 Mike Frysinger + + * configure.tgt (msp430*-*-*): Set sim_testsuite to yes. + * configure: Regenerate. + 2014-01-06 Tom Tromey * common/cgen-trace.c: Don't use old VA_* macros. diff --git a/sim/configure b/sim/configure index ab98231bc35..36d356e7dcf 100755 --- a/sim/configure +++ b/sim/configure @@ -3775,6 +3775,7 @@ subdirs="$subdirs arm" subdirs="$subdirs msp430" + sim_testsuite=yes ;; rl78-*-*) diff --git a/sim/configure.tgt b/sim/configure.tgt index 39f92b645db..d112e72ff6d 100644 --- a/sim/configure.tgt +++ b/sim/configure.tgt @@ -88,6 +88,7 @@ case "${target}" in ;; msp430*-*-*) SIM_ARCH(msp430) + sim_testsuite=yes ;; rl78-*-*) SIM_ARCH(rl78) diff --git a/sim/testsuite/ChangeLog b/sim/testsuite/ChangeLog index 86aa1ce9030..be7ad565d0e 100644 --- a/sim/testsuite/ChangeLog +++ b/sim/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-03-10 Mike Frysinger + + * configure: Regenerate. + 2014-03-04 Mike Frysinger * common/bits-gen.c (main): Change to new style prototype. diff --git a/sim/testsuite/configure b/sim/testsuite/configure index af186246dbd..f90bd479fd5 100755 --- a/sim/testsuite/configure +++ b/sim/testsuite/configure @@ -1895,6 +1895,7 @@ case "${target}" in ;; msp430*-*-*) sim_arch=msp430 + sim_testsuite=yes ;; rl78-*-*) sim_arch=rl78 diff --git a/sim/testsuite/sim/msp430/ChangeLog b/sim/testsuite/sim/msp430/ChangeLog new file mode 100644 index 00000000000..d26efadac67 --- /dev/null +++ b/sim/testsuite/sim/msp430/ChangeLog @@ -0,0 +1,3 @@ +2014-03-10 Mike Frysinger + + * add.s, allinsn.exp, testutils.inc: New files. diff --git a/sim/testsuite/sim/msp430/add.s b/sim/testsuite/sim/msp430/add.s new file mode 100644 index 00000000000..76247edde84 --- /dev/null +++ b/sim/testsuite/sim/msp430/add.s @@ -0,0 +1,20 @@ +# check that basic add insn works. +# mach: msp430 + +.include "testutils.inc" + + start + + mov #10, r4 + add #23, r4 + cmp #33, r4 + jne 1f + + cmp #32, r4 + jlo 1f + + cmp #34, r4 + jhs 1f + + pass +1: fail diff --git a/sim/testsuite/sim/msp430/allinsn.exp b/sim/testsuite/sim/msp430/allinsn.exp new file mode 100644 index 00000000000..affa8aedc2a --- /dev/null +++ b/sim/testsuite/sim/msp430/allinsn.exp @@ -0,0 +1,15 @@ +# msp430 simulator testsuite + +if [istarget msp430-*] { + # all machines + set all_machs "msp430" + + foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.s]] { + # If we're only testing specific files and this isn't one of them, + # skip it. + if ![runtest_file_p $runtests $src] { + continue + } + run_sim_test $src $all_machs + } +} diff --git a/sim/testsuite/sim/msp430/testutils.inc b/sim/testsuite/sim/msp430/testutils.inc new file mode 100644 index 00000000000..6c540b1042a --- /dev/null +++ b/sim/testsuite/sim/msp430/testutils.inc @@ -0,0 +1,70 @@ +# MACRO: start +# All assembler tests should start with a call to "start" + .macro start + .text + + # Skip over these inlined funcs. + jmp __start; + + .global __pass + .type __pass, function +__pass: + write 1, _passmsg, 5 + exit 0 + + .global __fail + .type __fail, function +__fail: + write 1, _failmsg, 5 + exit 1 + + .data +_passmsg: + .ascii "pass\n" + .align 4 + +_failmsg: + .ascii "fail\n" + .align 4 + + .text + .global __start + .type __start, function +__start: + .endm + +# MACRO: system_call +# Make a libgloss/Linux system call + .macro system_call nr:req + call #(0x180|\nr); + .endm + +# MACRO: exit +# Quit the current test + .macro exit rc:req + mov #\rc, r12 + system_call 1 + .endm + +# MACRO: pass +# Write 'pass' to stdout via syscalls and quit; +# meant for non-OS operating environments + .macro pass + jmp __pass; + .endm + +# MACRO: fail +# Write 'fail' to stdout via syscalls and quit; +# meant for non-OS operating environments + .macro fail + jmp __fail; + .endm + +# MACRO: write +# Just like the write() C function; uses system calls + .macro write fd:req, buf:req, count:req + mov #\fd, r12; + mov #\buf, r13; + mov #\count, r14; + system_call 5 + .endm -- 2.30.2