Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Cc: nickc@redhat.com
Subject: [PATCH 3/3] sim: msp430: start a test framework
Date: Sat, 08 Mar 2014 05:28:00 -0000	[thread overview]
Message-ID: <1394256493-15084-3-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1394256493-15084-1-git-send-email-vapier@gentoo.org>

The current sim lacks any sort of tests.  Start a basic framework and
add a simple one to test the add insn.

sim/:
2014-03-08  Mike Frysinger  <vapier@gentoo.org>

	* configure.tgt (msp430*-*-*): Set sim_testsuite to yes.
	* configure: Regenerate.

sim/testsuite/:
2014-03-08  Mike Frysinger  <vapier@gentoo.org>

	* configure: Regenerate.

sim/testsuite/sim/msp430/:
2014-03-08  Mike Frysinger  <vapier@gentoo.org>

	* add.s, allinsn.exp, testutils.inc: New files.
---
 sim/configure                          |  1 +
 sim/configure.tgt                      |  1 +
 sim/testsuite/configure                |  1 +
 sim/testsuite/sim/msp430/add.s         | 20 ++++++++++
 sim/testsuite/sim/msp430/allinsn.exp   | 15 ++++++++
 sim/testsuite/sim/msp430/testutils.inc | 70 ++++++++++++++++++++++++++++++++++
 6 files changed, 108 insertions(+)
 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/configure b/sim/configure
index ab98231b..36d356e 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 39f92b6..d112e72 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/configure b/sim/testsuite/configure
index af18624..f90bd47 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/add.s b/sim/testsuite/sim/msp430/add.s
new file mode 100644
index 0000000..76247ed
--- /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 0000000..affa8ae
--- /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 0000000..6c540b1
--- /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
-- 
1.9.0


  reply	other threads:[~2014-03-08  5:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-08  5:28 [PATCH 1/3] sim: msp430: fix build time warnings Mike Frysinger
2014-03-08  5:28 ` Mike Frysinger [this message]
2014-03-10 13:56   ` [PATCH 3/3] sim: msp430: start a test framework Nicholas Clifton
2014-03-08  5:28 ` [PATCH 2/3] sim: msp430: set initial PC to ELF entry if available Mike Frysinger
2014-03-10 13:19   ` Nicholas Clifton
2014-03-10 21:09   ` DJ Delorie
2014-03-10 22:28     ` Mike Frysinger
2014-03-11  3:38   ` [PATCH v2] " Mike Frysinger
2014-03-11  3:44     ` DJ Delorie
2014-03-11  3:57       ` Mike Frysinger
2014-03-11  4:12         ` DJ Delorie
2014-03-10 13:18 ` [PATCH 1/3] sim: msp430: fix build time warnings Nicholas Clifton
2014-03-10 19:30   ` Mike Frysinger
2014-03-11 16:08     ` Nicholas Clifton
2014-03-11 19:01       ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394256493-15084-3-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox