Skip to content

Commit

Permalink
Merge commit '0bd56d8454dc7667861555ccab88a21639696b57'
Browse files Browse the repository at this point in the history
Conflicts:
	harness/libraries/regression_test.py
  • Loading branch information
verolero86 committed Jun 24, 2020
2 parents 46e5ba0 + 0bd56d8 commit 5eb45a8
Show file tree
Hide file tree
Showing 29 changed files with 1,082 additions and 1,906 deletions.
130 changes: 36 additions & 94 deletions harness/bin/check_executable_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import subprocess
import getopt
import string
from libraries import status_file
from machine_types.machine_factory import MachineFactory

from libraries.apptest import subtest
from libraries.layout_of_apps_directory import get_layout_from_runarchivedir

#
# Author: Arnold Tharrington, Scientific Computing Group
Expand All @@ -21,61 +22,13 @@
# It is designed such that it will be called from the Scripts directory.
#

def check_executable_driver(path_to_results,
test_id_string):
#
# Wait till job_id.txt is created.
#
starting_directory = os.getcwd()
(dir_head1, dir_tail1) = os.path.split(starting_directory)
path1 = os.path.join(dir_head1,"Status",test_id_string,"job_id.txt")
while (not os.path.lexists(path1)):
file_obj = open(path1,"r")
job_id = file_obj.readline()
file_obj.close()
job_id = str.strip(job_id)


# Call the check_executable.x script only after the job_id.txt file is created.
jstatus = status_file.StatusFile(test_id_string,mode="Old")
jstatus.log_event(status_file.StatusFile.EVENT_CHECK_START)

#
# Add to environment the path to the Scripts directory.
#
os.putenv('RGT_PATH_TO_SCRIPTS_DIR',starting_directory)

# If the rgt_test_input.txt file exists call auto generated
# check script, else call user generated check script.
rgt_test_input_file = os.path.join(starting_directory,"rgt_test_input.txt")
if os.path.isfile(rgt_test_input_file):
auto_generated_check_script(path_to_results,test_id_string)
else:
user_generated_check_script(path_to_results,test_id_string)
# Run report_executable.x, if it exists.
report_command_argv = ['./report_executable.x']
if os.path.exists(report_command_argv[0]):
for args1 in sys.argv[1:] :
report_command_argv = report_command_argv + [args1]
report_command_argv = subprocess.call(report_command_argv)

jstatus = status_file.StatusFile(test_id_string,mode="Old")
jstatus.log_event(status_file.StatusFile.EVENT_CHECK_START)

#
# Now read the result to the job_status.txt file.
#
path2 = os.path.join(dir_head1,"Status",test_id_string,"job_status.txt")
file_obj2 = open(path2,"r")
job_correctness = file_obj2.readline()
file_obj2.close()
job_correctness = str.strip(job_correctness)

# Log result of status check.
jstatus.log_event(status_file.StatusFile.EVENT_CHECK_END,
job_correctness)

return
def usage():
print ("Usage: check_executable_driver.py [-h|--help] [-i <test_id_string>] -p <path_to_results>")
print ("A driver program that calls check_executable.x")
print
print ("-h, --help Prints usage information.")
print ("-p <path_to_results> The absoulte path to the results of a test.")
print ("-i <test_id_string> The test's unique id.")

def main():

Expand All @@ -89,6 +42,9 @@ def main():
usage()
sys.exit(2)

path_to_results = None
test_id_string = None

#
# Parse the command line arguments.
#
Expand All @@ -99,54 +55,40 @@ def main():
test_id_string = a
elif o == ("-h", "--help"):
usage()
sys.exit()
sys.exit(2)
else:
usage()
sys.exit()

check_executable_driver(path_to_results,
test_id_string)

return
sys.exit(2)

def user_generated_check_script(path_to_results,test_id_string):
if path_to_results == None:
usage()
sys.exit(2)

path_to_scripts_dir = os.getcwd()
sys.path.insert(0,path_to_scripts_dir)
check_executable_python_file = "./check_executable.py"
(apps_root, app, test, testid) = get_layout_from_runarchivedir(path_to_results)

if (os.path.isfile(check_executable_python_file) ):
import check_executable
check_executable.check_executable(path_to_results,test_id_string)
else:
check_command_argv = ["./check_executable.x"]
for args1 in sys.argv[1:] :
check_command_argv = check_command_argv + [args1]
check_cmd_process = subprocess.call(check_command_argv)

return
if test_id_string != None:
if testid != test_id_string:
print("ERROR: user-provided test id", test_id_string, "does not match run archive id", testid)
sys.exit(1)

def auto_generated_check_script(path_to_results,
test_id_string):
apptest = subtest(name_of_application=app,
name_of_subtest=test,
local_path_to_tests=apps_root,
harness_id=testid)

mymachine = MachineFactory.create_machine(path_to_results,test_id_string)

check_exit_value = mymachine.check_executable()
print("check_exit_value = " + str(check_exit_value))
currentdir = os.getcwd()
scriptsdir = apptest.get_path_to_scripts()

report_exit_value = mymachine.report_executable()
print("report_exit_value = " + str(report_exit_value))
if currentdir != scriptsdir:
os.chdir(scriptsdir)

return
check_command = "test_harness_driver.py --check -i " + testid
check_exit_value = os.system(check_command)

def usage():
print ("Usage: check_executable_driver.py [-h|--help] [-i <test_id_string>] [-p <path_to_results>]")
print ("A driver program that calls check_executable.x")
print
print ("-h, --help Prints usage information.")
print ("-p <path_to_results> The absoulte path to the results of a test.")
print ("-i <test_id_string> The test string unique id.")
if currentdir != scriptsdir:
os.chdir(currentdir)

return check_exit_value


if __name__ == "__main__":
Expand Down
18 changes: 10 additions & 8 deletions harness/bin/recheck_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import sys
import subprocess

from libraries.layout_of_apps_directory import apptest_layout

def main():

parser = argparse.ArgumentParser(description='Calculate the mean of the metric..')
Expand All @@ -26,19 +28,19 @@ def doReTest(test_name):
# -
# -
#-----------------------------------------------------
initial_dir = os.getcwd()
cwd = os.getcwd()

#-----------------------------------------------------
# Get the path to the Scripts directory. -
# -
#-----------------------------------------------------
path_to_scripts_dir = os.path.join(os.getcwd(),test_name,"Scripts")
path_to_scripts_dir = os.path.join(cwd, test_name, apptest_layout.test_scripts_dirname)

#-----------------------------------------------------
# Get the unique id of test instances. -
# -
#-----------------------------------------------------
path_to_run_archive_dir = os.path.join(os.getcwd(),test_name,"Run_Archive")
path_to_run_archive_dir = os.path.join(cwd, test_name, apptest_layout.test_run_archive_dirname)
unique_ids = os.listdir(path_to_run_archive_dir)

stdoutfile = "recheck.stdout.txt"
Expand All @@ -48,9 +50,9 @@ def doReTest(test_name):
header += "#\n"
print(header)
for id in unique_ids:
path_to_results = os.path.join(path_to_run_archive_dir,id)
path_to_results = os.path.join(path_to_run_archive_dir, id)
os.chdir(path_to_scripts_dir)
unix_command = "check_executable_driver.py -p {} -i {}".format(path_to_results,id)
unix_command = "check_executable_driver.py -p {} -i {}".format(path_to_results, id)
message = "Checking test instance: {}\n".format(str(id))
print(message)
with open(stdoutfile,"w") as out:
Expand All @@ -60,7 +62,7 @@ def doReTest(test_name):
message = " {}".format("standard output:")
print(message)
print(" ----------------")
file_obj = open(stdoutfile,"r")
file_obj = open(stdoutfile,"r")
records = file_obj.readlines()
for tmp_record in records:
message = " {}".format(tmp_record.strip())
Expand All @@ -72,7 +74,7 @@ def doReTest(test_name):
message = " {}".format("standard error:")
print(message)
print(" ----------------")
file_obj = open(stderrfile,"r")
file_obj = open(stderrfile,"r")
records = file_obj.readlines()
for tmp_record in records:
message = " {}".format(tmp_record.strip())
Expand All @@ -81,7 +83,7 @@ def doReTest(test_name):
print

os.chdir(initial_dir)


print
if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 5eb45a8

Please sign in to comment.