import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Misc") regression.add_check(name="Query System Time", check=lambda res: "Query System Time OK" in res[0].log) regression.add_check(name="Delay Execution for 10000 Microseconds", check=lambda res: "Delay Execution for 10000 Microseconds OK" in res[0].log) regression.add_check(name="Delay Execution for 3 Seconds", check=lambda res: "Delay Execution for 3 Seconds OK" in res[0].log) regression.add_check(name="Generate Random Bits", check=lambda res: "Generate Random Bits OK" in res[0].log) rv = regression.run_checks() if rv: sys.exit(rv) regression = Regression(loader, "Hex") regression.add_check(name="Hex 2 String Helper Function", check=lambda res: "Hex test 1 is deadbeef" in res[0].log and \ "Hex test 2 is cdcdcdcdcdcdcdcd" in res[0].log) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = './pal' # Running Bootstrap regression = Regression(loader, "large-mmap") regression.add_check( name="Ftruncate", check=lambda res: "large-mmap: ftruncate OK" in res[0].out) regression.add_check(name="Large mmap", check=lambda res: "large-mmap: mmap 1 completed OK" in res[0].out and \ "large-mmap: mmap 2 completed OK" in res[0].out) regression.run_checks()
global dir_files os.mkdir("dir_exist.tmp") dir_files = [] for i in range(5): file = ''.join([random.choice(string.ascii_letters) for i in range(8)]) f = open("dir_exist.tmp/" + file, "w") f.close() dir_files.append(file) os.mkdir("dir_delete.tmp") regression = Regression(loader, "Directory", prepare_dirs) regression.add_check(name="Basic Directory Opening", check=lambda res: "Directory Open Test 1 OK" in res[ 0].log and "Directory Open Test 2 OK" in res[0].log and "Directory Open Test 3 OK" in res[0].log) regression.add_check(name="Basic Directory Creation", check=lambda res: "Directory Creation Test 1 OK" in res[ 0].log and "Directory Creation Test 2 OK" in res[0]. log and "Directory Creation Test 3 OK" in res[0].log) def check_read(res): global dir_files for file in dir_files: if ("Read Directory: " + file) not in res[0].log: return False return True
import os, sys, mmap from regression import Regression loader = sys.argv[1] # Running futex regression = Regression(loader, "futex") regression.add_check(name="Futex Wake Test", check=lambda res: "Woke all kiddos" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv) # Running futex-timeout regression = Regression(loader, "futex-timeout") regression.add_check( name="Futex Timeout Test", check=lambda res: "futex correctly timed out" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/python import os, sys, mmap, random, string from regression import Regression loader = os.environ['PAL_LOADER'] # Running Semaphore regression = Regression(loader, "Semaphore") regression.add_check( name="Semaphore: Timeout on Locked Semaphores", check=lambda res: "Locked binary semaphore timed out (1000)." in res[ 0].log and "Locked binary semaphore timed out (0)." in res[0].log) regression.add_check( name="Semaphore: Acquire Unlocked Semaphores", check=lambda res: "Locked binary semaphore successfully (-1)." in res[ 0].log and "Locked binary semaphore successfully (0)." in res[0].log) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/env python2 import os, sys, mmap from regression import Regression loader = sys.argv[1] # Running getsockopt regression = Regression(loader, "getsockopt", None) regression.add_check(name="getsockopt", check=lambda res: "getsockopt: Got socket type OK" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
import os, sys from regression import Regression loader = sys.argv[1] # Running Bootstrap regression = Regression(loader, "proc-path") regression.add_check(name="Base /proc path present", check=lambda res: "proc path test success" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/env python2 import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Pipe") regression.add_check(name="Pipe Creation", check=lambda res: "Pipe Creation 1 OK" in res[0].log) regression.add_check( name="Pipe Attributes", check=lambda res: "Pipe Attribute Query 1 on pipesrv returned OK" in res[ 0].log) regression.add_check(name="Pipe Connection", check=lambda res: "Pipe Connection 1 OK" in res[0].log) regression.add_check( name="Pipe Transmission", check=lambda res: "Pipe Write 1 OK" in res[0].log and "Pipe Read 1: Hello World 1" in res[0].log and "Pipe Write 2 OK" in res[ 0].log and "Pipe Read 2: Hello World 2" in res[0].log) rv = regression.run_checks() if rv: sys.exit(rv)
import os, sys, mmap from regression import Regression loader = sys.argv[1] # Running Bootstrap regression = Regression(loader, "proc") regression.add_check(name="Base /proc files present", check=lambda res: "/proc/1/.." in res[0].out and \ "/proc/1/cwd" in res[0].out and \ "/proc/1/exe" in res[0].out and \ "/proc/1/root" in res[0].out and \ "/proc/1/fd" in res[0].out and \ "/proc/1/maps" in res[0].out and \ "/proc/." in res[0].out and \ "/proc/1" in res[0].out and \ "/proc/self" in res[0].out and \ "/proc/meminfo" in res[0].out and \ "/proc/cpuinfo" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = '../src/pal' regression = Regression(loader, "Misc", timeout=5000) regression.add_check(name="Query System Time", check=lambda res: "Query System Time OK" in res[0].log) regression.add_check(name="Delay Execution for 10000 Microseconds", check=lambda res: "Delay Execution for 10000 Microseconds OK" in res[0].log) regression.add_check(name="Delay Execution for 3 Seconds", check=lambda res: "Delay Execution for 3 Seconds OK" in res[0].log) regression.add_check(name="Generate Random Bits", check=lambda res: "Generate Random Bits OK" in res[0].log) regression.run_checks()
import os, sys, mmap from regression import Regression loader = sys.argv[1] sgx = os.environ.get('SGX_RUN') == '1' # Running Bootstrap regression = Regression(loader, "mmap-file", None, 60000) regression.add_check(name="Private mmap beyond file range", check=lambda res: "mmap test 6 passed" in res[0].out and \ "mmap test 7 passed" in res[0].out) regression.add_check(name="Private mmap beyond file range (after fork)", check=lambda res: "mmap test 1 passed" in res[0].out and \ "mmap test 2 passed" in res[0].out and \ "mmap test 3 passed" in res[0].out and \ "mmap test 4 passed" in res[0].out) # On SGX, SIGBUS isn't always implemented correctly, for lack # of memory protection. For now, some of these cases won't work. if not sgx: regression.add_check(name="SIGBUS test", check=lambda res: "mmap test 5 passed" in res[0].out and \ "mmap test 8 passed" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
import os, sys, mmap from regression import Regression loader = sys.argv[1] # Running futex regression = Regression(loader, "futex") regression.add_check(name="Futex Wake Test", check=lambda res: "Woke all kiddos" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv) # Running futex-timeout regression = Regression(loader, "futex-timeout") regression.add_check(name="Futex Timeout Test", check=lambda res: "futex correctly timed out" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] sgx = os.environ.get('SGX_RUN') == '1' def manifest_file(file): if sgx: return file + '.manifest.sgx' else: return file + '.manifest' # Running AtomicMath regression = Regression(loader, "AtomicMath") regression.add_check(name="Atomic Math", check=lambda res: "Subtract INT_MIN: Both values match 2147483648" in res[0].log and \ "Subtract INT_MAX: Both values match -2147483647" in res[0].log and \ "Subtract LLONG_MIN: Both values match -9223372036854775808" in res[0].log and \ "Subtract LLONG_MAX: Both values match -9223372036854775807" in res[0].log) rv = regression.run_checks() if rv: sys.exit(rv)
import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Pipe") regression.add_check(name="Pipe Creation", check=lambda res: "Pipe Creation 1 OK" in res[0].log) regression.add_check(name="Pipe Attributes", check=lambda res: "Pipe Attribute Query 1 on pipesrv returned OK" in res[0].log) regression.add_check(name="Pipe Connection", check=lambda res: "Pipe Connection 1 OK" in res[0].log) regression.add_check(name="Pipe Transmission", check=lambda res: "Pipe Write 1 OK" in res[0].log and "Pipe Read 1: Hello World 1" in res[0].log and "Pipe Write 2 OK" in res[0].log and "Pipe Read 2: Hello World 2" in res[0].log) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = '../src/pal' regression = Regression(loader, "Pipe") regression.add_check(name="Pipe Creation", check=lambda res: "Pipe Creation 1 OK" in res[0].log) regression.add_check(name="Pipe Connection", check=lambda res: "Pipe Connection 1 OK" in res[0].log) regression.add_check(name="Pipe Transmission", check=lambda res: "Pipe Write 1 OK" in res[0].log and "Pipe Read 1: Hello World 1" in res[0].log and "Pipe Write 2 OK" in res[0].log and "Pipe Read 2: Hello World 2" in res[0].log) regression.run_checks()
import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] sgx = os.environ.get('SGX_RUN') == '1' def manifest_file(file): if sgx: return file + '.manifest.sgx' else: return file + '.manifest' # Running Bootstrap regression = Regression(loader, "Bootstrap") regression.add_check(name="Basic Bootstrapping", check=lambda res: "User Program Started" in res[0].log) regression.add_check(name="Control Block: Executable Name", check=lambda res: "Loaded Executable: file:Bootstrap" in res[0].log) regression.add_check(name="One Argument Given", check=lambda res: "# of Arguments: 1" in res[0].log and \ "argv[0] = file:Bootstrap" in res[0].log) regression.add_check(name="Five Arguments Given", args = ['a', 'b', 'c', 'd'], check=lambda res: "# of Arguments: 5" in res[0].log and \ "argv[1] = a" in res[0].log and "argv[2] = b" in res[0].log and \ "argv[3] = c" in res[0].log and "argv[4] = d" in res[0].log) regression.add_check(name="Control Block: Debug Stream (Inline)",
from regression import Regression loader = sys.argv[1] # Running sigaltstack regression = Regression(loader, "sigaltstack") messages = ( "OK on sigaltstack in main thread before alarm", "&act == 0x", "sig 14 count 1 goes off with sp=0x", "OK on signal stack", "OK on sigaltstack in handler", "sig 14 count 2 goes off with sp=0x", "OK on signal stack", "OK on sigaltstack in handler", "sig 14 count 3 goes off with sp=0x", "OK on signal stack", "OK on sigaltstack in handler", "OK on sigaltstack in main thread", "done exiting", ) regression.add_check(name="Sigaltstack Test", check=lambda res: all([x in res[0].out for x in messages])) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/env python2 import os, sys, mmap from regression import Regression loader = sys.argv[1] # Running Bootstrap regression = Regression(loader, "getdents", None, 10000) # This doesn't catch extraneous entries, but should be fine # until the LTP test can be run (need symlink support) regression.add_check(name="Directory listing (32-bit)", check=lambda res: "getdents: setup ok" in res[0].out and \ "getdents32: . [0x4]" in res[0].out and \ "getdents32: .. [0x4]" in res[0].out and \ "getdents32: file1 [0x8]" in res[0].out and \ "getdents32: file2 [0x8]" in res[0].out and \ "getdents32: dir3 [0x4]" in res[0].out) regression.add_check(name="Directory listing (64-bit)", check=lambda res: "getdents: setup ok" in res[0].out and \ "getdents64: . [0x4]" in res[0].out and \ "getdents64: .. [0x4]" in res[0].out and \ "getdents64: file1 [0x8]" in res[0].out and \ "getdents64: file2 [0x8]" in res[0].out and \ "getdents64: dir3 [0x4]" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/env python2 import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Socket") regression.add_check(name="TCP Socket Creation", check=lambda res: "TCP Creation 1 OK" in res[0].log) regression.add_check(name="TCP Socket Connection", check=lambda res: "TCP Connection 1 OK" in res[0].log) regression.add_check( name="TCP Socket Transmission", check=lambda res: "TCP Write 1 OK" in res[0].log and "TCP Read 1: Hello World 1" in res[0].log and "TCP Write 2 OK" in res[ 0].log and "TCP Read 2: Hello World 2" in res[0].log) regression.add_check(name="UDP Socket Creation", check=lambda res: "UDP Creation 1 OK" in res[0].log) regression.add_check(name="UDP Socket Connection", check=lambda res: "UDP Connection 1 OK" in res[0].log) regression.add_check( name="UDP Socket Transmission", check=lambda res: "UDP Write 1 OK" in res[0].log and "UDP Read 1: Hello World 1" in res[0].log and "UDP Write 2 OK" in res[
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = "../src/pal" regression = Regression(loader, "Memory") regression.add_check(name="Memory Allocation", check=lambda res: "Memory Allocation OK" in res[0].log) regression.add_check( name="Memory Allocation with Address", check=lambda res: "Memory Allocation with Address OK" in res[0].log ) regression.add_check( name="Memory Protection", check=lambda res: "Memory Allocation Protection (RW) OK" in res[0].log and "Memory Protection (R) OK" in res[0].log, ) regression.add_check(name="Memory Deallocation", check=lambda res: "Memory Deallocation OK" in res[0].log) def check_quota(res): for line in res[0].log: if line.startswith("Total Memory:"): return line != "Total Memory: 0" return False regression.add_check(name="Get Memory Total Quota", check=check_quota)
import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] sgx = os.environ.get('SGX_RUN') == '1' regression = Regression(loader, "Thread") regression.add_check(name="Thread Creation", check=lambda res: "Child Thread Created" in res[0].log and "Run in Child Thread: Hello World" in res[0].log) regression.add_check( name="Multiple Threads Run in Parallel", check=lambda res: "Threads Run in Parallel OK" in res[0].log) regression.add_check( name="Set Thread Private Segment Register", check=lambda res: "Private Message (FS Segment) 1: Hello World 1" in res[0] .log and "Private Message (FS Segment) 2: Hello World 2" in res[0].log) regression.add_check(name="Thread Exit", check=lambda res: "Child Thread Exited" in res[0].log) rv = regression.run_checks() if rv: sys.exit(rv) regression = Regression(loader, "Thread2") regression.add_check(name="Thread Cleanup: Exit by return.",
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Misc", timeout=5000) regression.add_check(name="Query System Time", check=lambda res: "Query System Time OK" in res[0].log) regression.add_check(name="Delay Execution for 10000 Microseconds", check=lambda res: "Delay Execution for 10000 Microseconds OK" in res[0].log) regression.add_check( name="Delay Execution for 3 Seconds", check=lambda res: "Delay Execution for 3 Seconds OK" in res[0].log) regression.add_check(name="Generate Random Bits", check=lambda res: "Generate Random Bits OK" in res[0].log) rv = regression.run_checks() if rv: sys.exit(rv) regression = Regression(loader, "Hex") regression.add_check(name="Hex 2 String Helper Function", check=lambda res: "Hex test 1 is deadbeef" in res[0].log and \ "Hex test 2 is cdcdcdcdcdcdcdcd" in res[0].log)
loader = os.environ['PAL_SEC'] if not os.path.exists(loader): print("Reference monitor mode is not available on this platform") exit(0) regression = Regression(loader, "Process") def check_times(target, lines, times): count = 0 for line in lines: if target == line: count += 1 return count == times regression.add_check(name="Process Creation", check=lambda res: check_times("Child Process Created", res[0].log, 3)) regression.add_check(name="Process Creation Arguments", check=lambda res: check_times("argv[0] = Process", res[0].log, 3) and check_times("argv[1] = Child", res[0].log, 3)) regression.add_check(name="Process Channel Transmission", check=lambda res: check_times("Process Write 1 OK", res[0].log, 3) and check_times("Process Read 1: Hello World 1", res[0].log, 3) and check_times("Process Write 2 OK", res[0].log, 3) and check_times("Process Read 2: Hello World 2", res[0].log, 3)) regression.add_check(name="Multi-Process Broadcast Channel Transmission", check=lambda res: check_times("Broadcast Write OK", res[0].log, 1) and check_times("Broadcast Read: Hello World 1", res[0].log, 3))
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = sys.argv[1] regression = Regression(loader, "epoll_wait_timeout", None, 50000) regression.add_check(name="epoll_wait timeout", args=['8000'], check=lambda res: "epoll_wait test passed" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = '../src/pal' regression = Regression(loader, "Thread") regression.add_check(name="Thread Creation", check=lambda res: "Child Thread Created" in res[0].log and "Run in Child Thread: Hello World" in res[0].log) regression.add_check(name="Multiple Threads Run in Parallel", check=lambda res: "Threads Run in Parallel OK" in res[0].log) regression.add_check(name="Set Thread Private Segment Register", check=lambda res: "Private Message (FS Segment) 1: Hello World 1" in res[0].log and "Private Message (FS Segment) 2: Hello World 2" in res[0].log) regression.add_check(name="Thread Exit", check=lambda res: "Child Thread Exited" in res[0].log) regression.run_checks()
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Thread") regression.add_check(name="Thread Creation", check=lambda res: "Child Thread Created" in res[0].log and "Run in Child Thread: Hello World" in res[0].log) regression.add_check( name="Multiple Threads Run in Parallel", check=lambda res: "Threads Run in Parallel OK" in res[0].log) regression.add_check( name="Set Thread Private Segment Register", check=lambda res: "Private Message (FS Segment) 1: Hello World 1" in res[0] .log and "Private Message (FS Segment) 2: Hello World 2" in res[0].log) regression.add_check(name="Thread Exit", check=lambda res: "Child Thread Exited" in res[0].log) regression.run_checks()
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = '../src/pal' # Running Bootstrap regression = Regression(loader, "Bootstrap") regression.add_check(name="Basic Bootstrapping", check=lambda res: "User Program Started" in res[0].log) regression.add_check(name="Control Block: Executable Name", check=lambda res: "Loaded Executable: file:Bootstrap" in res[0].log) regression.add_check(name="Control Block: Default Manifest", check=lambda res: "Loaded Manifest: file:manifest" in res[0].log) regression.add_check(name="One Argument Given", check=lambda res: "# of Arguments: 1" in res[0].log and \ "argv[0] = file:Bootstrap" in res[0].log) regression.add_check(name="Five Arguments Given", args = ['a', 'b', 'c', 'd'], check=lambda res: "# of Arguments: 5" in res[0].log and \ "argv[0] = file:Bootstrap" in res[0].log and \ "argv[1] = a" in res[0].log and "argv[2] = b" in res[0].log and \ "argv[3] = c" in res[0].log and "argv[4] = d" in res[0].log) regression.add_check(name="Control Block: Debug Stream (Inline)",
import os, sys, mmap from regression import Regression loader = '../src/pal' regression = Regression(loader, "Exception") def check_exception1(res): for line in res[0].log: if not line: continue if line.startswith('Div-by-Zero Exception Handler'): return True return False regression.add_check(name="Exception Handling (Div-by-Zero)", check=check_exception1) def check_exception2(res): for line in res[0].log: if not line: continue if line.startswith('Memory Fault Exception Handler'): return True return False regression.add_check(name="Exception Handling (Memory Fault)", check=check_exception2) def check_exception3(res): found1 = False found2 = False for line in res[0].log:
import os, sys, mmap from regression import Regression loader = sys.argv[1] # Running Bootstrap regression = Regression(loader, "bootstrap") regression.add_check(name="Basic Bootstrapping", check=lambda res: "User Program Started" in res[0].out) regression.add_check(name="One Argument Given", check=lambda res: "# of Arguments: 1" in res[0].out and \ "argv[0] = file:bootstrap" in res[0].out) regression.add_check(name="Five Arguments Given", args = ['a', 'b', 'c', 'd'], check=lambda res: "# of Arguments: 5" in res[0].out and \ "argv[0] = file:bootstrap" in res[0].out and \ "argv[1] = a" in res[0].out and "argv[2] = b" in res[0].out and \ "argv[3] = c" in res[0].out and "argv[4] = d" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv) # Running Exec regression = Regression(loader, "exec") regression.add_check(name="2 page child binary", check=lambda res: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 " in res[0].out)
import os, sys from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Event") regression.add_check( name="Wait for event with too short timeout", check=lambda res: "Wait with too short timeout ok." in res[0].log) regression.add_check( name="Wait for event with long enough timeout", check=lambda res: "Wait with long enough timeout ok." in res[0].log) rv = regression.run_checks() if rv: sys.exit(rv)
import os, sys, mmap from regression import Regression loader = sys.argv[1] # Running getsockopt regression = Regression(loader, "getsockopt", None) regression.add_check(name="getsockopt", check=lambda res: "getsockopt: Got socket type OK" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] is_sgx = 'SGX_RUN' in os.environ and os.environ['SGX_RUN'] == '1' success = True def manifest_file(file): if is_sgx: return file + '.manifest.sgx' else: return file + '.manifest' # Running AtomicMath regression = Regression(loader, "AtomicMath") regression.add_check(name="Atomic Math", check=lambda res: "Subtract INT_MIN: Both values match 2147483648" in res[0].log and \ "Subtract INT_MAX: Both values match -2147483647" in res[0].log and \ "Subtract LLONG_MIN: Both values match -9223372036854775808" in res[0].log and \ "Subtract LLONG_MAX: Both values match -9223372036854775807" in res[0].log) regression.run_checks()
import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Socket") regression.add_check(name="TCP Socket Creation", check=lambda res: "TCP Creation 1 OK" in res[0].log) regression.add_check(name="TCP Socket Connection", check=lambda res: "TCP Connection 1 OK" in res[0].log) regression.add_check(name="TCP Socket Transmission", check=lambda res: "TCP Write 1 OK" in res[0].log and "TCP Read 1: Hello World 1" in res[0].log and "TCP Write 2 OK" in res[0].log and "TCP Read 2: Hello World 2" in res[0].log) regression.add_check(name="UDP Socket Creation", check=lambda res: "UDP Creation 1 OK" in res[0].log) regression.add_check(name="UDP Socket Connection", check=lambda res: "UDP Connection 1 OK" in res[0].log) regression.add_check(name="UDP Socket Transmission", check=lambda res: "UDP Write 1 OK" in res[0].log and "UDP Read 1: Hello World 1" in res[0].log and "UDP Write 2 OK" in res[0].log and "UDP Read 2: Hello World 2" in res[0].log)
'DkSynchronizationEventCreate', 'DkEventSet', 'DkEventClear', 'DkObjectsWaitAny', 'DkObjectClose', 'DkSystemTimeQuery', 'DkRandomBitsRead', 'DkInstructionCacheFlush', 'DkSegmentRegister', 'DkMemoryAvailableQuota', 'DkCreatePhysicalMemoryChannel', 'DkPhysicalMemoryCommit', 'DkPhysicalMemoryMap'] def check_symbols(res): for sym in all_symbols: found = False for line in res[0].log: if line and line.startswith(sym + ' = '): if line == sym + ' = 0x0': return False found = True break if not found: return False return True regression.add_check(name="Symbol Resolution", check=check_symbols); rv = regression.run_checks() if rv: sys.exit(rv)
import os, sys, mmap from regression import Regression loader = sys.argv[1] regression = Regression(loader, "epoll_wait_timeout", None, 50000) regression.add_check(name="epoll_wait timeout", args = ['8000'], check=lambda res: "epoll_wait test passed" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
file_exist = ''.join([random.choice(string.ascii_letters) for i in range(mmap.PAGESIZE)]) with open("file_exist.tmp", "w") as f: f.write(file_exist) if os.path.exists("file_nonexist.tmp"): os.remove("file_nonexist.tmp") with open("file_delete.tmp", "w") as f: f.write(file_exist) # Running File regression = Regression(loader, "File", prepare_files) regression.add_check(name="Basic File Opening", check=lambda res: "File Open Test 1 OK" in res[0].log and "File Open Test 2 OK" in res[0].log and "File Open Test 3 OK" in res[0].log) regression.add_check(name="Basic File Creation", check=lambda res: "File Creation Test 1 OK" in res[0].log and "File Creation Test 2 OK" in res[0].log and "File Creation Test 3 OK" in res[0].log) regression.add_check(name="File Reading", check=lambda res: ("Read Test 1 (0th - 40th): " + file_exist[0:40]) in res[0].log and ("Read Test 2 (0th - 40th): " + file_exist[0:40]) in res[0].log and ("Read Test 3 (200th - 240th): " + file_exist[200:240]) in res[0].log) def check_write(res): global file_exist with open("file_nonexist.tmp", "r") as f:
import sys from regression import Regression loader = sys.argv[1] regression = Regression(loader, "proc_cpuinfo", None, 50000) regression.add_check(name="proc/cpuinfo Linux-based formatting", check=lambda res: "cpuinfo test passed" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = '../src/pal' regression = Regression(loader, "Memory") regression.add_check(name="Memory Allocation", check=lambda res: "Memory Allocation OK" in res[0].log) regression.add_check( name="Memory Allocation with Address", check=lambda res: "Memory Allocation with Address OK" in res[0].log) regression.add_check( name="Memory Protection", check=lambda res: "Memory Allocation Protection (RW) OK" in res[ 0].log and "Memory Protection (R) OK" in res[0].log) regression.add_check(name="Memory Deallocation", check=lambda res: "Memory Deallocation OK" in res[0].log) def check_quota(res): for line in res[0].log: if line.startswith("Total Memory:"): return line != "Total Memory: 0" return False
global dir_files os.mkdir("dir_exist.tmp") dir_files = [] for i in range(5): file = ''.join([random.choice(string.ascii_letters) for i in range(8)]) f = open("dir_exist.tmp/" + file, "w") f.close() dir_files.append(file) os.mkdir("dir_delete.tmp") regression = Regression(loader, "Directory", prepare_dirs) regression.add_check(name="Basic Directory Opening", check=lambda res: "Directory Open Test 1 OK" in res[0].log and "Directory Open Test 2 OK" in res[0].log and "Directory Open Test 3 OK" in res[0].log) regression.add_check(name="Basic Directory Creation", check=lambda res: "Directory Creation Test 1 OK" in res[0].log and "Directory Creation Test 2 OK" in res[0].log and "Directory Creation Test 3 OK" in res[0].log) def check_read(res): global dir_files for file in dir_files: if ("Read Directory: " + file) not in res[0].log: return False return True regression.add_check(name="Directory Reading", check=check_read)
#!/usr/bin/env python2 import os, sys, mmap from regression import Regression loader = sys.argv[1] # Running futex regression = Regression(loader, "futex") regression.add_check(name="Futex Wake Test", check=lambda res: "Woke all kiddos" in res[0].out) regression.run_checks()
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = "../src/pal" regression = Regression(loader, "Pipe") regression.add_check(name="Pipe Creation", check=lambda res: "Pipe Creation 1 OK" in res[0].log) regression.add_check(name="Pipe Connection", check=lambda res: "Pipe Connection 1 OK" in res[0].log) regression.add_check( name="Pipe Transmission", check=lambda res: "Pipe Write 1 OK" in res[0].log and "Pipe Read 1: Hello World 1" in res[0].log and "Pipe Write 2 OK" in res[0].log and "Pipe Read 2: Hello World 2" in res[0].log, ) regression.run_checks()
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = './pal' # Running Bootstrap regression = Regression(loader, "bootstrap") regression.add_check(name="Basic Bootstrapping", check=lambda res: "User Program Started" in res[0].out) regression.add_check(name="One Argument Given", check=lambda res: "# of Arguments: 1" in res[0].out and \ "argv[0] = file:bootstrap" in res[0].out) regression.add_check(name="Five Arguments Given", args = ['a', 'b', 'c', 'd'], check=lambda res: "# of Arguments: 5" in res[0].out and \ "argv[0] = file:bootstrap" in res[0].out and \ "argv[1] = a" in res[0].out and "argv[2] = b" in res[0].out and \ "argv[3] = c" in res[0].out and "argv[4] = d" in res[0].out) regression.run_checks()
import sys from regression import Regression loader = sys.argv[1] # Running sigaltstack regression = Regression(loader, "sigaltstack") messages = ( "OK on sigaltstack in main thread before alarm", "&act == 0x", "sig 14 count 1 goes off with sp=0x", "OK on signal stack", "OK on sigaltstack in handler", "sig 14 count 2 goes off with sp=0x", "OK on signal stack", "OK on sigaltstack in handler", "sig 14 count 3 goes off with sp=0x", "OK on signal stack", "OK on sigaltstack in handler", "OK on sigaltstack in main thread", "done exiting", ) regression.add_check(name="Sigaltstack Test", check=lambda res: all([x in res[0].out for x in messages])) rv = regression.run_checks() if rv: sys.exit(rv)
import sys from regression import Regression loader = sys.argv[1] # Running udp regression = Regression(loader, "udp", None) regression.add_check(name="udp", check=lambda res: "Data: This is packet 0" in res[0].out and "Data: This is packet 1" in res[0].out and "Data: This is packet 2" in res[0].out and "Data: This is packet 3" in res[0].out and "Data: This is packet 4" in res[0].out and "Data: This is packet 5" in res[0].out and "Data: This is packet 6" in res[0].out and "Data: This is packet 7" in res[0].out and "Data: This is packet 8" in res[0].out and "Data: This is packet 9" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
'DkStreamAttributesSetbyHandle', 'DkStreamGetName', 'DkStreamChangeName', 'DkThreadCreate', 'DkThreadDelayExecution', 'DkThreadYieldExecution', 'DkThreadExit', 'DkThreadResume', 'DkSetExceptionHandler', 'DkExceptionReturn', 'DkMutexCreate', 'DkMutexRelease', 'DkNotificationEventCreate', 'DkSynchronizationEventCreate', 'DkEventSet', 'DkEventClear', 'DkObjectsWaitAny', 'DkObjectClose', 'DkSystemTimeQuery', 'DkRandomBitsRead', 'DkInstructionCacheFlush', 'DkSegmentRegister', 'DkMemoryAvailableQuota', 'DkCreatePhysicalMemoryChannel', 'DkPhysicalMemoryCommit', 'DkPhysicalMemoryMap' ] def check_symbols(res): for sym in all_symbols: found = False for line in res[0].log: if line and line.startswith(sym + ' = '): if line == sym + ' = 0x0': return False found = True break if not found: return False return True regression.add_check(name="Symbol Resolution", check=check_symbols) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/env python2 import os, sys, mmap from regression import Regression loader = sys.argv[1] # Running Bootstrap regression = Regression(loader, "bootstrap") regression.add_check(name="Basic Bootstrapping", check=lambda res: "User Program Started" in res[0].out) regression.add_check(name="One Argument Given", check=lambda res: "# of Arguments: 1" in res[0].out and \ "argv[0] = file:bootstrap" in res[0].out) regression.add_check(name="Five Arguments Given", args = ['a', 'b', 'c', 'd'], check=lambda res: "# of Arguments: 5" in res[0].out and \ "argv[0] = file:bootstrap" in res[0].out and \ "argv[1] = a" in res[0].out and "argv[2] = b" in res[0].out and \ "argv[3] = c" in res[0].out and "argv[4] = d" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv) # Running Exec regression = Regression(loader, "exec") regression.add_check(
#!/usr/bin/python import os, sys, mmap from regression import Regression loader = '../src/pal' regression = Regression(loader, "Exception") regression.add_check(name="Exception Handling (Div-by-Zero)", check=lambda res: any([line.startswith("Div-by-Zero Exception Handler") for line in res[0].log])) regression.add_check(name="Exception Handling (Memory Fault)", check=lambda res: any([line.startswith("Memory Fault Exception Handler") for line in res[0].log])) regression.add_check(name="Exception Handler Swap", check=lambda res: any([line.startswith("Div-by-Zero Exception Handler 1") for line in res[0].log]) and any([line.startswith("Div-by-Zero Exception Handler 2") for line in res[0].log])) regression.add_check(name="Exception Handling (Set Context)", check=lambda res: any([line.startswith("Div-by-Zero Exception Handler 1") for line in res[0].log])) regression.run_checks()
#!/usr/bin/env python2 import os, sys, mmap from regression import Regression loader = sys.argv[1] try: sgx = os.environ['SGX_RUN'] except KeyError: sgx = False # Running Bootstrap regression = Regression(loader, "mmap-file", None, 60000) regression.add_check(name="Private mmap beyond file range", check=lambda res: "mmap test 6 passed" in res[0].out and \ "mmap test 7 passed" in res[0].out) regression.add_check(name="Private mmap beyond file range (after fork)", check=lambda res: "mmap test 1 passed" in res[0].out and \ "mmap test 2 passed" in res[0].out and \ "mmap test 3 passed" in res[0].out and \ "mmap test 4 passed" in res[0].out) # On SGX, SIGBUS isn't always implemented correctly, for lack # of memory protection. For now, some of these cases won't work. if not sgx: regression.add_check(name="SIGBUS test", check=lambda res: "mmap test 5 passed" in res[0].out and \ "mmap test 8 passed" in res[0].out)
import os, sys, mmap from regression import Regression loader = sys.argv[1] # Running stat regression = Regression(loader, "stat_invalid_args") regression.add_check(name="Stat with invalid arguments", check=lambda res: "stat(invalid-path-ptr) correctly returns error" in res[0].out and \ "stat(invalid-buf-ptr) correctly returns error" in res[0].out and \ "lstat(invalid-path-ptr) correctly returns error" in res[0].out and \ "lstat(invalid-buf-ptr) correctly returns error" in res[0].out) rv = regression.run_checks() if rv: sys.exit(rv)
#!/usr/bin/env python2 import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Exception") regression.add_check(name="Exception Handling (Div-by-Zero)", check=lambda res: any([ line.startswith("Div-by-Zero Exception Handler") for line in res[0].log ])) regression.add_check(name="Exception Handling (Memory Fault)", check=lambda res: any([ line.startswith("Memory Fault Exception Handler") for line in res[0].log ])) regression.add_check(name="Exception Handler Swap", check=lambda res: any([ line.startswith("Div-by-Zero Exception Handler 1") for line in res[0].log ]) and any([ line.startswith("Div-by-Zero Exception Handler 2") for line in res[0].log ])) regression.add_check(name="Exception Handling (Set Context)",
import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "SendHandle") def check_times(target, lines, times): count = 0 for line in lines: if target == line: count += 1 return count == times regression.add_check(name="Send and Receive Handles across Processes", check=lambda res: check_times("Send Handle OK", res[0].log, 3) and check_times("Receive Handle OK", res[0].log, 3)) regression.add_check(name="Send Pipe Handle", check=lambda res: check_times("Receive Pipe Handle: Hello World", res[0].log, 1)) regression.add_check(name="Send Socket Handle", check=lambda res: check_times("Receive Socket Handle: Hello World", res[0].log, 1)) regression.add_check(name="Send File Handle", check=lambda res: check_times("Receive File Handle: Hello World", res[0].log, 1)) rv = regression.run_checks() if rv: sys.exit(rv)
import os, sys, mmap from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Process") def check_times(target, lines, times): count = 0 for line in lines: if target == line: count += 1 return count == times regression.add_check(name="Process Creation", check=lambda res: check_times("Child Process Created", res[0].log, 3)) regression.add_check(name="Process Creation Arguments", check=lambda res: check_times("argv[0] = Process", res[0].log, 3) and check_times("argv[1] = Child", res[0].log, 3)) regression.add_check(name="Process Channel Transmission", check=lambda res: check_times("Process Write 1 OK", res[0].log, 3) and check_times("Process Read 1: Hello World 1", res[0].log, 3) and check_times("Process Write 2 OK", res[0].log, 3) and check_times("Process Read 2: Hello World 2", res[0].log, 3)) regression.add_check(name="Multi-Process Broadcast Channel Transmission", check=lambda res: check_times("Broadcast Write OK", res[0].log, 1) and check_times("Broadcast Read: Hello World 1", res[0].log, 3))
import os, sys from regression import Regression loader = os.environ['PAL_LOADER'] regression = Regression(loader, "Event") regression.add_check(name="Wait for event with too short timeout", check=lambda res: "Wait with too short timeout ok." in res[0].log) regression.add_check(name="Wait for event with long enough timeout", check=lambda res: "Wait with long enough timeout ok." in res[0].log) rv = regression.run_checks() if rv: sys.exit(rv)