The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

118 lines
4.7 KiB

4 weeks ago
  1. import subprocess
  2. import os
  3. import shutil
  4. import time
  5. import math
  6. import sys
  7. logfileDir = "test_build_configurations_logs"
  8. pathToConfigFile = ""
  9. globalCmakeArguments = ""
  10. globalMakeArguments = ""
  11. if len(sys.argv) == 1 or len(sys.argv) > 5:
  12. print "Usage: " + sys.argv[0] + "/path/to/storm /path/to/configurations.txt \"optional make arguments\" \"optional cmake arguments\""
  13. print "Example: " + sys.argv[0] + " ~/storm test_build_configurations.txt \"-j 48 -k\" \"-DZ3_ROOT=/path/to/z3/\""
  14. sys.exit(0)
  15. pathToStorm = sys.argv[1]
  16. pathToConfigFile = sys.argv[2]
  17. if len(sys.argv) > 3:
  18. globalMakeArguments = sys.argv[3]
  19. print globalMakeArguments
  20. if len(sys.argv) > 4:
  21. globalCmakeArguments = sys.argv[4]
  22. print globalCmakeArguments
  23. # create directory for log files
  24. if not os.path.exists(logfileDir):
  25. os.makedirs(logfileDir)
  26. unsuccessfulConfigs = ""
  27. globalStartTime = time.time()
  28. with open(pathToConfigFile) as configfile:
  29. localStartTime = time.time()
  30. configId=0
  31. for localCmakeArguments in configfile:
  32. cmakeArguments = globalCmakeArguments + " " + localCmakeArguments.strip('\n')
  33. buildDir = os.path.join(pathToStorm, "build{}".format(configId))
  34. logfilename = os.path.join(logfileDir, "build{}".format(configId) + "_" + time.strftime("%Y-%m-%d-%H-%M-%S") + ".log")
  35. print "Building configuration {} with cmake options ".format(configId) + cmakeArguments
  36. print "\tCreating log file " + logfilename + " ..."
  37. with open(logfilename, "w") as logfile:
  38. success=True
  39. logfile.write("Log for test configuration " + cmakeArguments + "\n")
  40. print "\tCreating build directory" + buildDir + " ..."
  41. if os.path.exists(buildDir):
  42. print "\t\tRemoving existing directory " + buildDir
  43. shutil.rmtree(buildDir, ignore_errors=True)
  44. os.makedirs(buildDir)
  45. logfile.write("Build directory is " + buildDir + "\n")
  46. print "\t\tdone"
  47. if success:
  48. print "\tInvoking cmake ..."
  49. cmakeCommand = "cmake .. {}".format(cmakeArguments)
  50. logfile.write ("\n\n CALLING CMAKE \n\n" + cmakeCommand + "\n")
  51. try:
  52. cmakeOutput = subprocess.check_output("cd " + buildDir + "; " + cmakeCommand , shell=True,stderr=subprocess.STDOUT)
  53. print "\t\tdone"
  54. logfile.write(cmakeOutput)
  55. except subprocess.CalledProcessError as e:
  56. success=False
  57. print "\t\tfail"
  58. print e.output
  59. logfile.write(e.output)
  60. if success:
  61. print "\tInvoking make ..."
  62. makeCommand = "make {}".format(globalMakeArguments)
  63. logfile.write ("\n\n CALLING MAKE \n\n" + makeCommand + "\n")
  64. try:
  65. makeOutput = subprocess.check_output("cd " + buildDir + "; " + makeCommand , shell=True,stderr=subprocess.STDOUT)
  66. print "\t\tdone"
  67. logfile.write(makeOutput)
  68. except subprocess.CalledProcessError as e:
  69. success=False
  70. print "\t\tfail"
  71. print e.output
  72. logfile.write(e.output)
  73. if success:
  74. print "\tInvoking make check..."
  75. makeCheckCommand = "make check"
  76. logfile.write ("\n\n CALLING MAKE CHECK \n\n" + makeCheckCommand + "\n")
  77. try:
  78. makeCheckOutput = subprocess.check_output("cd " + buildDir + "; " + makeCheckCommand , shell=True,stderr=subprocess.STDOUT)
  79. print "\t\tdone"
  80. logfile.write(makeCheckOutput)
  81. except subprocess.CalledProcessError as e:
  82. success=False
  83. print "\t\tfail"
  84. print e.output
  85. logfile.write(e.output)
  86. localEndTime = time.time()
  87. if success:
  88. print "\tConfiguration build and tested successfully within {} minutes.".format(int((localEndTime - localStartTime)/60))
  89. else:
  90. print "\tAn error occurred for this configuration."
  91. unsuccessfulConfigs += buildDir + " with arguments " + cmakeArguments + "\n"
  92. configId += 1
  93. globalEndTime = time.time()
  94. print "All tests completed after {} minutes.".format(int((globalEndTime - globalStartTime)/60))
  95. if unsuccessfulConfigs == "":
  96. print "All configurations were build and tested successfully."
  97. else:
  98. print "The following configurations failed: \n" + unsuccessfulConfigs