diff --git a/Jenkinsfiles/ubuntu-16.04.dockerfile b/Jenkinsfiles/ubuntu-16.04.dockerfile index 4c0e2d51bb..ac90d64c39 100644 --- a/Jenkinsfiles/ubuntu-16.04.dockerfile +++ b/Jenkinsfiles/ubuntu-16.04.dockerfile @@ -18,6 +18,7 @@ RUN apt-get update \ python \ python-crypto \ python-protobuf \ + python3-minimal \ texinfo \ wget \ diff --git a/LibOS/shim/test/regression/Makefile b/LibOS/shim/test/regression/Makefile index bb5480750b..bbbc72b602 100644 --- a/LibOS/shim/test/regression/Makefile +++ b/LibOS/shim/test/regression/Makefile @@ -55,13 +55,13 @@ endif .PHONY: regression regression: $(target) @echo "\n\nBasic Bootstrapping:" - @for f in $(wildcard 00_*.py); do env $(PYTHONENV) python $$f $(RUNTIME)/pal-$(PAL_HOST) || exit $$?; done + @for f in $(wildcard 00_*.py); do env $(PYTHONENV) python3 $$f $(RUNTIME)/pal-$(PAL_HOST) || exit $$?; done @echo "\n\nSyscall Support:" - @for f in $(wildcard 30_*.py); do env $(PYTHONENV) python $$f $(RUNTIME)/pal-$(PAL_HOST) || exit $$?; done + @for f in $(wildcard 30_*.py); do env $(PYTHONENV) python3 $$f $(RUNTIME)/pal-$(PAL_HOST) || exit $$?; done @echo "\n\nSocket Support:" - @for f in $(wildcard 80_*.py); do env $(PYTHONENV) python $$f $(RUNTIME)/pal-$(PAL_HOST) || exit $$?; done + @for f in $(wildcard 80_*.py); do env $(PYTHONENV) python3 $$f $(RUNTIME)/pal-$(PAL_HOST) || exit $$?; done @echo "\n\nLarge File Support:" - @for f in $(wildcard 90_*.py); do env $(PYTHONENV) python $$f $(RUNTIME)/pal-$(PAL_HOST) || exit $$?; done + @for f in $(wildcard 90_*.py); do env $(PYTHONENV) python3 $$f $(RUNTIME)/pal-$(PAL_HOST) || exit $$?; done .PHONY: clean-tmp clean-tmp: diff --git a/Pal/regression/02_File.py b/Pal/regression/02_File.py index 8cbfcf4c1a..f44e598088 100644 --- a/Pal/regression/02_File.py +++ b/Pal/regression/02_File.py @@ -1,4 +1,4 @@ -import os, sys, mmap, random, string, binascii +import os, sys, mmap, random, string from regression import Regression loader = os.environ['PAL_LOADER'] @@ -10,7 +10,7 @@ def prepare_files(args): if os.path.exists("file_nonexist.tmp"): os.remove("file_nonexist.tmp") - with open("file_delete.tmp", "w") as f: + with open("file_delete.tmp", "wb") as f: f.write(file_exist) # Running File @@ -27,13 +27,13 @@ def prepare_files(args): "File Creation Test 3 OK" in res[0].log) regression.add_check(name="File Reading", - check=lambda res: ("Read Test 1 (0th - 40th): " + binascii.hexlify(file_exist[0:40])) in res[0].log and - ("Read Test 2 (0th - 40th): " + binascii.hexlify(file_exist[0:40])) in res[0].log and - ("Read Test 3 (200th - 240th): " + binascii.hexlify(file_exist[200:240])) in res[0].log) + check=lambda res: ("Read Test 1 (0th - 40th): " + file_exist[0:40].hex()) in res[0].log and + ("Read Test 2 (0th - 40th): " + file_exist[0:40].hex()) in res[0].log and + ("Read Test 3 (200th - 240th): " + file_exist[200:240].hex()) in res[0].log) def check_write(res): global file_exist - with open("file_nonexist.tmp", "r") as f: + with open("file_nonexist.tmp", "rb") as f: file_nonexist = f.read() return file_exist[0:40] == file_nonexist[200:240] and \ file_exist[200:240] == file_nonexist[0:40] @@ -47,11 +47,10 @@ def check_write(res): check=lambda res: ("Query by Handle: type = 1, size = %d" % (len(file_exist))) in res[0].log) regression.add_check(name="File Mapping", - check=lambda res: ("Map Test 1 (0th - 40th): " + binascii.hexlify(file_exist[0:40])) in res[0].log and - ("Map Test 2 (200th - 240th): " + binascii.hexlify(file_exist[200:240])) in res[0].log and - ("Map Test 3 (4096th - 4136th): " + binascii.hexlify(file_exist[4096:4136])) in res[0].log and - ("Map Test 4 (4296th - 4336th): " + - binascii.hexlify(file_exist[4296:4336])) in res[0].log) + check=lambda res: ("Map Test 1 (0th - 40th): " + file_exist[0:40].hex()) in res[0].log and + ("Map Test 2 (200th - 240th): " + file_exist[200:240].hex()) in res[0].log and + ("Map Test 3 (4096th - 4136th): " + file_exist[4096:4136].hex()) in res[0].log and + ("Map Test 4 (4296th - 4336th): " + file_exist[4296:4336].hex()) in res[0].log) regression.add_check(name="Set File Length", check=lambda res: os.stat("file_nonexist.tmp").st_size == mmap.ALLOCATIONGRANULARITY) diff --git a/Pal/regression/04_Ipc.py b/Pal/regression/04_Ipc.py index f1e175fa39..e9da89459a 100644 --- a/Pal/regression/04_Ipc.py +++ b/Pal/regression/04_Ipc.py @@ -8,12 +8,12 @@ sgx = 0 if sgx: - print "Bulk IPC not supported on SGX" + print("Bulk IPC not supported on SGX") exit(0) ## XXX Should really be running these tests as part of CI if not os.path.exists('/dev/gipc'): - print "GIPC not loaded; skipping these tests\n" + print("GIPC not loaded; skipping these tests\n") exit(0) def prepare_files(args): diff --git a/Pal/regression/05_Process.py b/Pal/regression/05_Process.py index 869570b8b8..8d24ceb574 100644 --- a/Pal/regression/05_Process.py +++ b/Pal/regression/05_Process.py @@ -7,7 +7,7 @@ loader = os.environ['PAL_SEC'] if not os.path.exists(loader): - print "Reference monitor mode is not available on this platform" + print("Reference monitor mode is not available on this platform") exit(0) regression = Regression(loader, "Process") diff --git a/Pal/regression/05_Reference_Monitor.py b/Pal/regression/05_Reference_Monitor.py index a2ca34575d..4b0b5b0623 100644 --- a/Pal/regression/05_Reference_Monitor.py +++ b/Pal/regression/05_Reference_Monitor.py @@ -4,7 +4,7 @@ loader = os.environ['PAL_SEC'] if not os.path.exists(loader): - print "Reference monitor mode is not available on this platform" + print("Reference monitor mode is not available on this platform") exit(0) # Running Bootstrap diff --git a/Pal/regression/Makefile b/Pal/regression/Makefile index f2235cfe6c..629ca6f7dd 100644 --- a/Pal/regression/Makefile +++ b/Pal/regression/Makefile @@ -81,17 +81,17 @@ endif regression: $(call expand_target,$(target)) @printf "\n\nBasic Bootstrapping:\n" - @for f in $(wildcard 00_*.py); do env $(PYTHONENV) python $$f || exit $$?; done + @for f in $(wildcard 00_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done @printf "\n\nException Handling:\n" - @for f in $(wildcard 01_*.py); do env $(PYTHONENV) python $$f || exit $$?; done + @for f in $(wildcard 01_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done @printf "\n\nSingle-Process Functionalities:\n" - @for f in $(wildcard 02_*.py); do env $(PYTHONENV) python $$f || exit $$?; done + @for f in $(wildcard 02_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done @printf "\n\nProcess Creation:\n" - @for f in $(wildcard 03_*.py); do env $(PYTHONENV) python $$f || exit $$?; done + @for f in $(wildcard 03_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done @printf "\n\nMulti-Process Functionalities:\n" - @for f in $(wildcard 04_*.py); do env $(PYTHONENV) python $$f || exit $$?; done + @for f in $(wildcard 04_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done @printf "\n\nReference Monitor (Optional):\n" - @for f in $(wildcard 05_*.py); do env $(PYTHONENV) python $$f || exit $$?; done + @for f in $(wildcard 05_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done @printf "\n\n" .PHONY: clean diff --git a/Scripts/regression.py b/Scripts/regression.py index 5e3ca59ffb..159fa25788 100644 --- a/Scripts/regression.py +++ b/Scripts/regression.py @@ -69,8 +69,8 @@ def run_checks(self): time.sleep(0.1) - out = p.stdout.read() - log = p.stderr.read() + out = p.stdout.read().decode('utf-8') + log = p.stderr.read().decode('utf-8') outputs.append(Result(out, log, p.returncode)) @@ -80,14 +80,14 @@ def run_checks(self): if run_times == times: result = check(outputs) if not timed_out and result: - print '\033[92m[Success ]\033[0m', name + print('\033[92m[Success ]\033[0m', name) else: if ignore_failure: - print '[Fail (Ignored)]', name + print('[Fail (Ignored)]', name) else: - print '\033[93m[Fail ]\033[0m', name + print('\033[93m[Fail ]\033[0m', name) something_failed = 1 - if timed_out : print 'Test timed out!' + if timed_out : print('Test timed out!') keep_log = True if self.keep_log and keep_log: @@ -95,7 +95,7 @@ def run_checks(self): filename = 'log-' + '_'.join(sargs) + '_' + time.strftime("%Y%m%d_%H%M%S") with open(filename, 'w') as f: f.write(log + out) - print 'keep log to %s' % (filename) + print('keep log to %s' % (filename)) if something_failed: return -1 else: