Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions harness/bin/test_harness_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ def auto_generated_scripts(harness_config,

"""

messloc = "In function {functionname}:".format(functionname="auto_generated_scripts")

status_dir = apptest.get_path_to_status()
ra_dir = apptest.get_path_to_runarchive()

Expand All @@ -167,7 +165,7 @@ def auto_generated_scripts(harness_config,
try:
build_exit_value = mymachine.build_executable()
except SetBuildRTEError as error:
message = f"{messloc} Unable to set the build runtime environnment."
message = f"Unable to set the build runtime environnment."
message += error.message
a_logger.doCriticalLogging(message)
finally:
Expand All @@ -185,7 +183,7 @@ def auto_generated_scripts(harness_config,
submit_exit_value = 0
if actions['submit'] and (build_exit_value != 0):
submit_exit_value = 1
message = f"{messloc} No submit action due to prior failed build."
message = f"No submit action due to prior failed build."
a_logger.doCriticalLogging(message)
elif actions['submit'] and (build_exit_value == 0):

Expand Down Expand Up @@ -236,7 +234,7 @@ def auto_generated_scripts(harness_config,
if job_id != "0":
jstatus.log_event(status_file.StatusFile.EVENT_JOB_QUEUED, job_id)
else:
message = f"{messloc} Submit error, failed to retrieve the job id."
message = f"Submit error, failed to retrieve the job id."
a_logger.doCriticalLogging(message)
submit_exit_value = 1
else:
Expand Down Expand Up @@ -268,7 +266,7 @@ def auto_generated_scripts(harness_config,
run_exit_value = p.returncode
run_stdout.close()
else:
message = f"{messloc} Run error, failed to retrieve the job id."
message = f"Run error, failed to retrieve the job id."
a_logger.doCriticalLogging(message)
run_exit_value = 1

Expand All @@ -286,7 +284,7 @@ def auto_generated_scripts(harness_config,
mymachine.start_report_executable()
mymachine.log_to_db()
else:
message = f"{messloc} check error, failed to retrieve the job id."
message = f"Check error, failed to retrieve the job id."
a_logger.doCriticalLogging(message)
check_exit_value = 1

Expand Down
9 changes: 4 additions & 5 deletions harness/libraries/apptest.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,16 +542,15 @@ def _start_test(self,
run_as_subprocess_command_return_exitstatus(starttestcomand,
command_execution_directory=pathtoscripts)
if exit_status > 0:
message = ( "In function {function_name} we have a critical error.\n"
"The command '{cmd}' has exited with a failure.\n"
"The exit return value is {value}\n.").format(function_name=self.__name_of_current_function(), cmd=starttestcomand,value=exit_status)
message = ( "The command '{cmd}' has exited with a failure.\n"
"The exit return value is {value}\n.").format(cmd=starttestcomand,value=exit_status)
self.logger.doCriticalLogging(message)


string1 = "Command failed: " + starttestcomand
return 1
else:
message = "In function {function_name}, the command '{cmd}' has executed sucessfully.\n".format(function_name=self.__name_of_current_function(),cmd=starttestcomand)
message = "'{cmd}' has executed sucessfully.\n".format(cmd=starttestcomand)
message += "stdout of command : {}\n".format(stdout)
message += "stderr of command : {}\n".format(stderr)
self.logger.doInfoLogging(message)
Expand All @@ -561,7 +560,7 @@ def _stop_test(self):
with open(pathtokillfile,"w") as kill_file:
kill_file.write("")

message = "In function {function_name}, The kill file '{filename}' has been created.\n".format(function_name=self.__name_of_current_function(),filename=pathtokillfile)
message = "The kill file '{filename}' has been created.\n".format(filename=pathtokillfile)
self.logger.doInfoLogging(message)

def _run_db_extensions(self):
Expand Down
52 changes: 20 additions & 32 deletions harness/machine_types/base_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ def submit_batch_script(self):
The exit status of submitting the batch script to the scheduler. An
exit_status of 0 indicates success, other wise failure.
"""
messloc = "In function {functionname}:".format(functionname=self._name_of_current_function())

message = f"{messloc} Submitting a batch script."
message = f"Submitting a batch script."
self.logger.doInfoLogging(message)

currentdir = os.getcwd()
Expand All @@ -195,20 +193,20 @@ def submit_batch_script(self):

try:
if filename != "":
message = f"{messloc} The submit runtime environmental file is {filename}."
message = f"The submit runtime environmental file is {filename}."
self.logger.doInfoLogging(message)
new_env = linux_utilities.get_new_environment(self,filename)
except SetBuildRTEError as error:
message = f"{messloc} Unable to set the submit runtime environment."
message = f"Unable to set the submit runtime environment."
self.logger.doCriticalLogging(message)

exit_status = linux_utilities.submit_batch_script(self,new_env)

if exit_status != 0:
message = f"{messloc} Unsuccessful batch script submission with exit status of {exit_status}."
message = f"Unsuccessful batch script submission with exit status of {exit_status}."
self.logger.doCriticalLogging(message)
else:
message = f"{messloc} Successful batch script submission with exit status of {exit_status}."
message = f"Successful batch script submission with exit status of {exit_status}."
self.logger.doInfoLogging(message)

return exit_status
Expand Down Expand Up @@ -273,9 +271,7 @@ def build_executable(self):
The exit status of the build command.

"""
messloc = "In function {functionname}:".format(functionname=self._name_of_current_function())

message = f"{messloc} Start of buiding executable.\n"
message = f"Start of buiding executable.\n"
self.logger.doInfoLogging(message)

currentdir = os.getcwd()
Expand All @@ -292,31 +288,31 @@ def build_executable(self):
if not copy_rc == 0:
return copy_rc

message = f"{messloc} Copied source to build directory.\n"
message = f"Copied source to build directory.\n"
self.logger.doInfoLogging(message)

# Get the environment using the build runtime environment file.
new_env = None
filename = self.build_runtime_environment_command_file

if filename != "":
message = f"{messloc} The build runtime environmental file is {filename}."
message = f"The build runtime environmental file is {filename}."
self.logger.doInfoLogging(message)
new_env = linux_utilities.get_new_environment(self,filename)
message = f"{messloc} The new build environment is as follows:\n"
message = f"The new build environment is as follows:\n"
message += str(new_env)
self.logger.doInfoLogging(message)

# We now change directories to the build directory.
os.chdir(path_to_build_directory)

message = f"{messloc} Changed to build directory {path_to_build_directory}. Commencing build ..."
message = f"Changed to build directory {path_to_build_directory}. Commencing build ..."
self.logger.doInfoLogging(message)

# We run the build command.
exit_status = self._build_executable(new_env)

message = f"{messloc} The build exit status is {exit_status}."
message = f"The build exit status is {exit_status}."
if exit_status == 0:
self.logger.doInfoLogging(message)
else:
Expand All @@ -325,10 +321,10 @@ def build_executable(self):
# We now change back to starting directory.
os.chdir(currentdir)

message = f"{messloc} Changed back to Scripts directory {currentdir}."
message = f"Changed back to Scripts directory {currentdir}."
self.logger.doInfoLogging(message)

message = f"{messloc} End of buiding executable."
message = f"End of buiding executable."
self.logger.doInfoLogging(message)

return exit_status
Expand All @@ -341,9 +337,6 @@ def check_executable(self):
int :
The exist status of the check command.
"""

messloc = "In function {functionname}:".format(functionname=self._name_of_current_function())

currentdir = os.getcwd()
runarchive_dir = self.apptest.get_path_to_runarchive()

Expand All @@ -352,16 +345,16 @@ def check_executable(self):
filename = self.check_runtime_environment_command_file
try:
if filename != "":
message = f"{messloc} The check runtime environmental file is {filename}."
message = f"The check runtime environmental file is {filename}."
new_env = linux_utilities.get_new_environment(self,filename)
except SetBuildRTEError as error:
message = f"{messloc} Unable to set the check runtime environment."
message = f"Unable to set the check runtime environment."
self.logger.doCriticalLogging(message)

# We now change to the runarchive directory.
os.chdir(runarchive_dir)

message = f"{messloc} The current working directory is {runarchive_dir} "
message = f"The current working directory is {runarchive_dir} "
self.logger.doInfoLogging(message)

# We now run the check command.
Expand All @@ -372,7 +365,7 @@ def check_executable(self):
# We now change back to starting directory.
os.chdir(currentdir)

message = f"{messloc} The current working directory is {currentdir} "
message = f"The current working directory is {currentdir} "
self.logger.doInfoLogging(message)

return check_status
Expand All @@ -386,8 +379,7 @@ def start_report_executable(self):
"""
report_command_str = self.test_config.get_report_command()

messloc = "In function {functionname}: ".format(functionname=self._name_of_current_function())
message = f"{messloc} Running report executable script report script {report_command_str }."
message = f"Running report executable script report script {report_command_str }."

print(message)
self.logger.doInfoLogging(message)
Expand All @@ -403,8 +395,7 @@ def log_to_db(self):
------
bool: Success (True), otherwise, not logged to Databases
"""
messloc = "In function {functionname}: ".format(functionname=self._name_of_current_function())
message = f"{messloc} attempting to log to Databases."
message = f"Attempting to log to Databases."

self.logger.doInfoLogging(message)

Expand Down Expand Up @@ -436,8 +427,6 @@ def _submit_batch_script(self,new_env):
return exit_status

def _copy_source_to_build_directory(self):
messloc = "In function {functionname}:".format(functionname=self._name_of_current_function())

path_to_source = self.apptest.get_path_to_source()
path_to_test_source = self.apptest.get_path_to_test_source()
# Use Error threshold to show this message all the time
Expand Down Expand Up @@ -472,11 +461,10 @@ def _copy_source_to_build_directory(self):

def _write_check_exit_status(self, cstatus):
""" Write the status of checking results to the status directory."""
messloc = "In function {functionname}:".format(functionname=self._name_of_current_function())

status_file = self.apptest.get_path_to_job_status_file()
with open(status_file, "w") as file_obj:
message = f"{messloc} Writing check_exit_status {cstatus} into {status_file}"
message = f"Writing check_exit_status {cstatus} into {status_file}"
self.logger.doInfoLogging(message)
file_obj.write(str(cstatus))
return
Expand Down
12 changes: 4 additions & 8 deletions harness/machine_types/linux_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,11 @@ def check_executable(a_machine,new_env):
my_current_frame = inspect.currentframe()
my_current_frame_info = inspect.getframeinfo(my_current_frame)
my_functioname = my_current_frame_info.function
messloc = "In function {functionname}:".format(functionname=my_functioname )

checkcmd = a_machine.check_command
path_to_checkscript = a_machine.apptest.get_path_to_scripts()
check_command_line = _form_proper_command_line(path_to_checkscript,checkcmd)

message = f"{messloc} The check command line is {check_command_line}."
message = f"The check command line is {check_command_line}."
a_machine.logger.doInfoLogging(message)

check_outfile = "output_check.txt"
Expand All @@ -160,7 +158,7 @@ def check_executable(a_machine,new_env):

check_exit_status = p.returncode

message = f"{messloc} The check command return code {check_exit_status}."
message = f"The check command return code {check_exit_status}."
a_machine.logger.doInfoLogging(message)

return check_exit_status
Expand Down Expand Up @@ -384,7 +382,6 @@ def build_executable(a_machine, new_env):
# Get the name of the current function.
frame = inspect.currentframe()
function_name = inspect.getframeinfo(frame).function
messloc = "In function {functionname}:".format(functionname=function_name )

# Update the build environment
env_vars = a_machine.test_config.test_environment
Expand All @@ -405,7 +402,7 @@ def build_executable(a_machine, new_env):

# We get the command for bulding the binary.
buildcmd = a_machine.test_config.get_build_command()
message = f"{messloc} The build command: {buildcmd}"
message = f"The build command: {buildcmd}"
a_machine.logger.doInfoLogging(message)

if a_machine.separate_build_stdio:
Expand All @@ -429,7 +426,6 @@ def submit_batch_script(a_machine, new_env):
# Get the name of the current function.
frame = inspect.currentframe()
function_name = inspect.getframeinfo(frame).function
messloc = "In function {functionname}:".format(functionname=function_name)

# Update the batch submission environment
env_vars = a_machine.test_config.test_environment
Expand All @@ -452,7 +448,7 @@ def submit_batch_script(a_machine, new_env):
batch_script = a_machine.test_config.get_batch_file()
submit_exit_value = a_machine.submit_to_scheduler(batch_script)

message = f"{messloc} Submitted batch script {batch_script} with exit status of {submit_exit_value}."
message = f"Submitted batch script {batch_script} with exit status of {submit_exit_value}."
return submit_exit_value

#-----------------------------------------------------
Expand Down