From e0e6c72e94c754b76b1cdd4cbc44a15762e04dee Mon Sep 17 00:00:00 2001 From: "Marty E. Plummer" Date: Fri, 10 May 2019 00:43:56 -0500 Subject: treewide: use print function instead of statement This enables better compat between python2.7 and python3.x Without this change, building with python3.x (python3.5 tested) as /usr/bin/python will result in the following error: File: "sbe/src/build/security/securityRegListGen.py", line 64 -v, --verbose enable verbose traces" ^ SyntaxError: Missing parentheses in call to 'print' Signed-off-by: Marty E. Plummer Change-Id: Id617f54096fca5cc5fcd829767595a85350e343d Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/89618 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: RAJA DAS --- src/boot/sbeCompression.py | 31 ++-- src/build/parsAndCutElf.py | 9 +- src/build/sbeOpDistribute.py | 9 +- src/build/security/securityRegListGen.py | 94 ++++++------ src/build/updateBuildTag.py | 4 +- src/test/testcases/testAbort.py | 3 +- src/test/testcases/testAduMem_124B.py | 5 +- src/test/testcases/testAduMem_ecc.py | 13 +- src/test/testcases/testAduMem_itag.py | 13 +- src/test/testcases/testAduMem_noEccNoItag.py | 13 +- src/test/testcases/testAduMem_withEccItag.py | 13 +- .../testAduMem_withEccWithItagReadWrite.py | 1 + src/test/testcases/testCntlInstruction.py | 1 + src/test/testcases/testContinueMpipl.py | 1 + src/test/testcases/testContinueSbeBoot.py | 1 + src/test/testcases/testEnterMpipl.py | 1 + src/test/testcases/testExecutorCntrlTimer.py | 9 +- src/test/testcases/testExecutorMemory.py | 12 +- src/test/testcases/testExecutorPSU.py | 18 +-- src/test/testcases/testExecutorPutRing.py | 20 +-- src/test/testcases/testExecutorStopTimer.py | 11 +- src/test/testcases/testFastArray.py | 1 + src/test/testcases/testFifoReset.py | 1 + src/test/testcases/testFlushNVDIMM.py | 2 +- src/test/testcases/testGetCapabilities.py | 6 +- src/test/testcases/testGetMem.py | 1 + src/test/testcases/testGetMem_expdata.py | 1 + src/test/testcases/testGetRing.py | 1 + src/test/testcases/testHostFFDC.py | 8 +- src/test/testcases/testIstepAuto.py | 3 +- src/test/testcases/testIstepInvalid.py | 1 + src/test/testcases/testIstepInvalidFenced.py | 1 + src/test/testcases/testIstepSuccess.py | 1 + src/test/testcases/testMatchStashPair.py | 5 +- src/test/testcases/testMemPBA.py | 37 ++--- src/test/testcases/testMemUtil.py | 7 +- src/test/testcases/testPSUGetCapabilities.py | 14 +- src/test/testcases/testPSUReadSbeMem.py | 22 +-- src/test/testcases/testPSUSetFFDCAddr.py | 5 +- src/test/testcases/testPSUSetStashPair.py | 34 ++--- src/test/testcases/testPSUUserUtil.py | 4 +- src/test/testcases/testPSUUtil.py | 81 +++++----- src/test/testcases/testPsuHostPassThrough.py | 10 +- src/test/testcases/testPutGetRegFpr.py | 1 + src/test/testcases/testPutGetRegGpr.py | 1 + src/test/testcases/testPutGetRegSpr.py | 1 + src/test/testcases/testPutMem_fail.py | 1 + src/test/testcases/testQuiesce.py | 1 + src/test/testcases/testRunTillSbeBooted.py | 7 +- src/test/testcases/testSbeDump.py | 3 +- src/test/testcases/testSecurity.py | 59 ++++---- src/test/testcases/testSecurityListDump.py | 5 +- src/test/testcases/testSram.py | 11 +- src/test/testcases/testStartInstruction.py | 1 + src/test/testcases/testStopClocks.py | 1 + src/test/testcases/testStopInstruction.py | 1 + src/test/testcases/testSuspendIO.py | 2 +- src/test/testcases/testSystemFabricMap.py | 6 +- src/test/testcases/testTraceArray.py | 1 + src/test/testcases/testUnsecureMemRegions.py | 1 + src/test/testcases/testUtil.py | 11 +- src/tools/debug/sbe-debug.py | 135 ++++++++--------- src/tools/debug/simics-debug-framework.py | 49 +++--- src/tools/utils/CommitSbeImageToCMVC.py | 167 +++++++++++---------- src/tools/utils/cmvcRelease.py | 25 +-- src/tools/utils/sbeCmvcUtility.py | 95 ++++++------ src/tools/utils/sbePatchUtility.py | 11 +- src/tools/utils/sbePrime.py | 105 ++++++------- 68 files changed, 644 insertions(+), 585 deletions(-) diff --git a/src/boot/sbeCompression.py b/src/boot/sbeCompression.py index 61ce0057..379ddf10 100755 --- a/src/boot/sbeCompression.py +++ b/src/boot/sbeCompression.py @@ -23,6 +23,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import os import subprocess import re @@ -40,17 +41,17 @@ def compress(inputFile, compressedFile): try: f = open(inputFile, "rb") except IOError as e : - print "I/O error File for File to be compressed." + print("I/O error File for File to be compressed.") sys.exit(1) try: fW = open(compressedFile, "wb") except IOError as e : - print "I/O error File for compressed file." + print("I/O error File for compressed file.") sys.exit(1) if os.stat(inputFile).st_size < 4 : - print "File is less than four bytes." + print("File is less than four bytes.") sys.exit(1) instDict = dict() @@ -132,13 +133,13 @@ def compress(inputFile, compressedFile): fW.close() def usage(): - print "usage: sbeCompression.py [-h] [-l ] [-i ]" - print "SBE Compression Parser" - print "Arguments:" - print "-h, --help\t\tshow this help message and exit" - print "-l, --imageLoc\t\tSeeprom Binary Location" - print "-i, --image\t\tSeeprom Binary" - print "-p, --p9_xip_tool\t\tp9_xip_tool path" + print("usage: sbeCompression.py [-h] [-l ] [-i ]") + print("SBE Compression Parser") + print("Arguments:") + print("-h, --help\t\tshow this help message and exit") + print("-l, --imageLoc\t\tSeeprom Binary Location") + print("-i, --image\t\tSeeprom Binary") + print("-p, --p9_xip_tool\t\tp9_xip_tool path") return 1 def main( argv ): @@ -146,7 +147,7 @@ def main( argv ): try: opts, args = getopt.getopt(argv[1:], "l:i:p:h", ['imageLoc=', 'image=', 'p9_xip_tool=', 'help']) except getopt.GetoptError as err: - print str(err) + print(str(err)) usage() exit(1) @@ -169,14 +170,14 @@ def main( argv ): cmd1 = "cp " + imagePath + "/" + image + " " + imagePath + "/" + image + ".orig" rc = os.system(cmd1) if rc: - print "Unable to make copy of seeprom binary" + print("Unable to make copy of seeprom binary") sys.exit(1) #Extract base from SEEPROM binary. cmd2 = p9_xip_tool + " " + imagePath + "/" + image + " extract .base " + imagePath + "/" + image + ".base" rc = os.system(cmd2) if rc: - print "Unable to extract the base from seeprom binary" + print("Unable to extract the base from seeprom binary") sys.exit(1) #Compress the base section @@ -186,14 +187,14 @@ def main( argv ): cmd3 = p9_xip_tool + " " + imagePath + "/" + image + " delete .base" rc = os.system(cmd3) if rc: - print "Unable to delete base section from seeprom binary" + print("Unable to delete base section from seeprom binary") sys.exit(1) #Append the base section from SEEPEOM binary. cmd4 = p9_xip_tool + " " + imagePath + "/" + image + " append .base " + imagePath + "/" + image + ".base.compressed" rc = os.system(cmd4) if rc: - print "Unable to append the base section" + print("Unable to append the base section") sys.exit(1) if __name__ == "__main__": diff --git a/src/build/parsAndCutElf.py b/src/build/parsAndCutElf.py index f6a71b9e..624d3261 100755 --- a/src/build/parsAndCutElf.py +++ b/src/build/parsAndCutElf.py @@ -23,6 +23,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import os import subprocess import re @@ -36,7 +37,7 @@ def parserElf(argv): outdir = argv[2] img = argv[3] except: - print "Missing argument : arg[0] ddlevel; arg[1] output directory; arg[2] img (seeprom/pibmem)" + print("Missing argument : arg[0] ddlevel; arg[1] output directory; arg[2] img (seeprom/pibmem)") exit(-1) SBE_OUT = outdir+"/sbe_"+img+"_"+ddlevel+".out" SBE_BIN = outdir+"/sbe_"+img+"_"+ddlevel+".bin" @@ -53,7 +54,7 @@ def parserElf(argv): if( (line.find(firstSection) != -1) ): tokens = line.split(); startSize = int( tokens[5], 16 ) - print startSize + print(startSize) break; # Get the location of sbe end @@ -64,7 +65,7 @@ def parserElf(argv): endSize = int( tokens[0], 16 ); break; - print endSize; + print(endSize) if( (startSize == 0) or (endSize == 0)): exit(-1) @@ -72,7 +73,7 @@ def parserElf(argv): cmd1 = "dd skip=" + str(startSize) + " count=" + str(endSize) + " if="+SBE_OUT+" of="+SBE_BIN+" bs=1" rc = os.system(cmd1) if ( rc ): - print "ERROR running %s: %d "%( cmd1, rc ) + print("ERROR running %s: %d "%( cmd1, rc )) exit(-1) parserElf(sys.argv) diff --git a/src/build/sbeOpDistribute.py b/src/build/sbeOpDistribute.py index 98024205..cb735b73 100755 --- a/src/build/sbeOpDistribute.py +++ b/src/build/sbeOpDistribute.py @@ -22,24 +22,25 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import os import sys import getopt def usage(): - print "usage:sbeOpDistribute.py [--sbe_binary_dir] [--img_dir] " + print("usage:sbeOpDistribute.py [--sbe_binary_dir] [--img_dir] ") def run_system_cmd(cmd): - print 'Cmd:<'+cmd+'>' + print('Cmd:<'+cmd+'>') if(os.system(cmd)): - print "ERROR running cmd:<"+cmd+">" + print("ERROR running cmd:<"+cmd+">") exit(1) def main(argv): try: opts, args = getopt.getopt(sys.argv[1:], "", ['sbe_binary_dir=', 'img_dir=', 'buildSbePart=', 'hw_ref_image=', 'sbe_binary_filename=', 'scratch_dir=', 'install', 'help']) except getopt.GetoptError as err: - print str(err) + print(str(err)) usage() exit(1) diff --git a/src/build/security/securityRegListGen.py b/src/build/security/securityRegListGen.py index c4324498..78d09fea 100644 --- a/src/build/security/securityRegListGen.py +++ b/src/build/security/securityRegListGen.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import getopt import sys import os @@ -52,29 +53,30 @@ TAG_NAME_GREYLIST = 'write_greylist' TAG_NAME_BLACKLIST = 'read_blacklist' def usage(): - print "usage: p9_security_list_gen.py [-h] [-f ] [-0 ] [-0 SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_startTimer ) @@ -116,13 +117,13 @@ def main(): regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_Timer_Cmd_success ) #Poll on HOST DoorBell Register for interrupt - print "\n Poll on Host side for Timer INTR ...\n" + print("\n Poll on Host side for Timer INTR ...\n") regObj.pollingOn( testPSUUtil.simSbeObj, timer_polling_data, 50 ) ''' Test Case 2. Stop timer when timer already expired ''' - print "\n Test Stop timer\n" + print("\n Test Stop timer\n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_StopTimer ) diff --git a/src/test/testcases/testExecutorMemory.py b/src/test/testcases/testExecutorMemory.py index aec0375e..fb738738 100644 --- a/src/test/testcases/testExecutorMemory.py +++ b/src/test/testcases/testExecutorMemory.py @@ -36,7 +36,7 @@ # 1.0 gkeishin 29/03/16 Initial create ############################################################# ''' - +from __future__ import print_function import testClass as testObj import testRegistry as reg sys.path.append("targets/p9_nimbus/sbeTest" ) @@ -67,17 +67,17 @@ sbe_test_data = ( def main(): # Intialize the class obj instances - print "\n Initializing Registry instances ...." + print("\n Initializing Registry instances ....") regObj = testObj.registry() # Registry obj def for operation - print "\n Execute SBE Test set [ Indirect Commands ] ...\n" + print("\n Execute SBE Test set [ Indirect Commands ] ...\n") # Sim obj Target Test set rc_test = regObj.ExecuteTestOp(testObj.simMemObj,sbe_test_data) if rc_test != testObj.SUCCESS: - print " SBE Test data set .. [ FAILED ] .." + print(" SBE Test data set .. [ FAILED ] ..") else: - print " SBE Test data set .. [ SUCCESS ] " - print "\n" + print(" SBE Test data set .. [ SUCCESS ] ") + print("\n") if __name__=="__main__": if testUtil.getMachineName() == "axone": diff --git a/src/test/testcases/testExecutorPSU.py b/src/test/testcases/testExecutorPSU.py index c01287b4..cac232af 100644 --- a/src/test/testcases/testExecutorPSU.py +++ b/src/test/testcases/testExecutorPSU.py @@ -36,7 +36,7 @@ # 1.0 gkeishin 29/03/16 Initial create ############################################################# ''' - +from __future__ import print_function import testPSUUtil import testRegistry as reg sys.path.append("targets/p9_nimbus/sbeTest" ) @@ -119,25 +119,25 @@ sample_test_data = ( def main(): # Intialize the class obj instances - print "\n Initializing Registry instances ...." + print("\n Initializing Registry instances ....") regObj = testPSUUtil.registry() # Registry obj def for operation - print "\n Execute SBE Test set [ PSU ] ...\n" + print("\n Execute SBE Test set [ PSU ] ...\n") # Sim obj Target Test set Raise Exception rc_test = regObj.ExecuteTestOp(testPSUUtil.simSbeObj,sbe_test_data, True) if rc_test != testPSUUtil.SUCCESS: - print " SBE Test data set .. [ Failed ] .." + print(" SBE Test data set .. [ Failed ] ..") else: - print " SBE Test data set .. [ OK ] " - print "\n Poll on Host side for INTR ...\n" + print(" SBE Test data set .. [ OK ] ") + print("\n Poll on Host side for INTR ...\n") # Sim obj Target Test set Max timedout rc_intr = regObj.pollingOn(testPSUUtil.simSbeObj,host_test_data,20) if rc_intr == testPSUUtil.SUCCESS: - print " Interrupt Event Recieved .. Success !!" + print(" Interrupt Event Recieved .. Success !!") else: - print " Interrupt not Recieved.. Exiting .." + print(" Interrupt not Recieved.. Exiting ..") - print "\n" + print("\n") if __name__=="__main__": if testUtil.getMachineName() == "axone": diff --git a/src/test/testcases/testExecutorPutRing.py b/src/test/testcases/testExecutorPutRing.py index 4585d7f5..9d3ea802 100644 --- a/src/test/testcases/testExecutorPutRing.py +++ b/src/test/testcases/testExecutorPutRing.py @@ -143,7 +143,7 @@ def main(): # Intialize the class obj instances regObj = testPSUUtil.registry() # Registry obj def for operation - print "\n Execute SBE Test set1 [ Put Ring ] ...\n" + print("\n Execute SBE Test set1 [ Put Ring ] ...\n") ''' Test Case 1 @@ -151,7 +151,7 @@ def main(): # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data1 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) @@ -160,56 +160,56 @@ def main(): # Commenting out test cases for perv and proc chiplets, as there is no # way to stop cloks for these chiplets from the test framework -# print "\n Execute SBE Test set2 [ Put Ring ] ...\n" +# print("\n Execute SBE Test set2 [ Put Ring ] ...\n") # ''' # Test Case 2 # ''' # # HOST->SBE data set execution # regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data2 ) # -# print "\n Poll on Host side for INTR ...\n" +# print("\n Poll on Host side for INTR ...\n") # #Poll on HOST DoorBell Register for interrupt # regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) # # #SBE->HOST data set execution # regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_data_success ) # -# print "\n Execute SBE Test set3 [ Put Ring ] ...\n" +# print("\n Execute SBE Test set3 [ Put Ring ] ...\n") # ''' # Test Case 3 # ''' # # HOST->SBE data set execution # regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data3 ) # -# print "\n Poll on Host side for INTR ...\n" +# print("\n Poll on Host side for INTR ...\n") # #Poll on HOST DoorBell Register for interrupt # regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) # # #SBE->HOST data set execution # regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_data_success ) # - print "\n Execute SBE Test set4 [ Put Ring ] ...\n" + print("\n Execute SBE Test set4 [ Put Ring ] ...\n") ''' Test Case 4 ''' # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data4 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) #SBE->HOST data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_data_success ) - print "\n Execute SBE Test set5 [ Put Ring ] ...\n" + print("\n Execute SBE Test set5 [ Put Ring ] ...\n") ''' Test Case 5 ''' # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data5 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) diff --git a/src/test/testcases/testExecutorStopTimer.py b/src/test/testcases/testExecutorStopTimer.py index 1cc62053..8b98d8b9 100644 --- a/src/test/testcases/testExecutorStopTimer.py +++ b/src/test/testcases/testExecutorStopTimer.py @@ -23,6 +23,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import testPSUUtil import testRegistry as reg import testUtil @@ -98,12 +99,12 @@ def main(): # Intialize the class obj instances regObj = testPSUUtil.registry() # Registry obj def for operation - print "\n Execute SBE Test set1 [ PutCntrlTimer ] ...\n" + print("\n Execute SBE Test set1 [ PutCntrlTimer ] ...\n") ''' Test Case 1 ''' - print "\n Test Start timer\n" + print("\n Test Start timer\n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_startTimer ) @@ -113,7 +114,7 @@ def main(): #SBE->HOST data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_Timer_Cmd_success ) - print "\n Test Stop timer\n" + print("\n Test Stop timer\n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_StopTimer ) @@ -126,13 +127,13 @@ def main(): regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_Timer_Cmd_success ) try: #Poll on HOST DoorBell Register for interrupt - print "\n Poll on Host side for Timer INTR ...\n" + print("\n Poll on Host side for Timer INTR ...\n") regObj.pollingOn( testPSUUtil.simSbeObj, timer_polling_data, 20 ) except: isTimerFired = False if isTimerFired: - print "\n Problem. Timer not cancelled\n" + print("\n Problem. Timer not cancelled\n") raise Exception('Timer Not cancelled '); if __name__ == "__main__": diff --git a/src/test/testcases/testFastArray.py b/src/test/testcases/testFastArray.py index dbba1baa..bee60693 100644 --- a/src/test/testcases/testFastArray.py +++ b/src/test/testcases/testFastArray.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testFifoReset.py b/src/test/testcases/testFifoReset.py index 28c99287..ba5a271c 100644 --- a/src/test/testcases/testFifoReset.py +++ b/src/test/testcases/testFifoReset.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest") sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testFlushNVDIMM.py b/src/test/testcases/testFlushNVDIMM.py index a7d6ca17..e2983db6 100755 --- a/src/test/testcases/testFlushNVDIMM.py +++ b/src/test/testcases/testFlushNVDIMM.py @@ -22,7 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG - +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testGetCapabilities.py b/src/test/testcases/testGetCapabilities.py index f6aedcec..ed451cfa 100755 --- a/src/test/testcases/testGetCapabilities.py +++ b/src/test/testcases/testGetCapabilities.py @@ -5,7 +5,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2015,2019 +# Contributors Listed Below - COPYRIGHT 2015,2020 # [+] International Business Machines Corp. # # @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) @@ -62,6 +63,9 @@ EXPDATA3 = [0xa8,0x0,0x0,0x03, #getcapability/getSbeFFDC/quiesce #------------------------------------------------- def main( ): ( rc, out ) = quiet_run_command( "sbe-ddlevel 0", output_modes.regular ) + if(rc == "DD1"): + print("Not running Get Capabilities on DD1") + return testUtil.runCycles( 10000000 ) testUtil.writeUsFifo( TESTDATA ) testUtil.writeEot( ) diff --git a/src/test/testcases/testGetMem.py b/src/test/testcases/testGetMem.py index 535a10f4..3d929a58 100644 --- a/src/test/testcases/testGetMem.py +++ b/src/test/testcases/testGetMem.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testGetMem_expdata.py b/src/test/testcases/testGetMem_expdata.py index f0c5214a..fa7ef4c6 100644 --- a/src/test/testcases/testGetMem_expdata.py +++ b/src/test/testcases/testGetMem_expdata.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testGetRing.py b/src/test/testcases/testGetRing.py index ca8da56d..a1ade679 100644 --- a/src/test/testcases/testGetRing.py +++ b/src/test/testcases/testGetRing.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testHostFFDC.py b/src/test/testcases/testHostFFDC.py index af5ec676..cb107b7b 100644 --- a/src/test/testcases/testHostFFDC.py +++ b/src/test/testcases/testHostFFDC.py @@ -22,7 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG - +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) @@ -117,12 +117,12 @@ def main(): # Intialize the class obj instances regObj = testPSUUtil.registry() # Registry obj def for operation - print "\n Execute SBE Test - Set FFDC Address\n" + print("\n Execute SBE Test - Set FFDC Address\n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) @@ -135,7 +135,7 @@ def main(): # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_invalid_ring ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) diff --git a/src/test/testcases/testIstepAuto.py b/src/test/testcases/testIstepAuto.py index d68d2135..28c0551f 100755 --- a/src/test/testcases/testIstepAuto.py +++ b/src/test/testcases/testIstepAuto.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys import copy from sim_commands import * @@ -103,7 +104,7 @@ def sbe_istep_func( inum1, inum2, node=0, isfleetwood=0): lIstepArray[startMajor][1] = lIstepArray[startMajor][0] for major in range(startMajor, endMajor+1): for minor in range(lIstepArray[major][0], lIstepArray[major][1] + 1): - print "Running:"+str(major)+"."+str(minor) + print("Running:"+str(major)+"."+str(minor)) try: TESTDATA = [0,0,0,3, diff --git a/src/test/testcases/testIstepInvalid.py b/src/test/testcases/testIstepInvalid.py index 3123ee03..95068d68 100755 --- a/src/test/testcases/testIstepInvalid.py +++ b/src/test/testcases/testIstepInvalid.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testIstepInvalidFenced.py b/src/test/testcases/testIstepInvalidFenced.py index b5c0b795..67cdca13 100755 --- a/src/test/testcases/testIstepInvalidFenced.py +++ b/src/test/testcases/testIstepInvalidFenced.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testIstepSuccess.py b/src/test/testcases/testIstepSuccess.py index 28ffccab..f88cd708 100755 --- a/src/test/testcases/testIstepSuccess.py +++ b/src/test/testcases/testIstepSuccess.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testMatchStashPair.py b/src/test/testcases/testMatchStashPair.py index d8c0f686..fc683828 100644 --- a/src/test/testcases/testMatchStashPair.py +++ b/src/test/testcases/testMatchStashPair.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) @@ -49,8 +50,8 @@ def main( ): if(data == readData): print ("Success - Write-Read PBA - WO FMODE, WO LCO") else: - print data - print readData + print(data) + print(readData) raise Exception('data mistmach') #------------------------------------------------- # Calling all test code diff --git a/src/test/testcases/testMemPBA.py b/src/test/testcases/testMemPBA.py index e57bb6df..ab3db87e 100644 --- a/src/test/testcases/testMemPBA.py +++ b/src/test/testcases/testMemPBA.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) @@ -43,8 +44,8 @@ def main( ): if(data == readData): print ("Success - Write-Read PBA - WO FMODE, WO LCO") else: - print data - print readData + print(data) + print(readData) raise Exception('data mistmach') # Partial Write test readData = testMemUtil.getmem(0x08000000, 128*3, 0x02) @@ -56,10 +57,10 @@ def main( ): if(sandwichData == readBackData): print ("Success - Write_Part-Read PBA - WO FMODE, WO LCO") else: - print readData - print data - print readBackData - print sandwichData + print(readData) + print(data) + print(readBackData) + print(sandwichData) raise Exception('data mistmach') # Second Case with Fast Mode without LCO @@ -73,8 +74,8 @@ def main( ): if(data == readData): print ("Success - Write-Read PBA - W FMODE, WO LCO") else: - print data - print readData + print(data) + print(readData) raise Exception('data mistmach') # Partial Write test readData = testMemUtil.getmem(0x08000000, 128*3, 0x22) @@ -86,10 +87,10 @@ def main( ): if(sandwichData == readBackData): print ("Success - Write_Part-Read PBA - W FMODE, WO LCO") else: - print readData - print data - print readBackData - print sandwichData + print(readData) + print(data) + print(readBackData) + print(sandwichData) raise Exception('data mistmach') # Third Case with Fast Mode with LCO @@ -103,8 +104,8 @@ def main( ): if(data == readData): print ("Success - Write-Read PBA - W FMODE, W LCO") else: - print data - print readData + print(data) + print(readData) raise Exception('data mistmach') # Partial Write test readData = testMemUtil.getmem(0x08000000, 128*3, 0x62) @@ -116,10 +117,10 @@ def main( ): if(sandwichData == readBackData): print ("Success - Write_Part-Read PBA - W FMODE, W LCO") else: - print readData - print data - print readBackData - print sandwichData + print(readData) + print(data) + print(readBackData) + print(sandwichData) raise Exception('data mistmach') #------------------------------------------------- diff --git a/src/test/testcases/testMemUtil.py b/src/test/testcases/testMemUtil.py index b7d02c2d..7ae48569 100644 --- a/src/test/testcases/testMemUtil.py +++ b/src/test/testcases/testMemUtil.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys import os import struct @@ -141,8 +142,8 @@ def getmem(addr, len, flags): readLen = testUtil.readDsEntryReturnVal() if(getsingleword(lenExp) != list(readLen)): - print getsingleword(lenExp) - print list(readLen) + print(getsingleword(lenExp)) + print(list(readLen)) raise Exception("Invalid Length") expResp = [0xc0,0xde,0xa4,0x01, @@ -185,7 +186,7 @@ def setUnsecureMemRegion(addr, size, controlFlag, responseWord): # Host to SBE req regObj = testPSUUtil.registry() regObj.ExecuteTestOp(testPSUUtil.simSbeObj, req) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5) diff --git a/src/test/testcases/testPSUGetCapabilities.py b/src/test/testcases/testPSUGetCapabilities.py index 456ae306..07eea3d4 100644 --- a/src/test/testcases/testPSUGetCapabilities.py +++ b/src/test/testcases/testPSUGetCapabilities.py @@ -22,7 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG - +from __future__ import print_function import sys import os import struct @@ -114,7 +114,7 @@ def getCapabilities(addr, size, exp_status): ) # HOST->SBE data set execution - Less length setup regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) #SBE->HOST data set execution @@ -127,12 +127,12 @@ def main(): # Run Simics initially testUtil.runCycles( 100000000 ) - print "\n Execute SBE Test - negative testcase - less size\n" + print("\n Execute SBE Test - negative testcase - less size\n") getCapabilities(0x08000000, 30, 0x00020019) - print "\n Execute SBE Test - negative testcase - not multiple of PBA\n" + print("\n Execute SBE Test - negative testcase - not multiple of PBA\n") getCapabilities(0x08000000, 129, 0x00020019) - print "\n Execute SBE Test - positive testcase \n" + print("\n Execute SBE Test - positive testcase \n") getCapabilities(0x08000000, 128, 0) testUtil.runCycles( 100000000 ); @@ -145,8 +145,8 @@ def main(): if(capMsg == readData): print ("Success - PSU get capabilities") else: - print capMsg - print readData + print(capMsg) + print(readData) raise Exception('data mistmach') if __name__ == "__main__": diff --git a/src/test/testcases/testPSUReadSbeMem.py b/src/test/testcases/testPSUReadSbeMem.py index 4f53a24e..d20192a9 100644 --- a/src/test/testcases/testPSUReadSbeMem.py +++ b/src/test/testcases/testPSUReadSbeMem.py @@ -22,7 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG - +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) @@ -88,7 +88,7 @@ def readSeeprom(offset, size, destAddr, primStatus, secStatus): # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) @@ -102,13 +102,13 @@ def main(): # Run Simics initially testUtil.runCycles( 10000000 ); - print "\n Execute SBE Test - Read SBE Mem\n" + print("\n Execute SBE Test - Read SBE Mem\n") ''' Test Case 1 ''' readSeeprom(0, 128, 0x08000000, 0, 0) - print "SUCCESS: read seeprom valid" + print("SUCCESS: read seeprom valid") # Read data from cache and verify its contents # seeprom header @@ -118,34 +118,34 @@ def main(): for byte in range(len(seepprmHdr)): if( ord(seepprmHdr[byte]) != readData[byte ]): - print "Data mismtach at: ", byte ; - print " expected: ", ord(seepprmHdr[byte]); - print " Actual: ", readData[byte]; + print("Data mismtach at: ", byte) + print(" expected: ", ord(seepprmHdr[byte])) + print(" Actual: ", readData[byte]) raise Exception('data mistmach'); ''' Test Case 2 ''' readSeeprom(0x38CA0, 0x180, 0x8973780, 0, 0) - print "SUCCESS: read seeprom HB testcase" + print("SUCCESS: read seeprom HB testcase") ''' Test Case 3 ''' readSeeprom(0x0, 0x40, 0x08000000, 0x03, 0x19) - print "SUCCESS: read seeprom size not aligned" + print("SUCCESS: read seeprom size not aligned") ''' Test Case 4 ''' readSeeprom(0x3fe80, 0x180, 0x08000000, 0x03, 0x19) - print "SUCCESS: read seeprom size exceeded" + print("SUCCESS: read seeprom size exceeded") ''' Test Case 5 ''' readSeeprom(0x7, 0x40, 0x08000000, 0x03, 0x19) - print "SUCCESS: read seeprom offset not aligned" + print("SUCCESS: read seeprom offset not aligned") if __name__ == "__main__": if testUtil.getMachineName() == "axone": diff --git a/src/test/testcases/testPSUSetFFDCAddr.py b/src/test/testcases/testPSUSetFFDCAddr.py index 5e64c6c6..14ea4c49 100644 --- a/src/test/testcases/testPSUSetFFDCAddr.py +++ b/src/test/testcases/testPSUSetFFDCAddr.py @@ -23,6 +23,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import testPSUUtil import testRegistry as reg import testUtil @@ -86,7 +87,7 @@ def main(): # Intialize the class obj instances regObj = testPSUUtil.registry() # Registry obj def for operation - print "\n Execute SBE Test - Set FFDC Address\n" + print("\n Execute SBE Test - Set FFDC Address\n") ''' Test Case 1 @@ -94,7 +95,7 @@ def main(): # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) diff --git a/src/test/testcases/testPSUSetStashPair.py b/src/test/testcases/testPSUSetStashPair.py index 24918f55..69f02035 100644 --- a/src/test/testcases/testPSUSetStashPair.py +++ b/src/test/testcases/testPSUSetStashPair.py @@ -22,7 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG - +from __future__ import print_function import sys import os import struct @@ -186,80 +186,80 @@ def main(): # Intialize the class obj instances regObj = testPSUUtil.registry() # Registry obj def for operation - print "\n Execute SBE Test \n" + print("\n Execute SBE Test \n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data1 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) #SBE->HOST data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_data_success ) testUtil.runCycles( 10000000 ); - print "\n Execute SBE Test \n" + print("\n Execute SBE Test \n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data2 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) #SBE->HOST data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_data_success ) testUtil.runCycles( 10000000 ); - print "\n Execute SBE Test \n" + print("\n Execute SBE Test \n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data3 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) #SBE->HOST data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_data_success ) testUtil.runCycles( 10000000 ); - print "\n Execute SBE Test \n" + print("\n Execute SBE Test \n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data4 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) #SBE->HOST data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_data_success ) testUtil.runCycles( 10000000 ); - print "\n Execute SBE Test \n" + print("\n Execute SBE Test \n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data5 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) #SBE->HOST data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_data_success ) testUtil.runCycles( 10000000 ); - print "\n Execute SBE Test \n" + print("\n Execute SBE Test \n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data6 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) #SBE->HOST data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_data_success ) testUtil.runCycles( 10000000 ); - print "\n Execute SBE Test \n" + print("\n Execute SBE Test \n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data7 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) #SBE->HOST data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, host_test_data_success ) testUtil.runCycles( 10000000 ); - print "\n Execute SBE Test \n" + print("\n Execute SBE Test \n") # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data8 ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) #SBE->HOST data set execution diff --git a/src/test/testcases/testPSUUserUtil.py b/src/test/testcases/testPSUUserUtil.py index d6eac4af..86cd79b9 100644 --- a/src/test/testcases/testPSUUserUtil.py +++ b/src/test/testcases/testPSUUserUtil.py @@ -37,7 +37,7 @@ # 1.0 gkeishin 29/03/16 Initial create ############################################################# ''' - +from __future__ import print_function import testPSUUtil ''' @@ -55,5 +55,5 @@ either SUCCESS or FAILURE as an end result for generalization purpose. ########################################################################## def classUtilFuncSample(i_paramArray): for input in i_paramArray: - print " classUtilFuncSample : parm: ",input + print(" classUtilFuncSample : parm: ",input) return testPSUUtil.SUCCESS diff --git a/src/test/testcases/testPSUUtil.py b/src/test/testcases/testPSUUtil.py index 0255b38f..c249ba09 100644 --- a/src/test/testcases/testPSUUtil.py +++ b/src/test/testcases/testPSUUtil.py @@ -40,6 +40,7 @@ #------------------------- # Imports packages #------------------------- +from __future__ import print_function import time import conf import testUtil @@ -104,9 +105,9 @@ class registry(object): # Read Reg value set or updated #------------------------------ def getRegData(self): - print " Addr : ",hex(self.regAddr) - print " Value : ",self.regVal - print " Size : ",self.regSize + print(" Addr : ",hex(self.regAddr)) + print(" Value : ",self.regVal) + print(" Size : ",self.regSize) #------------------------------ # Write to a Registry @@ -115,9 +116,9 @@ class registry(object): address = self.regAddr value = self.stringToByte(self.regVal) size = self.regSize -# print " WData : 0x%s -> Byte Data %s"% (self.regVal,value) -# print " Addr :", hex(address) -# print " Size : %s Bytes"% size +# print(" WData : 0x%s -> Byte Data %s"% (self.regVal,value)) +# print(" Addr :", hex(address)) +# print(" Size : %s Bytes"% size) self.__write(objType,address,value,size) return @@ -132,8 +133,8 @@ class registry(object): size = 8 for i in range (entryCount): value = stringToByte(data[i]) -# print "\n Writting ", hex(REGDATA_SBE[i]) -# print " %x %x %x %x %x %x %x %x" % (value[0],value[1],value[2],value[3],value[4],value[5],value[6],value[7]) +# print("\n Writting ", hex(REGDATA_SBE[i])) +# print(" %x %x %x %x %x %x %x %x" % (value[0],value[1],value[2],value[3],value[4],value[5],value[6],value[7])) simObj.write(None, REGDATA_SBE[regIndex], (value[0],value[1],value[2],value[3],value[4],value[5],value[6],value[7]), size) @@ -153,7 +154,7 @@ class registry(object): simObj.write(None, address, (value[0],value[1],value[2],value[3],value[4],value[5],value[6],value[7]), size) - print " SIM obj: Write %s bytes [ OK ] " % size + print(" SIM obj: Write %s bytes [ OK ] " % size) return #--------------------------- @@ -164,9 +165,9 @@ class registry(object): size = self.regSize value = self.regVal # if int(value) !=0: -# print " RData :", value -# print " Addr :", hex(address) -# print " Size : %s Bytes"% size +# print(" RData :", value) +# print(" Addr :", hex(address)) +# print(" Size : %s Bytes"% size) value = self.__read(objType,address,size) return value @@ -183,20 +184,20 @@ class registry(object): value = self.regVal # Max lentgth it should read MaxAddr = address + value # This is the addres range it could read -# print " MaxAddr Range:",hex(MaxAddr) +# print(" MaxAddr Range:",hex(MaxAddr)) OffsetAddr = address -# print " OffsetAddr:",hex(OffsetAddr) +# print(" OffsetAddr:",hex(OffsetAddr)) -# print " Memory Entries to be read : %d" % (value/8) -# print " Match Magic Number : ", magicNum +# print(" Memory Entries to be read : %d" % (value/8)) +# print(" Match Magic Number : ", magicNum) while ( OffsetAddr <= MaxAddr): sim_data = self.__read(objType,OffsetAddr,size) -# print " ", hex(OffsetAddr),self.joinListDataToHex(sim_data).upper() +# print(" ", hex(OffsetAddr),self.joinListDataToHex(sim_data).upper()) OffsetAddr += 8 if self.validateTestMemOp(sim_data,magicNum) == True: -# print " Test validated .. [ OK ]" +# print(" Test validated .. [ OK ]") return SUCCESS return FAILURE # Failed validation @@ -207,7 +208,7 @@ class registry(object): def __read(self, Targetobj, address, size): simObj = SIM_get_interface(Targetobj, "memory_space") value = simObj.read(None, address, size, 0x0) - #print " SIM obj: Read %s bytes [ OK ] " % size + #print(" SIM obj: Read %s bytes [ OK ] " % size) return value #-------------------------------- @@ -253,14 +254,14 @@ class registry(object): #-------------------------------------------- for l_params in test_bucket: #-------------------------------------------- -# print " Desc : %s " % l_params[5] -# print " Op : %s " % l_params[0] +# print(" Desc : %s " % l_params[5]) +# print(" Op : %s " % l_params[0]) if "func" == l_params[0]: - print " Func : %s " % l_params[1] + print(" Func : %s " % l_params[1]) if l_params[4] != "None": - print " Expect : %s " % l_params[4] + print(" Expect : %s " % l_params[4]) if "func" == l_params[0]: - print " Function Params :",l_params[2] + print(" Function Params :",l_params[2]) else: # addr, value, size self.setRegData(l_params[1],l_params[2],l_params[3]) @@ -279,16 +280,16 @@ class registry(object): ''' if l_params[4] != "None": if self.validateTestOp(sim_data,l_params[4]) == True: - print " Test validated .. [ OK ]" + print(" Test validated .. [ OK ]") else: - print " ++++++++++++++++++++++++++++++++++++++++++" - print " simics Data : ", sim_data - print " simics Hex : ", self.joinListDataToHex(sim_data).upper() + print(" ++++++++++++++++++++++++++++++++++++++++++") + print(" simics Data : ", sim_data) + print(" simics Hex : ", self.joinListDataToHex(sim_data).upper()) if(raiseException == True): raise Exception('Data mistmach'); return FAILURE # Failed validation # else: -# print " ++++++++++++++++++++++++++++++++++++++++++" +# print(" ++++++++++++++++++++++++++++++++++++++++++") elif "write" == l_params[0]: self.writeToReg(testOp) elif "memRead" == l_params[0]: @@ -299,27 +300,27 @@ class registry(object): rc = self.loadFunc( l_params[1], l_params[2] ) return rc else: - print "\n Invalid Test Data" + print("\n Invalid Test Data") if(raiseException == True): raise Exception('Invalid Test Data'); return FAILURE # Unknown entry op - print "\n" + print("\n") return SUCCESS #---------------------------------------------------- # Validate simulator data against test data #---------------------------------------------------- def validateTestOp(self, sim_data, test_data): - print " Test Expects : 0x%s " % test_data - print " Expect bytes : ", self.stringToByte(test_data) + print(" Test Expects : 0x%s " % test_data) + print(" Expect bytes : ", self.stringToByte(test_data)) if self.compareList(self.stringToByte(test_data), sim_data, "None") == True: - print " Test ... [ OK ] " - print " ++++++++++++++++++++++++++++++++++++++++++" + print(" Test ... [ OK ] ") + print(" ++++++++++++++++++++++++++++++++++++++++++") return SUCCESS else: - print " Test Failed... !!!" - print " ++++++++++++++++++++++++++++++++++++++++++" + print(" Test Failed... !!!") + print(" ++++++++++++++++++++++++++++++++++++++++++") return FAILURE #---------------------------------------------------- @@ -338,11 +339,11 @@ class registry(object): def compareList(self, expList, resList, opType): for i in range(0,8): if int(expList[i]) == int(resList[i]): - #print " %s : %s " % (expList[i],resList[i]) + #print(" %s : %s " % (expList[i],resList[i])) continue else: if opType != "memRead": - print " Error \t %s : %s [ Mismatch ]" % (expList[i],resList[i]) + print(" Error \t %s : %s [ Mismatch ]" % (expList[i],resList[i])) return False # mismatch return # Return nothing for Next Mem byte read return True @@ -359,7 +360,7 @@ class registry(object): if rc == SUCCESS: break elif retries <= 0: - print " Retrials exhausted... Exiting polling" + print(" Retrials exhausted... Exiting polling") raise Exception('Polling Failed for - ' + l_param[5]); break else: diff --git a/src/test/testcases/testPsuHostPassThrough.py b/src/test/testcases/testPsuHostPassThrough.py index 6fa3126f..789a216b 100644 --- a/src/test/testcases/testPsuHostPassThrough.py +++ b/src/test/testcases/testPsuHostPassThrough.py @@ -22,7 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG - +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) @@ -98,7 +98,7 @@ def main(): # Intialize the class obj instances regObj = testPSUUtil.registry() # Registry obj def for operation - print "\n Execute SBE Test - Set Pass through Address\n" + print("\n Execute SBE Test - Set Pass through Address\n") ''' Test Case 1 @@ -106,7 +106,7 @@ def main(): # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) @@ -126,8 +126,8 @@ def main(): if(data == readData): print ("Success - Write-Read PBA - With Pass through Mode") else: - print data - print readData + print(data) + print(readData) raise Exception('data mistmach') # Send an invalid size, it should fail testMemUtil.getmem_failure(0x00000000, 128*4, 0x102, 0x0002000a) diff --git a/src/test/testcases/testPutGetRegFpr.py b/src/test/testcases/testPutGetRegFpr.py index cf1a4c84..01961b34 100755 --- a/src/test/testcases/testPutGetRegFpr.py +++ b/src/test/testcases/testPutGetRegFpr.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testPutGetRegGpr.py b/src/test/testcases/testPutGetRegGpr.py index 7fa24669..aacc0576 100755 --- a/src/test/testcases/testPutGetRegGpr.py +++ b/src/test/testcases/testPutGetRegGpr.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testPutGetRegSpr.py b/src/test/testcases/testPutGetRegSpr.py index 2b4f793c..c13770ef 100755 --- a/src/test/testcases/testPutGetRegSpr.py +++ b/src/test/testcases/testPutGetRegSpr.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testPutMem_fail.py b/src/test/testcases/testPutMem_fail.py index 762b64ac..9a538d9c 100644 --- a/src/test/testcases/testPutMem_fail.py +++ b/src/test/testcases/testPutMem_fail.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testQuiesce.py b/src/test/testcases/testQuiesce.py index 5353d40e..f396170e 100755 --- a/src/test/testcases/testQuiesce.py +++ b/src/test/testcases/testQuiesce.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testRunTillSbeBooted.py b/src/test/testcases/testRunTillSbeBooted.py index 16b7a475..b56c0c74 100644 --- a/src/test/testcases/testRunTillSbeBooted.py +++ b/src/test/testcases/testRunTillSbeBooted.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import os import sys sys.path.append("targets/p9_nimbus/sbeTest" ) @@ -41,11 +42,11 @@ else: while True: try: if testUtil.read(lbus, 0x2824, 4)[0] & 0x80 : - print "SBE is booted, continue" + print("SBE is booted, continue") break else: - print "SBE is still not booted" + print("SBE is still not booted") except: - print "." + print(".") testUtil.runCycles( 10000000 ) diff --git a/src/test/testcases/testSbeDump.py b/src/test/testcases/testSbeDump.py index 8e92f07d..8501ca24 100644 --- a/src/test/testcases/testSbeDump.py +++ b/src/test/testcases/testSbeDump.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest") sys.path.append("targets/p9_axone/sbeTest" ) @@ -93,7 +94,7 @@ def main(): #read user data id data = testUtil.readDsEntryReturnVal() id = (data[0] << 8) | data[1] - print "User data Id ["+str(hex(id))+"]" + print("User data Id ["+str(hex(id))+"]") len = (data[2] << 8) | data[3] #if it is trace field SBE_FFDC_TRACE_DUMP fileName = "" diff --git a/src/test/testcases/testSecurity.py b/src/test/testcases/testSecurity.py index d4e3efaf..6b019666 100644 --- a/src/test/testcases/testSecurity.py +++ b/src/test/testcases/testSecurity.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import os import sys import struct @@ -92,23 +93,23 @@ def main(): whitelist_table1, whitelist_table2, whitelist_table3) - print "generated whitelist validation passed" + print("generated whitelist validation passed") test_normal('blacklist', blacklist, blacklist_table1, blacklist_table2, blacklist_table3) - print "generated blacklist validation passed" + print("generated blacklist validation passed") # getscom success testScomUtil.getscom(0x0204001A) - print "getscom success testcase - passed" + print("getscom success testcase - passed") # getscom failure testScomUtil.getscom(eval(BLACKLISTED_REG_FOR_READ_TEST), [0x00, 0x05, 0x00, 0x23]) - print "getscom failure testcase - passed" + print("getscom failure testcase - passed") # putscom success testScomUtil.putscom(eval(WHITELISTED_REG_FOR_WRITE_TEST), testScomUtil.getscom(eval(WHITELISTED_REG_FOR_WRITE_TEST))) - print "putscom success testcase - passed" + print("putscom success testcase - passed") # putscom failure while(True): random_addr = struct.unpack('>L', os.urandom(4))[0] @@ -116,21 +117,21 @@ def main(): if not ((random_addr & 0x80000000) or (random_addr & 0x00F00000)): testScomUtil.putscom(random_addr, 0, [0x00, 0x05, 0x00, 0x23]) break - print "putscom failure testcase - passed" + print("putscom failure testcase - passed") # modify scom success dataWritten = testScomUtil.getscom(0x00040006) testScomUtil.modifyScom(0x01, 0x00040006, 0x0) dataRead = testScomUtil.getscom(0x00040006) if(dataRead != dataWritten): raise Exception('modify scom failed %x != %x' % (dataRead, dataWritten)) - print "modify scom success testcase - passed" + print("modify scom success testcase - passed") # putscom under mask success dataWritten = testScomUtil.getscom(0x00040006) testScomUtil.putScomUnderMask(0x00040006, dataWritten, 0xFFFFFFFFFFFFFFFF) dataRead = testScomUtil.getscom(0x00040006) if(dataRead != dataWritten): raise Exception('PutScom under mask failed %x != %x' % (dataRead, dataWritten)) - print "putscom under mask success testcase - passed" + print("putscom under mask success testcase - passed") # Greylist test cases dataWritten = testScomUtil.getscom(0x0901080B) @@ -142,7 +143,7 @@ def main(): testScomUtil.putScomUnderMask(0x0901080B, dataWritten, 0xFF0FFFFFFF0FFFFF) # Do putScomUnderMask with superset mask testScomUtil.putScomUnderMask(0x0901080B, dataWritten, 0xFF00FFFFFF0FFFFF) - print "Greylist testcases - passed" + print("Greylist testcases - passed") # indirect scom test dataWritten = testScomUtil.getscom(0x8000000D06010C3F) @@ -151,7 +152,7 @@ def main(): dataRead = testScomUtil.getscom(0x8000000D06010C3F) if(dataRead != dataWritten): raise Exception('indirect scom test failed %x != %x' % (dataRead, dataWritten)) - print "Indirect scom success testcase - passed" + print("Indirect scom success testcase - passed") except Exception, error: raise Exception(error) @@ -164,11 +165,11 @@ def test_normal(id, list, table1, table2, table3): table1, table2, table3)): - print id, list - print 'table1:', table1 - print 'table2:', table2 - print 'table3:', table3 - print "Failed Addr", hex(addr) + print(id, list) + print('table1:', table1) + print('table2:', table2) + print('table3:', table3) + print("Failed Addr", hex(addr)) raise Exception(id+' positive testcase') # negative testcase - number of random addresses checked is configurable i = 0 @@ -179,11 +180,11 @@ def test_normal(id, list, table1, table2, table3): i = i-1 else: if(True == is_present(random_addr, table1, table2, table3)): - print id, list - print 'table1:', table1 - print 'table2:', table2 - print 'table3:', table3 - print "Failed Addr", hex(random_addr) + print(id, list) + print('table1:', table1) + print('table2:', table2) + print('table3:', table3) + print("Failed Addr", hex(random_addr)) raise Exception(id+' negative testcase') def test_brute_force(id, list, table1, table2, table3): @@ -196,18 +197,18 @@ def test_brute_force(id, list, table1, table2, table3): sys.stdout.write("Progress: addr[0x%08x] last_addr[0x%08x]" % (addr, last_addr) ) sys.stdout.flush() if(True == is_present(addr, table1, table2, table3)): - print id, list - print 'table1:', table1 - print 'table2:', table2 - print 'table3:', table3 - print "Failed Addr", hex(addr) + print(id, list) + print('table1:', table1) + print('table2:', table2) + print('table3:', table3) + print("Failed Addr", hex(addr)) raise Exception(id+' brute force testcase') addr = addr + 1 def is_present(addr, table1, table2, table3): t1_addr = (addr & 0xFF000000) >> 24; if(DEBUG): - print "find", t1_addr, "in table1" + print("find", t1_addr, "in table1") for id1, (chiplet_range, count) in enumerate(table1): start = (chiplet_range & 0xFF00) >> 8 end = chiplet_range & 0x00FF @@ -219,7 +220,7 @@ def is_present(addr, table1, table2, table3): last_t2 = count-1 t2_addr = (addr & 0x00FF0000) >> 16; if(DEBUG): - print "find", t2_addr, "in table2", first_t2, last_t2 + print("find", t2_addr, "in table2", first_t2, last_t2) (found, id2) = binary_search(t2_addr, table2, first_t2, last_t2, True) if(found): if(id2-1 < 0): @@ -229,11 +230,11 @@ def is_present(addr, table1, table2, table3): last_t3 = table2[id2][1]-1 t3_addr = (addr & 0x0000FFFF) if(DEBUG): - print "find",t3_addr,"in table3", first_t3, last_t3 + print("find",t3_addr,"in table3", first_t3, last_t3) (found, id3) = binary_search(t3_addr, table3, first_t3, last_t3) if(found): if(DEBUG): - print "found" + print("found") return True return False diff --git a/src/test/testcases/testSecurityListDump.py b/src/test/testcases/testSecurityListDump.py index 78d3eda3..f8f1474f 100644 --- a/src/test/testcases/testSecurityListDump.py +++ b/src/test/testcases/testSecurityListDump.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import testPSUUtil import testRegistry as reg import testUtil @@ -76,7 +77,7 @@ def main(): regObj = testPSUUtil.registry() # Registry obj def for operation testUtil.runCycles( 1000000 ); - print "\n Execute SBE Test [ System Fabric Map ] ...\n" + print("\n Execute SBE Test [ System Fabric Map ] ...\n") ''' Test Case 1 @@ -84,7 +85,7 @@ def main(): # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) diff --git a/src/test/testcases/testSram.py b/src/test/testcases/testSram.py index 0ec9c018..fc3c08bd 100644 --- a/src/test/testcases/testSram.py +++ b/src/test/testcases/testSram.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys import os sys.path.append("targets/p9_nimbus/sbeTest" ) @@ -80,8 +81,8 @@ def getsram(addr, mode, length, primStatus, secStatus): data += list(testUtil.readDsEntryReturnVal()) readLen = testUtil.readDsEntryReturnVal() if(getsingleword(length) != list(readLen)): - print getsingleword(length) - print list(readLen) + print(getsingleword(length)) + print(list(readLen)) raise Exception("Invalid Length") expResp = (getsingleword(0xc0dea403) @@ -111,8 +112,8 @@ def main( ): if(data == readData): print("Success: put - get sram") else: - print data - print readData + print(data) + print(readData) raise Exception('data mistmach') # secure mem - write to disallowed mem @@ -155,7 +156,7 @@ def main( ): #testUtil.readDsFifo( GETSRAM_OCC_EXPDATA_1 ) #testUtil.readEot( ) except: - print "FAILED Test Case:"+str(testcase) + print("FAILED Test Case:"+str(testcase)) raise Exception('Failure') #------------------------------------------------- diff --git a/src/test/testcases/testStartInstruction.py b/src/test/testcases/testStartInstruction.py index e2c5e1c2..e65c3744 100644 --- a/src/test/testcases/testStartInstruction.py +++ b/src/test/testcases/testStartInstruction.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testStopClocks.py b/src/test/testcases/testStopClocks.py index 5df9cb91..5b452665 100644 --- a/src/test/testcases/testStopClocks.py +++ b/src/test/testcases/testStopClocks.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testStopInstruction.py b/src/test/testcases/testStopInstruction.py index 37c77900..ca31457e 100644 --- a/src/test/testcases/testStopInstruction.py +++ b/src/test/testcases/testStopInstruction.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testSuspendIO.py b/src/test/testcases/testSuspendIO.py index 09d1250b..48257f69 100755 --- a/src/test/testcases/testSuspendIO.py +++ b/src/test/testcases/testSuspendIO.py @@ -22,7 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG - +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) sys.path.append("targets/p9_axone/sbeTest" ) diff --git a/src/test/testcases/testSystemFabricMap.py b/src/test/testcases/testSystemFabricMap.py index d97105fe..c5adabc5 100644 --- a/src/test/testcases/testSystemFabricMap.py +++ b/src/test/testcases/testSystemFabricMap.py @@ -22,7 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG - +from __future__ import print_function import testPSUUtil import testRegistry as reg import testUtil @@ -77,7 +77,7 @@ def main(): regObj = testPSUUtil.registry() # Registry obj def for operation testUtil.runCycles( 1000000 ); - print "\n Execute SBE Test [ System Fabric Map ] ...\n" + print("\n Execute SBE Test [ System Fabric Map ] ...\n") ''' Test Case 1 @@ -85,7 +85,7 @@ def main(): # HOST->SBE data set execution regObj.ExecuteTestOp( testPSUUtil.simSbeObj, sbe_test_data ) - print "\n Poll on Host side for INTR ...\n" + print("\n Poll on Host side for INTR ...\n") #Poll on HOST DoorBell Register for interrupt regObj.pollingOn( testPSUUtil.simSbeObj, host_polling_data, 5 ) diff --git a/src/test/testcases/testTraceArray.py b/src/test/testcases/testTraceArray.py index 030719e4..57cecbcf 100644 --- a/src/test/testcases/testTraceArray.py +++ b/src/test/testcases/testTraceArray.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys sys.path.append("targets/p9_nimbus/sbeTest" ) import testUtil diff --git a/src/test/testcases/testUnsecureMemRegions.py b/src/test/testcases/testUnsecureMemRegions.py index a0b0d21f..fa56f9f4 100644 --- a/src/test/testcases/testUnsecureMemRegions.py +++ b/src/test/testcases/testUnsecureMemRegions.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import sys import os import struct diff --git a/src/test/testcases/testUtil.py b/src/test/testcases/testUtil.py index 95626fa1..d070081e 100644 --- a/src/test/testcases/testUtil.py +++ b/src/test/testcases/testUtil.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import time import conf from sim_commands import * @@ -252,14 +253,14 @@ def runCycles( cycles ): syscmd = "run-cycles %d"%(cycles) ( rc, out ) = quiet_run_command( syscmd, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( syscmd, rc ) + print("simics ERROR running %s: %d "%( syscmd, rc )) def checkEqual( data, expdata ): """ Throw exception if data is not equal """ if( cmp(data, expdata )): - print "Eqality check failed" - print "Data:", data - print "Expected Data", expdata + print("Eqality check failed") + print("Data:", data) + print("Expected Data", expdata) raise Exception('data mistmach'); def getMachineName(): @@ -277,4 +278,4 @@ def collectFFDC(): simics.SIM_run_command('sbe-regffdc 0') simics.SIM_run_command('backplane0.proc0.pib_cmp.sbe_ppe->ppe_state') simics.SIM_run_command('backplane0.proc0.cfam_cmp.sbe_fifo->upstream_hw_fifo') - simics.SIM_run_command('backplane0.proc0.cfam_cmp.sbe_fifo->downstream_hw_fifo') \ No newline at end of file + simics.SIM_run_command('backplane0.proc0.cfam_cmp.sbe_fifo->downstream_hw_fifo') diff --git a/src/tools/debug/sbe-debug.py b/src/tools/debug/sbe-debug.py index 5d53b408..fad7fd4e 100755 --- a/src/tools/debug/sbe-debug.py +++ b/src/tools/debug/sbe-debug.py @@ -6,7 +6,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2016,2019 +# Contributors Listed Below - COPYRIGHT 2016,2020 # [+] International Business Machines Corp. # # @@ -23,6 +23,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import os import subprocess import re @@ -63,7 +64,7 @@ def getFilePath(filename): retPath = os.path.join(dir, filename) if(os.path.exists(retPath)): return os.path.abspath(retPath) - print "ERROR: file " + filename +" not found" + print("ERROR: file " + filename +" not found") return 1 def getTraceFilePath(): @@ -84,7 +85,7 @@ def fillSymTable(): if( len( words ) == 4 ): syms[words[3]] = [words[0], words[1]] except: - print "Symbol file not found, limited commands avaliable" + print("Symbol file not found, limited commands avaliable") def getSymbolInfo( symbol ): symAddr = '' @@ -99,8 +100,8 @@ def getSymbolInfo( symbol ): else: baseAddr = 0xfffe8000 - print "\n symAddress :", symAddr - print "\n baseAddress :", baseAddr + print("\n symAddress :", symAddr) + print("\n baseAddress :", baseAddr) offset = int(symAddr, base = 16) - baseAddr; return (hex(offset), length) @@ -133,13 +134,13 @@ def getSymbolVal(symbol, hexdump=False): if hexdump: invokeOsCmd( "hexdump -C "+ output_path +"DumpPIBMEM" ) else: - print "symbol not found" + print("symbol not found") def invokeOsCmd(cmd): - print "Running command [" + cmd + "]" + print("Running command [" + cmd + "]") rc = os.system( cmd ) if ( rc ): - print "ERROR running command: %d " % ( rc ) + print("ERROR running command: %d " % ( rc )) return 1 ''' @@ -179,13 +180,13 @@ def forcedCollectTrace(): trace_pattern = [0, 2, 0, 0] + [ord(a) for a in image_str] + [0] data_read = [0] * len(trace_pattern) trace_index = 0 - #print trace_pattern + #print(trace_pattern) with open(output_path+"DumpPIBMEM", "r") as f: byte = 'x' while byte != "": byte = f.read(1) data_read = data_read[1:]+[ord(byte)] - #print [chr(a) for a in data_read] + #print([chr(a) for a in data_read]) if data_read == trace_pattern: trace_index -= len(trace_pattern)-1 break @@ -226,8 +227,8 @@ def collectStackUsage(): # Dump stack memory to binary file invokeOsCmd( "cat "+ output_path +"DumpPIBMEM >"+ output_path + thread ) - print "==================================Stack usage===================================" - print "Thread".ljust(40)+"Least Available[bytes]".ljust(30)+"Max usage[%]" + print("==================================Stack usage===================================") + print("Thread".ljust(40)+"Least Available[bytes]".ljust(30)+"Max usage[%]") for thread in threads: with open(output_path+thread, "rb") as f: word = struct.unpack('I', f.read(4))[0] @@ -241,7 +242,7 @@ def collectStackUsage(): break else: break - print str("["+thread+"]").ljust(40) + str(leastAvailable).ljust(30) + str("%.2f" % (100 * (1 - (leastAvailable/float(int("0x"+syms[thread][1], 16)))))) + print(str("["+thread+"]").ljust(40) + str(leastAvailable).ljust(30) + str("%.2f" % (100 * (1 - (leastAvailable/float(int("0x"+syms[thread][1], 16))))))) def getSbeCommit(): getSymbolVal( 'SBEGlobalsSingleton.*fwCommitId' ) @@ -249,7 +250,7 @@ def getSbeCommit(): with open(output_path+"DumpPIBMEM", "rb") as f: # Big Endian word word = struct.unpack('>I', f.read(4))[0] - print "SBE commit:", hex(word) + print("SBE commit:", hex(word)) def ppeStateFfdc(): # Keep this structure in sync with src/sbefw/core/sbeirqregistersave.H @@ -274,25 +275,25 @@ def ppeStateFfdc(): data = f.read() ctypes.memmove(ctypes.addressof(ppestateffdc), data, ctypes.sizeof(ppestateffdc)) - print ''' + print(''' --------------------------------------------------------------------------------- Please verify sbe_DD2.syms is valid for this dump, before depending on the values ----------------------------------------------------------------------------------''' +---------------------------------------------------------------------------------''') if ppestateffdc.validbyte == 0x1 and ppestateffdc.magicbyte == 0xA5: - print "ppestateffdc.version 0x%04X" % ppestateffdc.version - print "ppestateffdc.magicbyte 0x%02X" % ppestateffdc.magicbyte - print "ppestateffdc.validbyte 0x%02X" % ppestateffdc.validbyte - print "ppestateffdc.register_SRR0 0x%08X" % ppestateffdc.register_SRR0 - print "ppestateffdc.register_SRR1 0x%08X" % ppestateffdc.register_SRR0 - print "ppestateffdc.register_ISR 0x%08X" % ppestateffdc.register_ISR - print "ppestateffdc.register_FI2C_CONFIG_LOWER_32BITS 0x%08X" % ppestateffdc.register_FI2C_CONFIG_LOWER_32BITS - print "ppestateffdc.register_FI2C_CONFIG_UPPER_32BITS 0x%08X" % ppestateffdc.register_FI2C_CONFIG_UPPER_32BITS - print "ppestateffdc.register_FI2C_STAT_LOWER_32BITS 0x%08X" % ppestateffdc.register_FI2C_STAT_LOWER_32BITS - print "ppestateffdc.register_FI2C_STAT_UPPER_32BITS 0x%08X" % ppestateffdc.register_FI2C_STAT_UPPER_32BITS - print "ppestateffdc.register_LR 0x%08X" % ppestateffdc.register_LR + print("ppestateffdc.version 0x%04X" % ppestateffdc.version) + print("ppestateffdc.magicbyte 0x%02X" % ppestateffdc.magicbyte) + print("ppestateffdc.validbyte 0x%02X" % ppestateffdc.validbyte) + print("ppestateffdc.register_SRR0 0x%08X" % ppestateffdc.register_SRR0) + print("ppestateffdc.register_SRR1 0x%08X" % ppestateffdc.register_SRR0) + print("ppestateffdc.register_ISR 0x%08X" % ppestateffdc.register_ISR) + print("ppestateffdc.register_FI2C_CONFIG_LOWER_32BITS 0x%08X" % ppestateffdc.register_FI2C_CONFIG_LOWER_32BITS) + print("ppestateffdc.register_FI2C_CONFIG_UPPER_32BITS 0x%08X" % ppestateffdc.register_FI2C_CONFIG_UPPER_32BITS) + print("ppestateffdc.register_FI2C_STAT_LOWER_32BITS 0x%08X" % ppestateffdc.register_FI2C_STAT_LOWER_32BITS) + print("ppestateffdc.register_FI2C_STAT_UPPER_32BITS 0x%08X" % ppestateffdc.register_FI2C_STAT_UPPER_32BITS) + print("ppestateffdc.register_LR 0x%08X" % ppestateffdc.register_LR) else: - print "Register ffdc is not valid, probably SBE has not hit any internal halt condition" - print '''---------------------------------------------------------------------------------''' + print("Register ffdc is not valid, probably SBE has not hit any internal halt condition") + print('''---------------------------------------------------------------------------------''') def ppeState(): if(target == 'FILE'): @@ -361,12 +362,12 @@ def ppeState(): 30 : ["R30", False], 31 : ["R31", False] } - print "File path: ", file_path + print("File path: ", file_path) fileHandle = open(file_path) l_cnt = 0 - print '********************************************************************' - print 'Reg'.ljust(15),'Reg Value'.ljust(20) - print '--------------------------------------------------------------------' + print('********************************************************************') + print('Reg'.ljust(15),'Reg Value'.ljust(20)) + print('--------------------------------------------------------------------') while(l_cnt < os.path.getsize(file_path)): regNum = int(binascii.hexlify(fileHandle.read(2)), 16) str1 = '' @@ -381,10 +382,10 @@ def ppeState(): except: str1 = hex(regNum) str3 = binascii.hexlify(fileHandle.read(4)) - print str(str1).ljust(15),str(str3).ljust(20) + print(str(str1).ljust(15),str(str3).ljust(20)) l_cnt = l_cnt + 6; - print '********************************************************************' + print('********************************************************************') fileHandle.close() else: invokeOsCmd(getFilePath("p9_ppe_state_wrap.exe")+" -verbose -sbe -snapshot"+ @@ -392,19 +393,19 @@ def ppeState(): def sbeLocalRegister(): if(target == 'FILE'): - print "File path: ", file_path + print("File path: ", file_path) fileHandle = open(file_path) l_cnt = 0 - print '********************************************************************' - print 'Reg Number Reg Value Reg String' + print('********************************************************************') + print('Reg Number Reg Value Reg String') while(l_cnt < os.path.getsize(file_path)): str1 = binascii.hexlify(fileHandle.read(2)) str2 = fileHandle.read(32) str3 = binascii.hexlify(fileHandle.read(8)) - print str(str1).ljust(11),str(str3).ljust(20),str2.ljust(40) + print(str(str1).ljust(11),str(str3).ljust(20),str2.ljust(40)) l_cnt = l_cnt + 42; - print '********************************************************************' + print('********************************************************************') fileHandle.close() else: invokeOsCmd(getFilePath("p9_sbe_localreg_dump_wrap.exe")+" -verbose -halt"+ @@ -412,19 +413,19 @@ def sbeLocalRegister(): def sbeState(): if(target == 'FILE'): - print "File path: ", file_path + print("File path: ", file_path) fileHandle = open(file_path) l_cnt = 0 - print '********************************************************************' - print 'Reg Number Reg Value Reg String' + print('********************************************************************') + print('Reg Number Reg Value Reg String') while(l_cnt < os.path.getsize(file_path)): str1 = binascii.hexlify(fileHandle.read(4)) str2 = fileHandle.read(32) str3 = binascii.hexlify(fileHandle.read(8)) - print str(str1).ljust(11),str(str3).ljust(20),str2.ljust(40) + print(str(str1).ljust(11),str(str3).ljust(20),str2.ljust(40)) l_cnt = l_cnt + 44; - print '********************************************************************' + print('********************************************************************') fileHandle.close() else: invokeOsCmd(getFilePath("p9_pibms_reg_dump_wrap.exe")+" -verbose" +\ @@ -432,17 +433,17 @@ def sbeState(): def sbeStatus(): if(target == 'FILE'): - print "Error - not supported for FILE Target" + print("Error - not supported for FILE Target") else: cmd = ("getcfam pu 2809" +\ " -n" + str(node) + " -p" + str(proc)) - print "cmd:", cmd + print("cmd:", cmd) output = os.popen(cmd).read() output = output.split() expected_out = 'k0:n%1d:s0:p%02d'%(node,proc) if (expected_out not in output): - print "Error while getting the status register" - print ' '.join(output) + print("Error while getting the status register") + print(' '.join(output)) else: parsevalue(bin(int(output[output.index(expected_out)+1], 16))) @@ -456,30 +457,30 @@ def parsevalue(iValue): tempVal = iValue[2:3] tempVal = 'True' if tempVal == '1' else 'False' - print "SBE Booted : %s" %(tempVal) + print("SBE Booted : %s" %(tempVal)) tempVal = iValue[3:4] tempVal = 'True' if tempVal == '1' else 'False' - print "Async FFDC : %s" %(tempVal) + print("Async FFDC : %s" %(tempVal)) tempVal = iValue[4:6] - print "Reserver Bit [2:3] : %s" %(tempVal) + print("Reserver Bit [2:3] : %s" %(tempVal)) tempVal = iValue[6:10] - print "SBE Previous State : %s (%s)" %(sbeStates[tempVal], tempVal) + print("SBE Previous State : %s (%s)" %(sbeStates[tempVal], tempVal)) tempVal = iValue[10:14] - print "SBE Current State : %s (%s)" %(sbeStates[tempVal], tempVal) + print("SBE Current State : %s (%s)" %(sbeStates[tempVal], tempVal)) tempVal = iValue[14:22] - print "Istep Major : %s" %(int(tempVal, 2)) + print("Istep Major : %s" %(int(tempVal, 2))) tempVal = iValue[22:28] - print "Istep Minor : %s" %(int(tempVal, 2)) + print("Istep Minor : %s" %(int(tempVal, 2))) tempVal = iValue[28:34] - print "Reserved Bit [26:31] : %s" %(tempVal) + print("Reserved Bit [26:31] : %s" %(tempVal)) ''' @@ -516,7 +517,7 @@ def main( argv ): try: opts, args = getopt.getopt(sys.argv[1:], "l:t:n:p:d:s:f:o:h", ['level=', 'target=', 'node=', 'proc=', 'ddlevel=', 'symbol=', 'file_path=', 'output_path=','help']) except getopt.GetoptError as err: - print str(err) + print(str(err)) usage() exit(1) @@ -534,45 +535,45 @@ def main( argv ): if arg in LEVELS_ARRAY: level = arg else: - print "level should be one of " + str(LEVELS_ARRAY) + print("level should be one of " + str(LEVELS_ARRAY)) exit(1) elif opt in ('-t', '--target'): if arg in ('AWAN', 'HW', 'FILE'): target = arg else: - print "target should be one of {AWAN,HW,FILE}" + print("target should be one of {AWAN,HW,FILE}") exit(1) elif opt in ('-n', '--node'): try: node = int(arg) except: - print "node should be an integer number" + print("node should be an integer number") exit(1) elif opt in ('-p', '--proc'): try: proc = int(arg) except: - print "proc should be an integer number" + print("proc should be an integer number") exit(1) elif opt in ('-d', '--ddlevel'): if arg in ('DD1', 'DD2', 'AXONE'): ddsuffix = arg else: - print "target should be one of {DD1, DD2, AXONE}" + print("target should be one of {DD1, DD2, AXONE}") exit(1) elif opt in ('-f', '--file_path'): try: file_path = arg assert os.path.exists(arg), "Did not find the file at,"+str(arg) except: - print "file_path should a string path" + print("file_path should a string path") exit(1) elif opt in ('-o', '--output_path'): try: output_path = arg+"/" assert os.path.exists(arg) except: - print "output_path should a string path" + print("output_path should a string path") exit(1) elif opt in ('-s', '--symbol'): symbol = arg @@ -583,7 +584,7 @@ def main( argv ): # Example output: 'CNFG FILE GLOBAL_DEBUG: 8.VI.B\n\tk0 \nUSE_SBE_FIFO = off\n/afs/awd.austin.ibm.com/projects/eng/tools/cronus/p9/exe/dev/p9sim_dev_x86_64.exe getconfig USE_SBE_FIFO \n' regEx = re.search('USE_SBE_FIFO.*=(.*)', cmdFifoLastState) if (regEx == None): - print "ERROR in getting USE_SBE_FIFO config" + print("ERROR in getting USE_SBE_FIFO config") return 1 cmdFifoLastState = regEx.group(1).split()[0] # On cronus, disabe FIFO mode @@ -596,7 +597,7 @@ def main( argv ): fillSymTable() if ( level == 'all' ): - print "Parsing everything" + print("Parsing everything") collectTrace() collectAttr() sbeStatus() diff --git a/src/tools/debug/simics-debug-framework.py b/src/tools/debug/simics-debug-framework.py index 359df50d..969cb32f 100755 --- a/src/tools/debug/simics-debug-framework.py +++ b/src/tools/debug/simics-debug-framework.py @@ -5,7 +5,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2016,2019 +# Contributors Listed Below - COPYRIGHT 2016,2020 # [+] International Business Machines Corp. # # @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import os import os.path import subprocess @@ -44,7 +45,7 @@ if getMachineName() == "axone": SBE_TOOLS_PATH = simenv.sbe_scripts_path else: SBE_TOOLS_PATH = os.environ['SBE_TOOLS_PATH'] -print "SBE_TOOLS_PATH = " + SBE_TOOLS_PATH +print("SBE_TOOLS_PATH = " + SBE_TOOLS_PATH) testIstepAuto = imp.load_source("testIstepAuto", SBE_TOOLS_PATH + "/testIstepAuto.py") sbeDebug = imp.load_source("sbeDebug", SBE_TOOLS_PATH + "/sbe-debug.py") @@ -65,7 +66,7 @@ def check_sbe_tools_path (): cmd1 = "pipe \"echo $cec_type\" \"cat > temp1.map\"" ( rc, out ) = quiet_run_command( cmd1, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd1, rc ) + print ("simics ERROR running %s: %d "%( cmd1, rc )) with open('temp1.map', 'r') as f: map = f.read().strip() if(map == "p9_fleetwood"): @@ -85,10 +86,10 @@ def get_dd_level(procNr = 0, nodeNr = 0): else: cmd = "pipe \"p9Proc"+str(procNr)+".sbe.mibo_space.map\" \"cat > temp.map\"" - print "simics running %s: "%( cmd) + print ("simics running %s: "%( cmd)) ( rc, out ) = quiet_run_command( cmd, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd, rc ) + print ("simics ERROR running %s: %d "%( cmd, rc )) ddlevel = 'DD1' with open('temp.map', 'r') as f: map = f.read() @@ -103,7 +104,7 @@ def get_dd_level(procNr = 0, nodeNr = 0): ddlevel = "DD1" if map[map.index('p9Proc'+str(procNr)+'.sbe.fi2c_bo:fi2cfsm')-1] == '0xff800000': ddlevel = "DD2" - print "running image - ["+ddlevel+"]" + print ("running image - ["+ddlevel+"]") return ddlevel def register_sbe_debug_framework_tools(): @@ -147,12 +148,12 @@ def register_sbe_debug_framework_tools(): short = "Runs the debug framework for register ffdc ", doc = "") - print "SBE Debug Framework: Registered tool:", "sbe-istep" - print "SBE Debug Framework: Registered tool:", "sbe-trace" - print "SBE Debug Framework: Registered tool:", "sbe-stack" - print "SBE Debug Framework: Registered tool:", "sbe-ddlevel" - print "SBE Debug Framework: Registered tool:", "sbe-attrdump" - print "SBE Debug Framework: Registered tool:", "sbe-regffdc" + print("SBE Debug Framework: Registered tool:", "sbe-istep") + print("SBE Debug Framework: Registered tool:", "sbe-trace") + print("SBE Debug Framework: Registered tool:", "sbe-stack") + print("SBE Debug Framework: Registered tool:", "sbe-ddlevel") + print("SBE Debug Framework: Registered tool:", "sbe-attrdump") + print("SBE Debug Framework: Registered tool:", "sbe-regffdc") def fillSymTable(): @@ -175,7 +176,7 @@ def collectStackUsage ( procNr, nodeNr=0 ): 'sbeCommandReceiver_stack', 'sbe_Kernel_NCInt_stack', 'sbeAsyncCommandProcessor_stack') - print "==================================Stack usage===================================" + print("==================================Stack usage===================================") # Dump stack memory to binary files for thread in threads: if g_isFleetwood: @@ -186,12 +187,12 @@ def collectStackUsage ( procNr, nodeNr=0 ): cmd = "pipe \"backplane0.proc" + `procNr` + ".pib_cmp.sbe_mibo.x 0x" + syms[thread][0] + " 0x"+syms[thread][1]+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> "+thread+"\"" else: cmd = "pipe \"p9Proc" + `procNr` + ".sbe.mibo_space.x 0x" + syms[thread][0] + " 0x"+syms[thread][1]+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> "+thread+"\"" - print "simics running %s: "%( cmd) + print ("simics running %s: "%( cmd)) ( rc, out ) = quiet_run_command( cmd, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd, rc ) + print("simics ERROR running %s: %d "%( cmd, rc )) - print "Thread".ljust(40)+"Least Available[bytes]".ljust(30)+"Max usage[%]" + print("Thread".ljust(40)+"Least Available[bytes]".ljust(30)+"Max usage[%]") for thread in threads: with open(thread, "rb") as f: word = struct.unpack('I', f.read(4))[0] @@ -202,7 +203,7 @@ def collectStackUsage ( procNr, nodeNr=0 ): word = struct.unpack('I', f.read(4))[0] else: break - print str("["+thread+"]").ljust(40) + str(leastAvailable).ljust(30) + str("%.2f" % (100 * (1 - (leastAvailable/float(int("0x"+syms[thread][1], 16)))))) + print(str("["+thread+"]").ljust(40) + str(leastAvailable).ljust(30) + str("%.2f" % (100 * (1 - (leastAvailable/float(int("0x"+syms[thread][1], 16))))))) def collectAttr( procNr, nodeNr=0 ): global g_isFleetwood @@ -211,10 +212,10 @@ def collectAttr( procNr, nodeNr=0 ): cmd= "pipe \"D"+str(node)+"Proc"+str(procNr)+".sbe.mibo_space.x " + '0xFFFE8000' + " "+hex(96*1024)+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> DumpFullPIBMEM\"" else: cmd= "pipe \"p9Proc" + `procNr` + ".sbe.mibo_space.x " + '0xFFFE8000' + " "+hex(96*1024)+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> DumpFullPIBMEM\"" - print "simics running %s: "%( cmd) + print("simics running %s: "%( cmd)) ( rc, out ) = quiet_run_command( cmd, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd, rc ) + print("simics ERROR running %s: %d "%( cmd, rc )) ddlevel = get_dd_level(procNr, nodeNr) sbeDebug.ddsuffix = ddlevel sbeDebug.target = 'FILE' @@ -232,10 +233,10 @@ def collectRegFfdc( procNr, nodeNr=0 ): cmd = "pipe \"backplane0.proc" + `procNr` + ".pib_cmp.sbe_mibo.x " + '0xFFFE8000' + " "+hex(96*1024)+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> DumpFullPIBMEM\"" else: cmd= "pipe \"p9Proc" + `procNr` + ".sbe.mibo_space.x " + '0xFFFE8000' + " "+hex(96*1024)+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> DumpFullPIBMEM\"" - print "simics running %s: "%( cmd) + print ("simics running %s: "%( cmd)) ( rc, out ) = quiet_run_command( cmd, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd, rc ) + print("simics ERROR running %s: %d "%( cmd, rc )) ddlevel = get_dd_level(procNr, nodeNr) sbeDebug.ddsuffix = ddlevel sbeDebug.target = 'FILE' @@ -266,10 +267,10 @@ def collectTrace ( procNr, nodeNr=0 ): cmd3 = "shell \"fsp-trace -s " + SBE_TOOLS_PATH + "/sbeStringFile_"+get_dd_level(procNr, nodeNr)+" sbetrace.bin >" + fileName + "\"" cmd4 = "shell \"" + "cat " + fileName + "\"" - print "simics running %s: "%( cmd1) + print("simics running %s: "%( cmd1)) ( rc, out ) = quiet_run_command( cmd1, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd1, rc ) + print("simics ERROR running %s: %d "%( cmd1, rc )) run_command ( cmd2 ) run_command ( cmd3 ) @@ -287,7 +288,7 @@ def sbe_magic_instruction_callback(user_arg, cpu, inst_num): if inst_num == 8000: #MAGIC_SIMICS_CHECK iface = SIM_get_interface(cpu, "int_register") iface.write(iface.get_number("r3"), 1) - print "SBE::isSimicsRunning = true" + print("SBE::isSimicsRunning = true") # Run the registration automatically whenever this script is loaded. register_sbe_debug_framework_tools() diff --git a/src/tools/utils/CommitSbeImageToCMVC.py b/src/tools/utils/CommitSbeImageToCMVC.py index c177e72f..f5394e46 100755 --- a/src/tools/utils/CommitSbeImageToCMVC.py +++ b/src/tools/utils/CommitSbeImageToCMVC.py @@ -41,6 +41,7 @@ #------------------------- # Imports #------------------------- +from __future__ import print_function import getopt import os, sys, glob import shutil @@ -58,37 +59,37 @@ def main(): # Usage tool option #------------------------------------------ def usage(): - print " ---------------------------------------------------------------------------------------------------" - print " :: Command line USAGE options for Uploading FW SBE image to CMVC :: \n" - print " CommitSbeImageToCMVC.py -d -r -p -i " - - print " \n" - print " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" - print " | By default user MUST pass CMVC/Release/Path input. |" - print " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" - print " \n ***** Options Supported *****" - print " \t -d,--defect = Defect CMVC number" - print " \t -f,--feature = Feature CMVC number" - print " \t -r,--release = FW fips release string EX: fips910" - print " \t -p,--path = Absolute path of the SBE repo" - print " \t -i,--input = [ Optional ] List of image or file to upload" - print " \t -b,--bvt = BVT xml file for CI" - print " \t -h,--help = Help" - print " ------------------------------------------------------------------------------------" + print(" ---------------------------------------------------------------------------------------------------") + print(" :: Command line USAGE options for Uploading FW SBE image to CMVC :: \n") + print(" CommitSbeImageToCMVC.py -d -r -p -i ") + + print(" \n") + print(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + print(" | By default user MUST pass CMVC/Release/Path input. |") + print(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + print(" \n ***** Options Supported *****") + print(" \t -d,--defect = Defect CMVC number") + print(" \t -f,--feature = Feature CMVC number") + print(" \t -r,--release = FW fips release string EX: fips910") + print(" \t -p,--path = Absolute path of the SBE repo") + print(" \t -i,--input = [ Optional ] List of image or file to upload") + print(" \t -b,--bvt = BVT xml file for CI") + print(" \t -h,--help = Help") + print(" ------------------------------------------------------------------------------------") #------------------------------------------ # Exit from this Main #------------------------------------------ def exit_main(rc): if rc == errorcode.HELP_EXIT: - print " [ HELP DOCUMENTATION ]\n" + print(" [ HELP DOCUMENTATION ]\n") sys.exit(0) if rc: - print "\n [ ERROR - MAIN ] Exiting with error code = ", rc + print("\n [ ERROR - MAIN ] Exiting with error code = ", rc) sys.exit(rc) else: - print "\n SBE Image Upload to CMVC completed [ OK ] " + print("\n SBE Image Upload to CMVC completed [ OK ] ") sys.exit(0) #------------------------------------------ @@ -128,10 +129,10 @@ def main(): #---------------------------------- # Preping the data for Image Upload #---------------------------------- - print " \n" - print " ******************************************************" - print " ****** Stagging PPE image Files Upload to CMVC ******" - print " ******************************************************" + print(" \n") + print(" ******************************************************") + print(" ****** Stagging PPE image Files Upload to CMVC ******") + print(" ******************************************************") #------------------------------------------------------ # Make sure that it has passed atleast one arg with it @@ -144,45 +145,45 @@ def main(): # Check user inputs and display #------------------------------------------------------------- def input_setting(): - print " ---------------------------------------------------------------------------------" - print " [ Display User Inputs ]" - print " ---------------------------------------------------------------------------------" + print(" ---------------------------------------------------------------------------------") + print(" [ Display User Inputs ]") + print(" ---------------------------------------------------------------------------------") # Look elsewhere for the name instead of assigning to it locally. # This is now gloabal var global g_cmvc_num if ( defect_num != "None" ) or ( feature_num != "None" ): if not defect_num == "None": g_cmvc_num = 'D'+defect_num #D1234 - print " [ CMVC Defect ] \t\t#Number\t = %s"%(g_cmvc_num) + print(" [ CMVC Defect ] \t\t#Number\t = %s"%(g_cmvc_num)) else: g_cmvc_num = 'F'+feature_num # F1234 - print " [ CMVC Feature ] \t\t#Number\t = %s"%(g_cmvc_num) + print(" [ CMVC Feature ] \t\t#Number\t = %s"%(g_cmvc_num)) else: - print " [ CMVC Defect/Feature ] Neeed CMVC number. This can't be empty " + print(" [ CMVC Defect/Feature ] Neeed CMVC number. This can't be empty ") exit_main(errorcode.ERROR_EXIT) if not release_name == "None": - print " [ Fips Release Name ] \t#String\t = %s"%(release_name) + print(" [ Fips Release Name ] \t#String\t = %s"%(release_name)) else: - print " [ Fips release ] Neeed fips release string. This can't be empty " + print(" [ Fips release ] Neeed fips release string. This can't be empty ") exit_main(errorcode.ERROR_EXIT) if not path_name == "None": - print " [ Build Repo Path ] \t\t#String\t = %s"%(path_name) + print(" [ Build Repo Path ] \t\t#String\t = %s"%(path_name)) else: - print " [ User Build Repo Path ] \t\t#String\t = %s"%(path_name) + print(" [ User Build Repo Path ] \t\t#String\t = %s"%(path_name)) # Optional, by default looks up predefined files if not file_name == "None": - print " [ Files for Check-in - User List ]" + print(" [ Files for Check-in - User List ]") for files in file_name.split(","): - print " \t\t\t\t#",files + print(" \t\t\t\t#",files) else: - print " [ Files for Check-in - Default List ]" + print(" [ Files for Check-in - Default List ]") for files in errorcode.CMVC_FILE_LIST.split(","): - print " \t\t\t\t# ",files + print(" \t\t\t\t# ",files) - print " ---------------------------------------------------------------------------------" + print(" ---------------------------------------------------------------------------------") #------------------------------------------------------------- # CMVC ENV check @@ -200,17 +201,17 @@ def main(): l_found_cmvc_conf = False for key in os.environ.keys(): if "CMVC" in key: - print "\t %s : %s" % (key,os.environ[key]) + print("\t %s : %s" % (key,os.environ[key])) l_found_cmvc_conf = True if l_found_cmvc_conf == False: - print "\n [ ERROR SETTING ] : The CMVC specific ENV is not set" - print " Please add the following CMVC details in ~/.bashrc" - print " ------------------------------------------------------" - print " export CMVC_FAMILY=aix@@" - print " export CMVC_BECOME=" - print " export CMVC_AUTH_METHOD=PWD" - print " ------------------------------------------------------" + print("\n [ ERROR SETTING ] : The CMVC specific ENV is not set") + print(" Please add the following CMVC details in ~/.bashrc") + print(" ------------------------------------------------------") + print(" export CMVC_FAMILY=aix@@") + print(" export CMVC_BECOME=") + print(" export CMVC_AUTH_METHOD=PWD") + print(" ------------------------------------------------------") return errorcode.ERROR_SETTING return errorcode.SUCCESS_EXIT @@ -231,67 +232,67 @@ def main(): #------------------------------ input_setting() - print "\n [ Checking PPE ENV Pre-req ] " + print("\n [ Checking PPE ENV Pre-req ] ") # Check if User has passed the path, else get it from ENV if path_name == "None": # Get the PPE path l_ppe_path = utilcode.utilppeSbENV("SBEROOT") if l_ppe_path == "None": - print " PPE Repo ENV Setting Path : [ ERROR CODE: %s ] " % l_ppe_path + print(" PPE Repo ENV Setting Path : [ ERROR CODE: %s ] " % l_ppe_path) exit_main(errorcode.ERROR_SETTING) else: - print " PPE Repo path Setting : [ %s ]"% l_ppe_path + print(" PPE Repo path Setting : [ %s ]"% l_ppe_path) path_name = l_ppe_path - print "\n [ Checking CMVC user ENV Pre-req ] " + print("\n [ Checking CMVC user ENV Pre-req ] ") rc_code = UserCmvcENV() if rc_code == errorcode.SUCCESS_EXIT : - print " CMVC Setting : [ OK ] " + print(" CMVC Setting : [ OK ] ") else: - print " CMVC Setting : [ ERORR CODE: %s ]"% rc_code + print(" CMVC Setting : [ ERORR CODE: %s ]"% rc_code) #------------------------------ # 2) Check the CMVC login access #------------------------------ - print "\n [ Checking CMVC user Login Session access ] " + print("\n [ Checking CMVC user Login Session access ] ") rc_cmvc = CheckCmvcAccess() if rc_cmvc == errorcode.ERROR_CMVC_LOGIN: - print " CMVC Login Access : [ ERORR CODE: %s ]"% rc_cmvc - print "\t No cmvc login was found in this session." - print "\t Issue the cmvclog command to establish a login and re-run." - print "\t Command : cmvclog -in " + print(" CMVC Login Access : [ ERORR CODE: %s ]"% rc_cmvc) + print("\t No cmvc login was found in this session.") + print("\t Issue the cmvclog command to establish a login and re-run.") + print("\t Command : cmvclog -in ") exit_main(rc_cmvc) else: - print " CMVC Session Login : [ OK ] " + print(" CMVC Session Login : [ OK ] ") # Call API/Utility funcs def here #------------------------------ # 3) Check track status #------------------------------ - print "\n [ Checking CMVC track state ] " + print("\n [ Checking CMVC track state ] ") l_trackFix = utilcode.utilCheckTrackState(g_cmvc_num,release_name) if l_trackFix == errorcode.SUCCESS_TRACK_STATE : - print " Track in fix state. Suitable to continue." + print(" Track in fix state. Suitable to continue.") else : - print " Track not in fix state. Aborting activity." + print(" Track not in fix state. Aborting activity.") return errorcode.ERROR_TRACK_STATE #------------------------------ # 4) Checkout the code #------------------------------ - print "\n [ Creating Sandbox ]" + print("\n [ Creating Sandbox ]") origDir = os.getcwd() utilcode.utilCmvcChangeDir(g_cmvc_num) sbDir = os.getcwd() - print "\n [ Checkout Files from CMVC ] " - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print("\n [ Checkout Files from CMVC ] ") + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") if file_name == "None": file_name = errorcode.CMVC_FILE_LIST for l_filename in file_name.split(","): rc_checkout = utilcode.utilCmvcCheckout(l_filename,release_name,g_cmvc_num) if rc_checkout == errorcode.ERROR_CMVC_CHECKOUT: - print " [ CMVC File Checkout Failed ] [Error code : %s]\t:%s"%(rc_checkout,l_filename) + print(" [ CMVC File Checkout Failed ] [Error code : %s]\t:%s"%(rc_checkout,l_filename)) # Undo checkout.. dont check errors just do it utilcode.utilRollBack("checkout",g_cmvc_num,release_name) # Return to initial directory of operation @@ -299,38 +300,38 @@ def main(): shutil.rmtree(sbDir) exit_main(rc_checkout) else: - print " CMVC File Checkout [ OK ]" - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print(" CMVC File Checkout [ OK ]") + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") #------------------------------ # 4) Copy the binaries and file #------------------------------ # Find the files from the repo and copy to the Checkout dir - print "\n [ Find files and Overide the checkout file ] " - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print("\n [ Find files and Overide the checkout file ] ") + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") rc_copy = utilcode.utilCmvcRepoPath(path_name,g_cmvc_num,file_name) if rc_copy == errorcode.ERROR_CMVC_FILE_COPY: - print " [ File copy Failed ] [ Error code : %s]"%rc_copy + print(" [ File copy Failed ] [ Error code : %s]"%rc_copy) # Return to initial directory of operation os.chdir(origDir) shutil.rmtree(sbDir) exit_main(rc_copy) else: - print " Files Copied Successfully : [ OK ] " + print(" Files Copied Successfully : [ OK ] ") - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") #--------------------- # 6) Checkin the files #--------------------- - print "\n [ Check-in Files from CMVC ] " - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print("\n [ Check-in Files from CMVC ] ") + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") if file_name == "None": file_name = errorcode.CMVC_FILE_LIST for files in file_name.split(","): rc_checkin = utilcode.utilCmvcCheckin(files,release_name,g_cmvc_num) if rc_checkin == errorcode.ERROR_CMVC_CHECKIN: - print " [ CMVC File Checkin Failed ] [Error code : %s]\t:%s"%(rc_checkin,files) + print(" [ CMVC File Checkin Failed ] [Error code : %s]\t:%s"%(rc_checkin,files)) # Undo checkin.. dont check errors just do it utilcode.utilRollBack("checkin",g_cmvc_num,release_name) # Return to initial directory of operation @@ -338,28 +339,28 @@ def main(): shutil.rmtree(sbDir) exit_main(rc_checkin) else: - print " CMVC File Checkin [ OK ]" - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print(" CMVC File Checkin [ OK ]") + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") #--------------------------------- # 7) Fix record the defect/release #--------------------------------- - print "\n [ Fix the Record to complete in CMVC ] " + print("\n [ Fix the Record to complete in CMVC ] ") utilcode.utilCmvcFixComplete(g_cmvc_num, release_name) #--------------------------------- # 8) Trigger Jenkins CI Job #--------------------------------- - print "\n [ Trigering Jenkins job ] " + print("\n [ Trigering Jenkins job ] ") rc_ci = utilcode.utilTriggerJenkins(g_cmvc_num, release_name, bvt) if rc_ci == errorcode.ERROR_CI_TRIGGER : - print " [ CI Trigger Failed ] [Error code : %s]\t"%(rc_ci) + print(" [ CI Trigger Failed ] [Error code : %s]\t"%(rc_ci)) # Return to initial directory of operation os.chdir(origDir) shutil.rmtree(sbDir) exit_main(rc_ci) else : - print " CI Trigger [ OK ]" + print(" CI Trigger [ OK ]") #----------------------------------------- # Return to initial directory of operation @@ -368,7 +369,7 @@ def main(): shutil.rmtree(sbDir) # Clean exit - print "\n [ Manually Integrate on CMVC post CI ] " + print("\n [ Manually Integrate on CMVC post CI ] ") exit_main(errorcode.SUCCESS_EXIT) diff --git a/src/tools/utils/cmvcRelease.py b/src/tools/utils/cmvcRelease.py index 6dd6b74c..4dc6e832 100755 --- a/src/tools/utils/cmvcRelease.py +++ b/src/tools/utils/cmvcRelease.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import subprocess import os import sys @@ -42,7 +43,7 @@ CMVC_PASSWORD = "xxxxxx" # cmd = ['Feature','-open', '-remarks',' \"SBE release '+build_name+'\"', '-component', 'esw_sbei'] # result = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] # cmvc_feature = result.split()[-1].split('.')[0] -# print "cmvc track ["+cmvc_feature+']' +# print("cmvc track ["+cmvc_feature+']') # os.system('Feature -assign '+cmvc_feature+' -owner '+CMVC_USER) # os.system('Feature -accept '+cmvc_feature) # os.system('Track -create -feature '+cmvc_feature+' -release fips911') @@ -77,46 +78,46 @@ def step_2(branch, cmvc_feature): filterarray += [ele] last_release = filterarray[-1].split()[0].split('/')[-1] - print "last release ["+last_release+"]" + print("last release ["+last_release+"]") # build-name generation cmd = [REL_TOOL,'build-name', '-release', RELEASE[branch]] build_name = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].split('\n')[0] - print "build name ["+build_name+"]" + print("build name ["+build_name+"]") # latest commit cmd = ['git','log', '-1', '--pretty=format:%H'] commit = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].split('\n')[0] - print "commit ["+commit+"]" + print("commit ["+commit+"]") # define release level cmd = REL_TOOL+' define --level '+str(build_name)+' --base '+str(commit)+' --released '+str(last_release) os.system(cmd) - print cmd + print(cmd) # release cmd = REL_TOOL+' release --level '+build_name os.system(cmd) - print cmd + print(cmd) # make SBE cmd = 'make clean' - print cmd + print(cmd) os.system(cmd) cmd = 'make install' - print cmd + print(cmd) os.system(cmd) # trigger CI cmd = './sb cmvc -f '+str(cmvc_feature)+' -r ' + 'fips'+RELEASE[branch] os.system(cmd) - print cmd + print(cmd) # after ci pass def step_3(branch, track): # integrate track cmd = 'Track -integrate -feature '+track+' -release fips'+RELEASE[branch] os.system(cmd) - print cmd + print(cmd) # get last release tag cmd = ['git', 'for-each-ref', '--sort=taggerdate', '--format','\'%(refname) %(taggerdate)\'','refs/tags'] @@ -129,10 +130,10 @@ def step_3(branch, track): filterarray += [ele] last_release = filterarray[-1].split()[0].split('/')[-1] - print "last release ["+last_release+"]" + print("last release ["+last_release+"]") cmd = 'git push '+REMOTE+' '+last_release os.system(cmd) - print cmd + print(cmd) # cmvc log in diff --git a/src/tools/utils/sbeCmvcUtility.py b/src/tools/utils/sbeCmvcUtility.py index 405503e2..f5c02621 100755 --- a/src/tools/utils/sbeCmvcUtility.py +++ b/src/tools/utils/sbeCmvcUtility.py @@ -41,6 +41,7 @@ #------------------------- # Imports #------------------------- +from __future__ import print_function import os, sys import time import os.path @@ -66,7 +67,7 @@ import sbeCmvcConstants as errorcode def utilCmvcChangeDir(i_cmvcnum): l_home_path= expanduser("~") + "/" + errorcode.CMVC_DIR_CREATE + i_cmvcnum - print " Sandbox path\t: ",l_home_path + print(" Sandbox path\t: ",l_home_path) cmd='mkdir -p ' + l_home_path os.system(cmd) os.chdir(l_home_path) @@ -87,8 +88,8 @@ def utilCmvcRepoPath(i_pathname, i_cmvcnum, i_filename): l_home_path= expanduser("~") + "/" + errorcode.CMVC_DIR_CREATE + i_cmvcnum # Strip the last string from the file path input - print " Sandbox path\t: ",l_home_path - print " SBE Repo path\t: ",i_pathname + print(" Sandbox path\t: ",l_home_path) + print(" SBE Repo path\t: ",i_pathname) if i_filename == "None": i_filename = errorcode.CMVC_FILE_LIST @@ -100,10 +101,10 @@ def utilCmvcRepoPath(i_pathname, i_cmvcnum, i_filename): l_repo_path = utilFindFile(l_filename,i_pathname) if l_sb_path is None : - print " ERROR: Checked out sandbox does not contain " + l_filename + print(" ERROR: Checked out sandbox does not contain " + l_filename) return errorcode.ERROR_CMVC_FILE_COPY if l_repo_path is None : - print " ERROR: File Not Found in SBE repo " + l_filename + print(" ERROR: File Not Found in SBE repo " + l_filename) return errorcode.ERROR_CMVC_FILE_COPY cp_cmd = 'cp ' + l_repo_path + ' ' + l_sb_path @@ -180,8 +181,8 @@ def utilFindFilePPE(i_filename, i_path, i_sandbox_name): # ########################################################################## def utilCmvcCheckout(i_filename, i_release, i_cmvcnum): - print " File Name\t: ",i_filename - print " Release\t: ",i_release + print(" File Name\t: ",i_filename) + print(" Release\t: ",i_release) # The file simics.tar,releaseNotes.html is not unique so provide # the relative path @@ -190,7 +191,7 @@ def utilCmvcCheckout(i_filename, i_release, i_cmvcnum): elif i_filename == "releaseNotes.html": i_filename = 'src/sbei/sbfw/releaseNotes.html' - print " CMVC #\t: ",i_cmvcnum[1:] + print(" CMVC #\t: ",i_cmvcnum[1:]) l_home_path= expanduser("~") + "/" + errorcode.CMVC_DIR_CREATE + i_cmvcnum cmd='File -checkout ' + i_filename + ' -release '+ i_release + ' -relative ' + l_home_path @@ -199,12 +200,12 @@ def utilCmvcCheckout(i_filename, i_release, i_cmvcnum): else: cmd += ' -feature ' + i_cmvcnum[1:] - print " Executing\t: ", cmd + print(" Executing\t: ", cmd) rc = os.system(cmd) if rc: # rc 256 File not found in CMVC if rc == 256: - print " * File was not found or Error operation in CMVC" + print(" * File was not found or Error operation in CMVC") return errorcode.ERROR_CMVC_CHECKOUT else: return errorcode.SUCCESS_CMVC_CHECKOUT @@ -223,9 +224,9 @@ def utilCmvcCheckout(i_filename, i_release, i_cmvcnum): # ########################################################################## def utilCmvcCheckin(i_filename, i_release, i_cmvcnum): - print " File Name\t: ",i_filename - print " Release\t: ",i_release - print " CMVC #\t: ",i_cmvcnum[1:] + print(" File Name\t: ",i_filename) + print(" Release\t: ",i_release) + print(" CMVC #\t: ",i_cmvcnum[1:]) l_home_path= expanduser("~") + "/" + errorcode.CMVC_DIR_CREATE + i_cmvcnum l_base_path = utilFindFile(i_filename,l_home_path) @@ -240,7 +241,7 @@ def utilCmvcCheckin(i_filename, i_release, i_cmvcnum): else: cmd += ' -feature ' + i_cmvcnum[1:] - print " Executing\t: ", cmd + print(" Executing\t: ", cmd) rc = os.system(cmd) if rc: return errorcode.ERROR_CMVC_CHECKIN @@ -259,7 +260,7 @@ def utilCmvcCheckin(i_filename, i_release, i_cmvcnum): # ########################################################################## def utilCmvcFixComplete(i_cmvcnum, i_release): - print " CMVC #\t: ",i_cmvcnum + print(" CMVC #\t: ",i_cmvcnum) l_cmvcnum =i_cmvcnum[1:] if i_cmvcnum[:1] == "D": @@ -267,7 +268,7 @@ def utilCmvcFixComplete(i_cmvcnum, i_release): else: cmd='Fix -complete ' + ' -feature ' + l_cmvcnum + ' -r ' + i_release + ' -component esw_sbei' - print " Executing\t: ", cmd + print(" Executing\t: ", cmd) rc = os.system(cmd) if rc: return errorcode.ERROR_CMVC_FIX_RECORD @@ -285,8 +286,8 @@ def utilCmvcFixComplete(i_cmvcnum, i_release): # ########################################################################## def utilCheckTrackState(i_cmvcnum, i_release): - print " CMVC #\t: ",i_cmvcnum - print " Release\t: ",i_release + print(" CMVC #\t: ",i_cmvcnum) + print(" Release\t: ",i_release) l_cmvcnum =i_cmvcnum[1:] cmd = 'Track -view -release ' + i_release @@ -296,7 +297,7 @@ def utilCheckTrackState(i_cmvcnum, i_release): cmd += ' -feature ' + l_cmvcnum cmd += ' | grep state ' - print " Executing\t: ", cmd + print(" Executing\t: ", cmd) ex_cmd = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) for line in ex_cmd.stdout : if not line: continue @@ -316,24 +317,24 @@ def utilCheckTrackState(i_cmvcnum, i_release): # ########################################################################## def utilCheckFileHash(i_src, i_dest): - print " Source\t: ",i_src - print " Destination\t: ",i_dest + print(" Source\t: ",i_src) + print(" Destination\t: ",i_dest) sha_orig = hashlib.sha256() sha_orig.update(file(i_src).read()) orig_hash=sha_orig.hexdigest() - print " * Orig Hash\t [ %s : %s ] "% (os.path.basename(i_src),orig_hash) + print(" * Orig Hash\t [ %s : %s ] "% (os.path.basename(i_src),orig_hash)) sha_copy = hashlib.sha256() sha_copy.update(file(i_dest).read()) copied_hash=sha_copy.hexdigest() - print " * Copied Hash\t [ %s : %s ] "% (os.path.basename(i_dest),copied_hash) + print(" * Copied Hash\t [ %s : %s ] "% (os.path.basename(i_dest),copied_hash)) if orig_hash == copied_hash: - print " -> Hash Match .. Continue\n" + print(" -> Hash Match .. Continue\n") return errorcode.SUCCESS_HASH_CHECK else: - print " Mismatch Hash.. Abort" + print(" Mismatch Hash.. Abort") return errorcode.ERROR_HASH_CHECK ########################################################################## @@ -349,27 +350,27 @@ def utilCheckFileHash(i_src, i_dest): # ########################################################################## def utilRollBack(i_action, i_cmvcnum, i_release): - print "\n * Action request\t: ",i_action + print("\n * Action request\t: ",i_action) if i_action == "checkin": - print " * Undoing All default File list" + print(" * Undoing All default File list") if i_cmvcnum[:1] == "D": cmd = 'File -undo ' + errorcode.CMVC_FILE_UNDO_LIST + ' -release ' + i_release + ' -defect ' + i_cmvcnum[1:] + ' >/dev/null 2>&1' else: cmd = 'File -undo ' + errorcode.CMVC_FILE_UNDO_LIST + ' -release ' + i_release + ' -feature ' + i_cmvcnum[1:] + ' >/dev/null 2>&1' else: - print " * Unlocking All default Files list" + print(" * Unlocking All default Files list") if i_cmvcnum[:1] == "D": cmd = 'File -unlock ' + errorcode.CMVC_FILE_UNDO_LIST + ' -release ' + i_release + ' >/dev/null 2>&1' else: cmd = 'File -unlock ' + errorcode.CMVC_FILE_UNDO_LIST + ' -release ' + i_release + ' >/dev/null 2>&1' - #print " Executing : ", cmd + #print(" Executing : ", cmd) rc = os.system(cmd) # CMVC throws this rc even if its successfull if rc != 1024 and rc !=0: - print "\n Error [ %s ] in Undoing/Unlocking Files.. Please check manually"%rc + print("\n Error [ %s ] in Undoing/Unlocking Files.. Please check manually"%rc) else: - print "\n Roll Back Successfull.. Please Revisit your inputs [ OK ] " + print("\n Roll Back Successfull.. Please Revisit your inputs [ OK ] ") ########################################################################## @@ -385,7 +386,7 @@ def utilRollBack(i_action, i_cmvcnum, i_release): # ########################################################################## def utilTriggerJenkins(i_cmvcnum,i_release,i_bvt): - print " Jenkins job for %s" % i_cmvcnum + print(" Jenkins job for %s" % i_cmvcnum) #PATH : /afs/austin.ibm.com/projects/esw/bin/fsp-CI-jenkins cmd = "fsp-CI-jenkins -r " + i_release + " -t " + i_cmvcnum[1:] + " --test_on_hardware=y" if not i_bvt == "None" : @@ -411,14 +412,14 @@ def utilTriggerJenkins(i_cmvcnum,i_release,i_bvt): ########################################################################## def utilCopyFileToSandbox(i_pathname,i_sandboxname,i_filename): - print "\n *** For Development *** \n" - print " Sandbox path\t: ",i_sandboxname - print " SBE Repo path\t: ",i_pathname - print "\n" + print("\n *** For Development *** \n") + print(" Sandbox path\t: ",i_sandboxname) + print(" SBE Repo path\t: ",i_pathname) + print("\n") if i_filename == "None": i_filename = errorcode.CMVC_FILE_LIST - #print " No User supplied Files to copy" + #print(" No User supplied Files to copy") #return errorcode.ERROR_FILE_INPUT for l_filename in i_filename.split(","): @@ -426,7 +427,7 @@ def utilCopyFileToSandbox(i_pathname,i_sandboxname,i_filename): l_sandbox_name = os.path.basename(i_sandboxname) l_repo_path = utilFindFilePPE(l_filename,i_pathname,l_sandbox_name) if l_repo_path is None : - print " File [ %s ] not found in Repo..\t Check your repo and retry "%l_filename + print(" File [ %s ] not found in Repo..\t Check your repo and retry "%l_filename) return errorcode.ERROR_CMVC_FILE_COPY else: for files in errorcode.FILE_LOOKUP_LIST.split(","): @@ -439,18 +440,18 @@ def utilCopyFileToSandbox(i_pathname,i_sandboxname,i_filename): # Check if this path exist in the sandbox , if not create and copy if os.path.exists(sb_cp_path) == False: cmd='mkdir -p ' + os.path.dirname(sb_cp_path) - #print " Creating dir %s "%cmd + #print(" Creating dir %s "%cmd) os.system(cmd) # Copy the file copy_cmd = 'cp -rf ' + l_repo_path + ' ' + sb_cp_path rc = os.system(copy_cmd) if rc: - print " RC code :",rc - print " ERROR : Copying file : ",copy_cmd + print(" RC code :",rc) + print(" ERROR : Copying file : ",copy_cmd) return errorcode.ERROR_CMVC_FILE_COPY else: - print " Copied file : ",copy_cmd + print(" Copied file : ",copy_cmd) return errorcode.SUCCESS_DEV_EXIT @@ -471,15 +472,15 @@ def utilppeSbENV(i_env_key): env_ppe_path="None" for key in os.environ.keys(): if i_env_key in key: - #print "\t %s : %s" % (key,os.environ[key]) + #print("\t %s : %s" % (key,os.environ[key])) env_ppe_path = os.environ[key] l_found_ppe_conf = True if l_found_ppe_conf == False: - print " ---------------------------------------------------------" - print " | [ ERROR SETTING ] : The PPE Repository ENV is not set |" - print " | Please do ./sb workon to set/load the PPE repo ENV |" - print " ---------------------------------------------------------" + print(" ---------------------------------------------------------") + print(" | [ ERROR SETTING ] : The PPE Repository ENV is not set |") + print(" | Please do ./sb workon to set/load the PPE repo ENV |") + print(" ---------------------------------------------------------") return env_ppe_path diff --git a/src/tools/utils/sbePatchUtility.py b/src/tools/utils/sbePatchUtility.py index bbb6d883..2ab1ecaa 100644 --- a/src/tools/utils/sbePatchUtility.py +++ b/src/tools/utils/sbePatchUtility.py @@ -40,6 +40,7 @@ #------------------------- # Imports #------------------------- +from __future__ import print_function import os, sys import time import os.path @@ -65,7 +66,7 @@ import sbeCmvcUtility as utilcode # ########################################################################## def utilPatchSimics(i_sandbox_path, i_sandbox_root): - print "\n ... Patching simics files " + print("\n ... Patching simics files ") sb_name=os.path.basename(i_sandbox_path) @@ -76,7 +77,7 @@ def utilPatchSimics(i_sandbox_path, i_sandbox_root): return errorcode.ERROR_HOOKING_FILE l_sim_cmd = "workon -m ppc " + sb_name + " -c " + l_sim_file + " -rc " + i_sandbox_root +"/sbesandboxrc" - print " ", l_sim_cmd + print(" ", l_sim_cmd) os.system(l_sim_cmd) @@ -96,7 +97,7 @@ def utilPatchSimics(i_sandbox_path, i_sandbox_root): # ########################################################################## def utilExecuteShell(i_ppe_root, i_sandbox_path, i_shell_file): - print "\n ... Executing shell : ",i_shell_file + print("\n ... Executing shell : ",i_shell_file) # Sanbox name if i_sandbox_path != "None": @@ -105,7 +106,7 @@ def utilExecuteShell(i_ppe_root, i_sandbox_path, i_shell_file): # Find the file and execute l_path_name = i_ppe_root + '/src' l_shell_path=utilcode.utilFindFile(i_shell_file, l_path_name) - print " [ %s ]"%l_shell_path + print(" [ %s ]"%l_shell_path) if i_sandbox_path != "None": # Load the shell onto the Sandbox env and execute @@ -132,7 +133,7 @@ def utilExecuteShell(i_ppe_root, i_sandbox_path, i_shell_file): def utilShell_hooks(i_sandbox_path): # Find the simics machine from ENV l_machine = os.environ['MACHINE'].rstrip('\n') - print " Machine : ",l_machine + print(" Machine : ",l_machine) l_cmd_exec = 'start_simics -no_start -machine ' + l_machine + ' -batch_mode ' # Write the compile shell hook on the fips sandbox location diff --git a/src/tools/utils/sbePrime.py b/src/tools/utils/sbePrime.py index 8f522bda..dd3ab153 100755 --- a/src/tools/utils/sbePrime.py +++ b/src/tools/utils/sbePrime.py @@ -41,6 +41,7 @@ #------------------------- # Imports #------------------------- +from __future__ import print_function import getopt import os, sys, glob import shutil @@ -60,49 +61,49 @@ def main(): # Usage tool option #------------------------------------------ def usage(): - print " \n" - print " :: Command line USAGE options for Copying SBE FW files for compilation :: \n" - print " sbeDistribute.py -s -i " - - print " \n" - print " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" - print " | By default NO argument is needed as an input . |" - print " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" - print " \n ***** Options Supported *****" - print " \t -p,--patch = [ Optional ] Patch Simics related files on Sandbox " - print " \t -s,--sb = [ Optional ] Sandbox base name" - print " \t By default it picks up the ppe Repo test_sb sandbox" - print " \t but if you have created a sandbox of your own manually " - print " \t and you want to compile, use this option then only" - print " \t -i,--files = [ Optional ] Firmware Files coma ',' separated input file1,file2" - print " \t Only the pre-define listed files bellow:" - print " \t sbe_sp_intf.H,simics.tar," - print " \t sbe_seeprom_DD2.bin" - print " \t -r,--rc_file = [ Optional ] The RC file for the sandbox (with absolute path)" - print " \t -n,--no_build = [ Optional ] Flag to determine if sbei component should be compiled" - print " \t -h,--help = Help" - print " ------------------------------------------------------------------------------------" + print(" \n") + print(" :: Command line USAGE options for Copying SBE FW files for compilation :: \n") + print(" sbeDistribute.py -s -i ") + + print(" \n") + print(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + print(" | By default NO argument is needed as an input . |") + print(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + print(" \n ***** Options Supported *****") + print(" \t -p,--patch = [ Optional ] Patch Simics related files on Sandbox ") + print(" \t -s,--sb = [ Optional ] Sandbox base name") + print(" \t By default it picks up the ppe Repo test_sb sandbox") + print(" \t but if you have created a sandbox of your own manually ") + print(" \t and you want to compile, use this option then only") + print(" \t -i,--files = [ Optional ] Firmware Files coma ',' separated input file1,file2") + print(" \t Only the pre-define listed files bellow:") + print(" \t sbe_sp_intf.H,simics.tar,") + print(" \t sbe_seeprom_DD2.bin") + print(" \t -r,--rc_file = [ Optional ] The RC file for the sandbox (with absolute path)") + print(" \t -n,--no_build = [ Optional ] Flag to determine if sbei component should be compiled") + print(" \t -h,--help = Help") + print(" ------------------------------------------------------------------------------------") #------------------------------------------ # Exit from this Main #------------------------------------------ def exit_main(rc): if rc == errorcode.HELP_EXIT: - print " [ HELP DOCUMENTATION ]\n" + print(" [ HELP DOCUMENTATION ]\n") sys.exit(0) if rc == errorcode.ERROR_BUILD_FAILED: - print " Compilation Failed .. Error " + print(" Compilation Failed .. Error ") if rc == errorcode.SUCCESS_DEV_EXIT: - print " [ Files Copy done! ]\n" + print(" [ Files Copy done! ]\n") sys.exit(0) if rc: - print "\n [ ERROR - MAIN ] Exiting with error code = ", rc + print("\n [ ERROR - MAIN ] Exiting with error code = ", rc) sys.exit(rc) else: - print "\n Fips Sandbox compilation and simics patching completed [ OK ] " + print("\n Fips Sandbox compilation and simics patching completed [ OK ] ") sys.exit(0) #------------------------------------------ @@ -154,17 +155,17 @@ def main(): #------------------------------ # 1) User input params/ Check ENV #------------------------------ - print "\n [ Checking SBE user ENV Pre-req ] " + print("\n [ Checking SBE user ENV Pre-req ] ") # Get it from ENV if path_name == "None": # Get the PPE path l_ppe_path = utilcode.utilppeSbENV("SBEROOT") if l_ppe_path == "None": - print "\n Couldn't find PPE repo info from ENV currently set... " - print " [ ERROR ] PPE Repo ENV Setting Path : %s " % l_ppe_path + print("\n Couldn't find PPE repo info from ENV currently set... ") + print(" [ ERROR ] PPE Repo ENV Setting Path : %s " % l_ppe_path) exit_main(errorcode.ERROR_SETTING) else: - print " PPE Repo path Setting\t : %s "% l_ppe_path + print(" PPE Repo path Setting\t : %s "% l_ppe_path) path_name = l_ppe_path #----------------------------------- @@ -177,7 +178,7 @@ def main(): sandbox_path = utilcode.utilFind_ENV_string("SANDBOXBASE").rstrip('\n') else: sandbox_path = utilcode.utilFind_sb_base(sandbox_name).rstrip('\n') - print " Fips Sandbox path\t : ",sandbox_path + print(" Fips Sandbox path\t : ",sandbox_path) #----------------------------------- # 3) Get the Sanbox root path @@ -189,11 +190,11 @@ def main(): sandbox_root = utilcode.utilFind_sb_rc(sandbox_name).rstrip('\n') if sandbox_root == "None": - print " ** [ ERROR ] Something Fishy about the ENV set -OR- Option used.. Please check manually ** " + print(" ** [ ERROR ] Something Fishy about the ENV set -OR- Option used.. Please check manually ** ") usage() exit_main(errorcode.ERROR_SETTING) else: - print " Sandbox root path\t : ",sandbox_root + print(" Sandbox root path\t : ",sandbox_root) #--------------------------------------------- # sim setup if user initiates @@ -204,22 +205,22 @@ def main(): #--------------------------------------------- rc_sb = utilpatch.utilExecuteShell(path_name,"None","sandbox-create") if rc_sb == errorcode.SUCCESS_EXIT: - print " Sandbox Created.. [ OK ] \n" + print(" Sandbox Created.. [ OK ] \n") else: - print " Sandbox Create.. [ ERROR ]",rc_sb + print(" Sandbox Create.. [ ERROR ]",rc_sb) exit_main(rc_sb) #---------------------------------------- # Patch up the simics patches files #---------------------------------------- - print "\n *** Update Simics patches onto Sandbox *** \n " + print("\n *** Update Simics patches onto Sandbox *** \n ") # Pre sim setup rc_shell = utilpatch.utilExecuteShell(path_name,sandbox_path,"workarounds.presimsetup") if rc_shell == errorcode.SUCCESS_EXIT: - print " presimsetup [ OK ]\n" + print(" presimsetup [ OK ]\n") else: - print " presimsetup [ ERROR ] : ",rc_shell + print(" presimsetup [ ERROR ] : ",rc_shell) exit_main(rc_shell) # Patch the simics files @@ -227,16 +228,16 @@ def main(): if rc_sim != errorcode.SUCCESS_EXIT: exit_main(rc_sim) else: - print " Patch the simics files on Sandbox [ OK ] \n" + print(" Patch the simics files on Sandbox [ OK ] \n") # Post sim setup rc_shell = utilpatch.utilExecuteShell(path_name,sandbox_path,"workarounds.postsimsetup") if rc_shell == errorcode.SUCCESS_EXIT: - print " postsimsetup [ OK ]\n" + print(" postsimsetup [ OK ]\n") # Clean exit Get out from here exit_main(errorcode.SUCCESS_EXIT) else: - print " postsimsetup [ ERROR ] : ",rc_shell + print(" postsimsetup [ ERROR ] : ",rc_shell) exit_main(rc_shell) # Files to copy for sbe prime @@ -257,22 +258,22 @@ def main(): if os.path.isdir(sandbox_path) == True: rc_copy = utilcode.utilCopyFileToSandbox(path_name,sandbox_path,file_name) if rc_copy == errorcode.SUCCESS_DEV_EXIT: - print " Files Copied to Fips Sandbox : [ OK ]" + print(" Files Copied to Fips Sandbox : [ OK ]") else: exit_main(rc_copy) else: - print " Sandbox : %s [ Either doesn't exist or do workon to fips sb to load the ENV.. ]" % os.path.basename(sandbox_path) - print " - OR - " - print " [ Optional ] You can specify your sandbox name as input as well" - print " -s " + print(" Sandbox : %s [ Either doesn't exist or do workon to fips sb to load the ENV.. ]" % os.path.basename(sandbox_path)) + print(" - OR - ") + print(" [ Optional ] You can specify your sandbox name as input as well") + print(" -s ") usage() exit_main(errorcode.ERROR_SANDBOX_EXIST) else: - print " Please Check your fips Sandbox and retry" + print(" Please Check your fips Sandbox and retry") exit_main(errorcode.ERROR_SANDBOX_EXIST) sb_name=os.path.basename(sandbox_path) - print "\n Sandbox :",sb_name + print("\n Sandbox :",sb_name) if build == "1": #---------------------------------------- @@ -291,12 +292,12 @@ def main(): if rc_file == "None": compile_cmd="workon -m ppc " + sb_name + " -c " + hook_file + " -rc " + sandbox_root +"/.sandboxrc" else: - print " getting rc file from user \n" + print(" getting rc file from user \n") compile_cmd="workon -m ppc " + sb_name + " -c " + hook_file + " -rc " + rc_file - print "\n [ COMPILE ] Executing :%s \n"%compile_cmd + print("\n [ COMPILE ] Executing :%s \n"%compile_cmd) rc = os.system(compile_cmd) - print " Compilation returned rc :",rc + print(" Compilation returned rc :",rc) if rc != 0: exit_main(errorcode.ERROR_BUILD_FAILED) -- cgit v1.2.1