From: Luke Kenneth Casson Leighton Date: Fri, 1 Dec 2023 14:42:25 +0000 (+0000) Subject: bug 1169: elf support, minor coding style adjustment, clearer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=014fdc19b0207a35d564a680c52269841856cf9b;p=openpower-isa.git bug 1169: elf support, minor coding style adjustment, clearer --- diff --git a/src/openpower/test/elf/simple_cases.py b/src/openpower/test/elf/simple_cases.py index 9e59bc82..f70467cc 100644 --- a/src/openpower/test/elf/simple_cases.py +++ b/src/openpower/test/elf/simple_cases.py @@ -12,6 +12,7 @@ from openpower.test.common import TestAccumulatorBase, skip_case from openpower.test.state import ExpectedState from openpower.test.elf import compile_elf from openpower.consts import MSR, DEFAULT_MSR +from copy import deepcopy SYSCALL_DEF = r""" #include @@ -33,28 +34,15 @@ asm(".globl syscall\n" "blr"); """ -# we have to specify *all* sprs that our binary might possibly need to -# read, because ISACaller is annoying like that... -# https://bugs.libre-soc.org/show_bug.cgi?id=1226#c2 -_INITIAL_SPRS = ('LR', 'CTR', 'TAR', 'SVSTATE', 'SRR0', 'SRR1', - 'SVSHAPE0', 'SVSHAPE1', 'SVSHAPE2', 'SVSHAPE3') - -DEFAULT_USER_MSR = DEFAULT_MSR | (1 << MSR.PR) - -class SimpleCases(TestAccumulatorBase): - def case_hello_world(self): - prog = compile_elf(SYSCALL_DEF + r""" +hello_world = r""" void _start() { static const char msg[] = "Hello World!\n"; syscall(SYS_write, 1, (const void *)msg, sizeof(msg) - 1); syscall(SYS_exit_group, 0); } -""") - self.add_case(prog, initial_sprs=dict.fromkeys(_INITIAL_SPRS, 0), - initial_msr=DEFAULT_USER_MSR) +""" - def case_hello_world_with_data_and_bss(self): - prog = compile_elf(SYSCALL_DEF + r""" +hello_word_data_bss = r""" const char msg_in_ro_data[] = "World!\n"; char msg_in_data[] = "Hello "; char msg_in_bss[sizeof(msg_in_data)] = {}; @@ -67,14 +55,33 @@ void _start() { syscall(SYS_exit_group, 0); } """) - self.add_case(prog, initial_sprs=dict.fromkeys(_INITIAL_SPRS, 0), - initial_msr=DEFAULT_USER_MSR) - def case_just_exit(self): - prog = compile_elf(SYSCALL_DEF + r""" +just_exit = r""" void _start() { syscall(SYS_exit_group, 0); -} -""") - self.add_case(prog, initial_sprs=dict.fromkeys(_INITIAL_SPRS, 0), +""" + +# we have to specify *all* sprs that our binary might possibly need to +# read, because ISACaller is annoying like that... +# https://bugs.libre-soc.org/show_bug.cgi?id=1226#c2 +INITIAL_SPRS = ('LR', 'CTR', 'TAR', 'SVSTATE', 'SRR0', 'SRR1', + 'SVSHAPE0', 'SVSHAPE1', 'SVSHAPE2', 'SVSHAPE3') +initial_sprs = dict.fromkeys(INITIAL_SPRS, 0) + +DEFAULT_USER_MSR = DEFAULT_MSR | (1 << MSR.PR) # needs problem state + +class SimpleCases(TestAccumulatorBase): + def case_hello_world(self): + prog = compile_elf(SYSCALL_DEF + hello_world) + self.add_case(prog, initial_sprs=deepcopy(initial_sprs), + initial_msr=DEFAULT_USER_MSR) + + def case_hello_world_with_data_and_bss(self): + prog = compile_elf(SYSCALL_DEF + hello_word_data_bss) + self.add_case(prog, initial_sprs=deepcopy(initial_sprs), + initial_msr=DEFAULT_USER_MSR) + + def case_just_exit(self): + prog = compile_elf(SYSCALL_DEF + just_exit) + self.add_case(prog, initial_sprs=deepcopy(initial_sprs), initial_msr=DEFAULT_USER_MSR)