diff options
Diffstat (limited to 'src/test/testcases/testUnsecureMemRegions.py')
-rw-r--r-- | src/test/testcases/testUnsecureMemRegions.py | 206 |
1 files changed, 204 insertions, 2 deletions
diff --git a/src/test/testcases/testUnsecureMemRegions.py b/src/test/testcases/testUnsecureMemRegions.py index 129b80c4..7087e32e 100644 --- a/src/test/testcases/testUnsecureMemRegions.py +++ b/src/test/testcases/testUnsecureMemRegions.py @@ -6,6 +6,7 @@ # OpenPOWER sbe Project # # Contributors Listed Below - COPYRIGHT 2017 +# [+] International Business Machines Corp. # # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,5 +35,206 @@ err = False def main(): testUtil.runCycles( 10000000 ) - # Test case 1: open RO mem region - success - testMemProcUtil.setUnsecureMemRegion(0x08000000, 1024, 0x0000) + try: + # Close the HB dump region + testMemProcUtil.setUnsecureMemRegion(0x08000000, 32*1024*1024, 0x0120, 0) + + # Test case 1: open RO mem region - success + testcase = 1 + testMemProcUtil.setUnsecureMemRegion(0x07000000, 1024, 0x0111, 0) + # Test case 2: open RW mem region - success + # This region is kept open for mem testcases - will be closed by + # testUnsecureMemRegionsClose.py + testcase = 2 + testMemProcUtil.setUnsecureMemRegion(0x08000000, 0x2000, 0x0112, 0) + # Test case 3: close RO mem region - success + testcase = 3 + testMemProcUtil.setUnsecureMemRegion(0x07000000, 1024, 0x0120, 0) + + # Test case 4: open 9th window - failure + testcase = 4 + # 2 + testMemProcUtil.setUnsecureMemRegion(0x07000000, 0x10, 0x0111, 0) + # 3 + testMemProcUtil.setUnsecureMemRegion(0x07000010, 0x10, 0x0111, 0) + # 4 + testMemProcUtil.setUnsecureMemRegion(0x07000020, 0x10, 0x0111, 0) + # 5 + testMemProcUtil.setUnsecureMemRegion(0x07000030, 0x10, 0x0111, 0) + # 6 + testMemProcUtil.setUnsecureMemRegion(0x07000040, 0x10, 0x0111, 0) + # 7 + testMemProcUtil.setUnsecureMemRegion(0x07000050, 0x10, 0x0111, 0) + # 8 + testMemProcUtil.setUnsecureMemRegion(0x07000060, 0x10, 0x0111, 0) + # 9 - failed - response expected - + # SBE_PRI_USER_ERROR = 0x03 + # SBE_SEC_MAXIMUM_MEM_REGION_EXCEEDED = 0x16 + testMemProcUtil.setUnsecureMemRegion(0x07000070, 0x10, 0x0111, 0x00030016) + # Test case 5: open existing window - failure + testcase = 5 + # response expected + # SBE_PRI_USER_ERROR = 0x03 + # SBE_SEC_MEM_REGION_AMEND_ATTEMPTED = 0x17 + testMemProcUtil.setUnsecureMemRegion(0x07000060, 0x10, 0x0111, 0x00030017) + # Test case 6: close non-existing window - failure + testcase = 6 + # response expected + # SBE_PRI_USER_ERROR = 0x03 + # SBE_SEC_MEM_REGION_NOT_FOUND = 0x15 + testMemProcUtil.setUnsecureMemRegion(0x07000070, 0x10, 0x0120, 0x00030015) + # Test case 7: remove a window in between - adding it again should pass + testcase = 7 + testMemProcUtil.setUnsecureMemRegion(0x07000020, 0x10, 0x0120, 0) + testMemProcUtil.setUnsecureMemRegion(0x07000020, 0x10, 0x0111, 0) + # Test case 8: remove all and open again to validate removal + testcase = 8 + # 1 + testMemProcUtil.setUnsecureMemRegion(0x08000000, 0x2000, 0x0120, 0) + # Open Window with start address not exsting, but size spanning across + # existing window + # failed - response expected - + # SBE_PRI_USER_ERROR = 0x03 + # SBE_SEC_MEM_REGION_AMEND_ATTEMPTED = 0x17 + testMemProcUtil.setUnsecureMemRegion(0x06FFFFF0, 0x20, 0x0111, 0x00030017) + # 2 + testMemProcUtil.setUnsecureMemRegion(0x07000000, 0x10, 0x0120, 0) + # 3 + testMemProcUtil.setUnsecureMemRegion(0x07000010, 0x10, 0x0120, 0) + # 4 + testMemProcUtil.setUnsecureMemRegion(0x07000020, 0x10, 0x0120, 0) + # 5 + testMemProcUtil.setUnsecureMemRegion(0x07000030, 0x10, 0x0120, 0) + # 6 + testMemProcUtil.setUnsecureMemRegion(0x07000040, 0x10, 0x0120, 0) + # 7 + testMemProcUtil.setUnsecureMemRegion(0x07000050, 0x10, 0x0120, 0) + # 8 + testMemProcUtil.setUnsecureMemRegion(0x07000060, 0x10, 0x0120, 0) + # 1 + testMemProcUtil.setUnsecureMemRegion(0x08000000, 0x2000, 0x0112, 0) + # 2 + testMemProcUtil.setUnsecureMemRegion(0x07000000, 0x10, 0x0111, 0) + testcase = "8: new window subsuming exsiting windows" + # failed - response expected - + # SBE_PRI_USER_ERROR = 0x03 + # SBE_SEC_MEM_REGION_AMEND_ATTEMPTED = 0x17 + testMemProcUtil.setUnsecureMemRegion(0x06FFFFF0, 0x30, 0x0111, 0x00030017) + testcase = "8" + # 3 + testMemProcUtil.setUnsecureMemRegion(0x07000010, 0x10, 0x0111, 0) + # 4 + testMemProcUtil.setUnsecureMemRegion(0x07000020, 0x10, 0x0111, 0) + # 5 + testMemProcUtil.setUnsecureMemRegion(0x07000030, 0x10, 0x0111, 0) + # 6 + testMemProcUtil.setUnsecureMemRegion(0x07000040, 0x10, 0x0111, 0) + # 7 + testMemProcUtil.setUnsecureMemRegion(0x07000050, 0x10, 0x0111, 0) + # 8 + testMemProcUtil.setUnsecureMemRegion(0x07000060, 0x10, 0x0111, 0) + # 9 - failed - response expected - + # SBE_PRI_USER_ERROR = 0x03 + # SBE_SEC_MAXIMUM_MEM_REGION_EXCEEDED = 0x16 + testMemProcUtil.setUnsecureMemRegion(0x07000070, 0x10, 0x0111, 0x00030016) + + # Cleanup - close all the windows open except the one for mem testcases + # 2 + testMemProcUtil.setUnsecureMemRegion(0x07000000, 0x10, 0x0120, 0) + # 3 + testMemProcUtil.setUnsecureMemRegion(0x07000010, 0x10, 0x0120, 0) + # 4 + testMemProcUtil.setUnsecureMemRegion(0x07000020, 0x10, 0x0120, 0) + # 5 + testMemProcUtil.setUnsecureMemRegion(0x07000030, 0x10, 0x0120, 0) + # 6 + testMemProcUtil.setUnsecureMemRegion(0x07000040, 0x10, 0x0120, 0) + # 7 + testMemProcUtil.setUnsecureMemRegion(0x07000050, 0x10, 0x0120, 0) + # 8 + testMemProcUtil.setUnsecureMemRegion(0x07000060, 0x10, 0x0120, 0) + + # Test case 9: access memory in unopened window - ADU + testcase = 9 + testMemProcUtil.getmem_failure(0x07000060, 0x40, 0xA5, 0x00050014) + # Test case 10: access memory in unopened window - PBA + testcase = 10 + testMemProcUtil.getmem_failure(0x07000080, 0x80, 0x02, 0x00050014) + + # Test case 11: access memory spanning across two windows + testcase = 11 + testMemProcUtil.setUnsecureMemRegion(0x07000040, 0x40, 0x0111, 0) + testUtil.runCycles(100000) + testMemProcUtil.setUnsecureMemRegion(0x07000080, 0x40, 0x0111, 0) + testUtil.runCycles(100000) + testMemProcUtil.setUnsecureMemRegion(0x070000C0, 0x40, 0x0111, 0) + testUtil.runCycles(1000000) + # start and end on edges + testMemProcUtil.getmem(0x07000040, 0x80, 0xA5) + testUtil.runCycles(100000) + # start in between and end on edge + testMemProcUtil.getmem(0x07000060, 0x60, 0xA5) + testUtil.runCycles(100000) + # start on edge and end in between + testMemProcUtil.getmem(0x07000040, 0x60, 0xA5) + testUtil.runCycles(100000) + # start on edge and end in between - 3rd window + testMemProcUtil.getmem(0x07000040, 0xA0, 0xA5) + testUtil.runCycles(100000) + + testMemProcUtil.setUnsecureMemRegion(0x07000040, 0x40, 0x0120, 0) + testUtil.runCycles(100000) + testMemProcUtil.setUnsecureMemRegion(0x07000080, 0x40, 0x0120, 0) + testUtil.runCycles(100000) + testMemProcUtil.setUnsecureMemRegion(0x070000C0, 0x40, 0x0120, 0) + testUtil.runCycles(100000) + + # Test case 12: read access in read-write window - ADU + testcase = 12 + testMemProcUtil.setUnsecureMemRegion(0x07000080, 128, 0x0112, 0) + testMemProcUtil.getmem(0x07000080, 128, 0xA5) + testMemProcUtil.setUnsecureMemRegion(0x07000080, 128, 0x0120, 0) + # Test case 13: read access in read-write window - PBA + testcase = 13 + testMemProcUtil.getmem(0x08000080, 128, 0x02) + + # Test case 14: write access in read-only window - ADU + testcase = 14 + testMemProcUtil.setUnsecureMemRegion(0x07000080, 128, 0x0111, 0) + data = os.urandom(8) + data = [ord(c) for c in data] + testMemProcUtil.putmem_failure(0x07000080, data, 0xA5, 0x00050014) + # Test case 15: write access in read-only window - PBA + testcase = 15 + data = os.urandom(128) + data = [ord(c) for c in data] + testMemProcUtil.putmem_failure(0x07000080, data, 0x02, 0x00050014) + testMemProcUtil.setUnsecureMemRegion(0x07000080, 128, 0x0120, 0) + # Test case 16: access memory for which a partial window is open + testcase = 16 + testUtil.runCycles(1000000) + testMemProcUtil.setUnsecureMemRegion(0x07000040, 0x30, 0x0111, 0) + # start in between and end outside + testUtil.runCycles(1000000) + testMemProcUtil.getmem_failure(0x07000060, 0x40, 0xA5, 0x00050014) + # start on edge and end outside + testUtil.runCycles(1000000) + testMemProcUtil.getmem_failure(0x07000040, 0x40, 0xA5, 0x00050014) + # start and end within + testUtil.runCycles(1000000) + testMemProcUtil.getmem(0x07000050, 0x10, 0xA5) + testMemProcUtil.setUnsecureMemRegion(0x07000040, 0x30, 0x0120, 0) + except: + print "FAILED Test Case:"+str(testcase) + raise Exception('Failure') +#------------------------------------------------- +# Calling all test code +#------------------------------------------------- +main() + +if err: + print ("\nTest Suite completed with error(s)") + #sys.exit(1) +else: + print ("\nTest Suite completed with no errors") + #sys.exit(0); |