Adding syscall ISACaller test case (not working yet).
authorAndrey Miroshnikov <andrey@technepisteme.xyz>
Tue, 12 Sep 2023 13:32:43 +0000 (13:32 +0000)
committerAndrey Miroshnikov <andrey@technepisteme.xyz>
Tue, 12 Sep 2023 13:32:43 +0000 (13:32 +0000)
src/openpower/decoder/isa/test_caller_syscall.py [new file with mode: 0644]
src/openpower/test/syscall/__init__.py [new file with mode: 0644]
src/openpower/test/syscall/syscall_cases.py [new file with mode: 0644]

diff --git a/src/openpower/decoder/isa/test_caller_syscall.py b/src/openpower/decoder/isa/test_caller_syscall.py
new file mode 100644 (file)
index 0000000..b6f57a7
--- /dev/null
@@ -0,0 +1,27 @@
+""" Decoder tests
+
+related bugs:
+
+ * https://bugs.libre-soc.org/show_bug.cgi?id=982
+"""
+
+import unittest
+
+from openpower.test.syscall.syscall_cases import SysCallTestCase
+from openpower.test.runner import TestRunnerBase
+
+# writing the test_caller invocation this way makes it work with pytest
+
+
+class TestSysCall(TestRunnerBase):
+    def __init__(self, test):
+        assert test == 'test'
+        super().__init__(SysCallTestCase().test_data)
+
+    def test(self):
+        # dummy function to make unittest try to test this class
+        pass
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/src/openpower/test/syscall/__init__.py b/src/openpower/test/syscall/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/openpower/test/syscall/syscall_cases.py b/src/openpower/test/syscall/syscall_cases.py
new file mode 100644 (file)
index 0000000..dbf945a
--- /dev/null
@@ -0,0 +1,34 @@
+import random
+from openpower.test.common import TestAccumulatorBase, skip_case
+from openpower.endian import bigendian
+from openpower.simulator.program import Program
+#from openpower.decoder.selectable_int import SelectableInt
+#from openpower.decoder.power_enums import XER_bits
+#from openpower.decoder.isa.caller import special_sprs
+from openpower.decoder.helpers import exts
+from openpower.test.state import ExpectedState
+from openpower.util import log
+from pathlib import Path
+#import gzip
+#import json
+#import sys
+#from hashlib import sha256
+#from functools import lru_cache
+
+class SysCallTestCase(TestAccumulatorBase):
+    def case_sc(self):
+        lst = [f"sc"]
+        print(lst)
+        message = b'Hello world!\n'
+        message_len = len(message)
+        initial_regs = [0] * 32
+        initial_regs[0] = 4 # write syscall, see ppc64 ABI
+        initial_regs[3] = 1 # fd = 1 (stdout)
+        # The example code stores bits 0-63 of the msg into r4
+        # but message is actually 13 bytes, so just store 8 for now
+        msg_8bytes = int(message[0:8].hex(), 16)
+        initial_regs[4] =  msg_8bytes
+        initial_regs[5] = 8 # message_len
+        e = ExpectedState(initial_regs, pc=4)
+        e.intregs[3] = 0x10000
+        self.add_case(Program(lst, bigendian), initial_regs, expected=e)
\ No newline at end of file