aboutsummaryrefslogtreecommitdiff
path: root/debug
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2022-05-16 09:53:54 -0700
committerTim Newsome <tim@sifive.com>2022-06-08 13:10:56 -0700
commit0f07eccaf2139b129b074800cbbcfadee3b45a7e (patch)
treecef849f89dd675cf5a6a196ee131b026d651e12b /debug
parent27dbc399e23d5f9668363706accc76911d6d31fc (diff)
downloadriscv-tests-0f07eccaf2139b129b074800cbbcfadee3b45a7e.zip
riscv-tests-0f07eccaf2139b129b074800cbbcfadee3b45a7e.tar.gz
riscv-tests-0f07eccaf2139b129b074800cbbcfadee3b45a7e.tar.bz2
Test semihosting_fileio
In the original test, confirm that stdout data ends up in the OpenOCD log. In the new test, with `arm semihosting_fileio` enabled, confirm that stdout data ends up in gdb's CLI. This test requires https://github.com/riscv/riscv-openocd/pull/699.
Diffstat (limited to 'debug')
-rwxr-xr-xdebug/gdbserver.py27
-rw-r--r--debug/programs/semihosting.c4
2 files changed, 27 insertions, 4 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index 7213183..2e5a18e 100755
--- a/debug/gdbserver.py
+++ b/debug/gdbserver.py
@@ -952,10 +952,9 @@ class Semihosting(GdbSingleHartTest):
assertIn("Breakpoint", output)
assertIn("_exit", output)
assertEqual(self.gdb.p("status"), expected_result)
+ return output
def test(self):
- """Sending gdb ^C while the program is running should cause it to
- halt."""
temp = tempfile.NamedTemporaryFile(suffix=".data")
self.gdb.b("main:begin")
@@ -966,6 +965,28 @@ class Semihosting(GdbSingleHartTest):
contents = open(temp.name, "r").readlines()
assertIn("Hello, world!\n", contents)
+ # stdout should end up in the OpenOCD log
+ log = open(self.server.logname).read()
+ assertIn("Do re mi fa so la ti do!", log)
+
+class SemihostingFileio(Semihosting):
+ def setup(self):
+ self.gdb.command("monitor arm semihosting_fileio enable")
+ super().setup()
+
+ def test(self):
+ temp = tempfile.NamedTemporaryFile(suffix=".data")
+
+ self.gdb.b("main:begin")
+ self.gdb.c()
+ self.gdb.p('filename="%s"' % temp.name, ops=3)
+ output = self.exit()
+ # stdout should end up in gdb's CLI
+ assertIn("Do re mi fa so la ti do!", output)
+
+ contents = open(temp.name, "r").readlines()
+ assertIn("Hello, world!\n", contents)
+
class InterruptTest(GdbSingleHartTest):
compile_args = ("programs/interrupt.c",)
@@ -1464,7 +1485,7 @@ class DownloadTest(GdbTest):
# TODO: remove the next line so we get a bit more code to download. The
# line above that allows for more data runs into some error I don't
# have time to track down right now.
- length = min(2**14, max(2**10, self.hart.ram_size - 2048))
+ #length = min(2**14, max(2**10, self.hart.ram_size - 2048))
self.download_c = tempfile.NamedTemporaryFile(prefix="download_",
suffix=".c", delete=False)
self.download_c.write(b"#include <stdint.h>\n")
diff --git a/debug/programs/semihosting.c b/debug/programs/semihosting.c
index 2ceea8c..ea3fdde 100644
--- a/debug/programs/semihosting.c
+++ b/debug/programs/semihosting.c
@@ -65,9 +65,11 @@ int main()
{
char *filename = NULL;
const char *message = "Hello, world!\n";
+ const char *message2 = "Do re mi fa so la ti do!\n";
int fd;
begin:
fd = open(filename, O_WRONLY, 0644);
write(fd, message, strlen(message));
-} \ No newline at end of file
+ write(1, message2, strlen(message2));
+}