From 12de70d39214deff14c26173cb5808af30449f27 Mon Sep 17 00:00:00 2001 From: Andrey Miroshnikov Date: Tue, 12 Sep 2023 13:32:43 +0000 Subject: [PATCH] Adding syscall ISACaller test case (not working yet). --- .../decoder/isa/test_caller_syscall.py | 27 +++++++++++++++ src/openpower/test/syscall/__init__.py | 0 src/openpower/test/syscall/syscall_cases.py | 34 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 src/openpower/decoder/isa/test_caller_syscall.py create mode 100644 src/openpower/test/syscall/__init__.py create mode 100644 src/openpower/test/syscall/syscall_cases.py diff --git a/src/openpower/decoder/isa/test_caller_syscall.py b/src/openpower/decoder/isa/test_caller_syscall.py new file mode 100644 index 00000000..b6f57a75 --- /dev/null +++ b/src/openpower/decoder/isa/test_caller_syscall.py @@ -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 index 00000000..e69de29b diff --git a/src/openpower/test/syscall/syscall_cases.py b/src/openpower/test/syscall/syscall_cases.py new file mode 100644 index 00000000..dbf945a3 --- /dev/null +++ b/src/openpower/test/syscall/syscall_cases.py @@ -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 -- 2.30.2