Skip to content

Commit

Permalink
Testing - change output folder image writes, data dumps, performance …
Browse files Browse the repository at this point in the history
…result writes to CWD (r-abishek#276)

* Change output writes to build folder - Image based funcs - host+hip

* Change output writes to build folder - Voxel based funcs - host+hip

* Change output writes to build folder - Audio based funcs - host

* Change output location to cwd
  • Loading branch information
r-abishek authored and kiritigowda committed Dec 22, 2023
1 parent b2f3d2a commit 6724cb9
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 49 deletions.
25 changes: 14 additions & 11 deletions utilities/test_suite/HIP/runTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
inFilePath2 = scriptPath + "/../TEST_IMAGES/three_images_mixed_src2"
ricapInFilePath = scriptPath + "/../TEST_IMAGES/three_images_150x150_src1"
qaInputFile = scriptPath + "/../TEST_IMAGES/three_images_mixed_src1"
outFolderPath = os.getcwd()

# Checks if the folder path is empty, or is it a root folder, or if it exists, and remove its contents
def validate_and_remove_files(path):
Expand Down Expand Up @@ -66,12 +67,12 @@ def validate_and_remove_folders(path, folder):
if path == "/*": # check if the root directory is passed to the function
print("Root folder cannot be deleted.")
exit()
if path and os.path.isdir(path + "/.."): # checks if directory string is not empty and it exists
output_folders = [folder_name for folder_name in os.listdir(path + "/..") if folder_name.startswith(folder)]
if path and os.path.isdir(path): # checks if directory string is not empty and it exists
output_folders = [folder_name for folder_name in os.listdir(path) if folder_name.startswith(folder)]

# Loop through each directory and delete it only if it exists
for folder_name in output_folders:
folder_path = os.path.join(path, "..", folder_name)
folder_path = os.path.join(path, folder_name)
if os.path.isdir(folder_path):
shutil.rmtree(folder_path) # Delete the directory if it exists
print("Deleted directory:", folder_path)
Expand Down Expand Up @@ -389,28 +390,30 @@ def rpp_test_suite_parser_and_validator():
batchSize = args.batch_size
roiList = ['0', '0', '0', '0'] if args.roi is None else args.roi

if preserveOutput == 0:
validate_and_remove_folders(scriptPath, "OUTPUT_IMAGES_HIP")
validate_and_remove_folders(scriptPath, "QA_RESULTS_HIP")
validate_and_remove_folders(scriptPath, "OUTPUT_PERFORMANCE_LOGS_HIP")

if qaMode and batchSize != 3:
print("QA mode can only run with a batch size of 3.")
exit(0)

# set the output folders and number of runs based on type of test (unit test / performance test)
if(testType == 0):
if qaMode:
outFilePath = scriptPath + "/../QA_RESULTS_HIP_" + timestamp
outFilePath = outFolderPath + "/QA_RESULTS_HIP_" + timestamp
else:
outFilePath = scriptPath + "/../OUTPUT_IMAGES_HIP_" + timestamp
outFilePath = outFolderPath + "/OUTPUT_IMAGES_HIP_" + timestamp
numRuns = 1
elif(testType == 1):
if "--num_runs" not in sys.argv:
numRuns = 1000 #default numRuns for running performance tests
outFilePath = scriptPath + "/../OUTPUT_PERFORMANCE_LOGS_HIP_" + timestamp
outFilePath = outFolderPath + "/OUTPUT_PERFORMANCE_LOGS_HIP_" + timestamp
else:
print("Invalid TEST_TYPE specified. TEST_TYPE should be 0/1 (0 = Unittests / 1 = Performancetests)")
exit()

if preserveOutput == 0:
validate_and_remove_folders(outFolderPath, "OUTPUT_IMAGES_HIP")
validate_and_remove_folders(outFolderPath, "QA_RESULTS_HIP")
validate_and_remove_folders(outFolderPath, "OUTPUT_PERFORMANCE_LOGS_HIP")

os.mkdir(outFilePath)
loggingFolder = outFilePath
dstPath = outFilePath
Expand Down
20 changes: 11 additions & 9 deletions utilities/test_suite/HIP/runTests_voxel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
headerFilePath = scriptPath + "/../TEST_QA_IMAGES_VOXEL"
dataFilePath = scriptPath + "/../TEST_QA_IMAGES_VOXEL"
qaInputFile = scriptPath + "/../TEST_QA_IMAGES_VOXEL"
outFolderPath = os.getcwd()

# Check if folder path is empty, if it is the root folder, or if it exists, and remove its contents
def validate_and_remove_contents(path):
Expand Down Expand Up @@ -62,12 +63,12 @@ def validate_and_remove_folders(path, folder):
if path == "/*": # check if the root directory is passed to the function
print("Root folder cannot be deleted.")
exit()
if path and os.path.isdir(path + "/.."): # checks if directory string is not empty and it exists
output_folders = [folder_name for folder_name in os.listdir(path + "/..") if folder_name.startswith(folder)]
if path and os.path.isdir(path): # checks if directory string is not empty and it exists
output_folders = [folder_name for folder_name in os.listdir(path) if folder_name.startswith(folder)]

# Loop through each directory and delete it only if it exists
for folder_name in output_folders:
folder_path = os.path.join(path, "..", folder_name)
folder_path = os.path.join(path, folder_name)
if os.path.isdir(folder_path):
shutil.rmtree(folder_path) # Delete the directory if it exists
print("Deleted directory:", folder_path)
Expand Down Expand Up @@ -332,24 +333,25 @@ def rpp_test_suite_parser_and_validator():
print("QA mode can only run with a batch size of 3.")
exit(0)

# set the output folders and number of runs based on type of test (unit test / performance test)
if(testType == 0):
if qaMode:
outFilePath = scriptPath + "/../QA_RESULTS_HIP_VOXEL_" + timestamp
outFilePath = outFolderPath + "/QA_RESULTS_HIP_VOXEL_" + timestamp
else:
outFilePath = scriptPath + "/../OUTPUT_VOXEL_HIP_" + timestamp
outFilePath = outFolderPath + "/OUTPUT_VOXEL_HIP_" + timestamp
numRuns = 1
elif(testType == 1):
if "--num_runs" not in sys.argv:
numRuns = 100 #default numRuns for running performance tests
outFilePath = scriptPath + "/../OUTPUT_PERFORMANCE_LOGS_HIP_VOXEL_" + timestamp
outFilePath = outFolderPath + "/OUTPUT_PERFORMANCE_LOGS_HIP_VOXEL_" + timestamp
else:
print("Invalid TEST_TYPE specified. TEST_TYPE should be 0/1 (0 = Unittests / 1 = Performancetests)")
exit()

if preserveOutput == 0:
validate_and_remove_folders(scriptPath, "OUTPUT_VOXEL_HIP")
validate_and_remove_folders(scriptPath, "QA_RESULTS_HIP_VOXEL")
validate_and_remove_folders(scriptPath, "OUTPUT_PERFORMANCE_LOGS_HIP_VOXEL")
validate_and_remove_folders(outFolderPath, "OUTPUT_VOXEL_HIP")
validate_and_remove_folders(outFolderPath, "QA_RESULTS_HIP_VOXEL")
validate_and_remove_folders(outFolderPath, "OUTPUT_PERFORMANCE_LOGS_HIP_VOXEL")

os.mkdir(outFilePath)
loggingFolder = outFilePath
Expand Down
20 changes: 11 additions & 9 deletions utilities/test_suite/HOST/runAudioTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

scriptPath = os.path.dirname(os.path.realpath(__file__))
inFilePath = scriptPath + "/../TEST_AUDIO_FILES/three_samples_single_channel_src1"
outFolderPath = os.getcwd()
caseMin = 0
caseMax = 2

Expand Down Expand Up @@ -65,12 +66,12 @@ def validate_and_remove_folders(path, folder):
if path == "/*": # check if the root directory is passed to the function
print("Root folder cannot be deleted.")
exit(0)
if path and os.path.isdir(path + "/.."): # checks if directory string is not empty and it exists
output_folders = [folder_name for folder_name in os.listdir(path + "/..") if folder_name.startswith(folder)]
if path and os.path.isdir(path): # checks if directory string is not empty and it exists
output_folders = [folder_name for folder_name in os.listdir(path) if folder_name.startswith(folder)]

# Loop through each directory and delete it only if it exists
for folder_name in output_folders:
folder_path = os.path.join(path, "..", folder_name)
folder_path = os.path.join(path, folder_name)
if os.path.isdir(folder_path):
shutil.rmtree(folder_path) # Delete the directory if it exists
print("Deleted directory:", folder_path)
Expand Down Expand Up @@ -190,21 +191,22 @@ def rpp_test_suite_parser_and_validator():
print("WARNING: QA Mode cannot be run with testType = 1 (performance tests). Resetting testType to 0")
testType = 0

if preserveOutput == 0:
validate_and_remove_folders(scriptPath, "QA_RESULTS_AUDIO_HOST")
validate_and_remove_folders(scriptPath, "OUTPUT_PERFORMANCE_AUDIO_LOGS_HOST")

# set the output folders and number of runs based on type of test (unit test / performance test)
if(testType == 0):
outFilePath = scriptPath + "/../QA_RESULTS_AUDIO_HOST_" + timestamp
outFilePath = outFolderPath + "/QA_RESULTS_AUDIO_HOST_" + timestamp
numRuns = 1
elif(testType == 1):
if "--num_runs" not in sys.argv:
numRuns = 100 #default numRuns for running performance tests
outFilePath = scriptPath + "/../OUTPUT_PERFORMANCE_AUDIO_LOGS_HOST_" + timestamp
outFilePath = outFolderPath + "/OUTPUT_PERFORMANCE_AUDIO_LOGS_HOST_" + timestamp
else:
print("Invalid TEST_TYPE specified. TEST_TYPE should be 0/1 (0 = QA tests / 1 = Performance tests)")
exit(0)

if preserveOutput == 0:
validate_and_remove_folders(outFolderPath, "QA_RESULTS_AUDIO_HOST")
validate_and_remove_folders(outFolderPath, "OUTPUT_PERFORMANCE_AUDIO_LOGS_HOST")

os.mkdir(outFilePath)
loggingFolder = outFilePath
dstPath = outFilePath
Expand Down
24 changes: 13 additions & 11 deletions utilities/test_suite/HOST/runTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
inFilePath2 = scriptPath + "/../TEST_IMAGES/three_images_mixed_src2"
ricapInFilePath = scriptPath + "/../TEST_IMAGES/three_images_150x150_src1"
qaInputFile = scriptPath + "/../TEST_IMAGES/three_images_mixed_src1"
outFolderPath = os.getcwd()

# Checks if the folder path is empty, or is it a root folder, or if it exists, and remove its contents
def validate_and_remove_files(path):
Expand Down Expand Up @@ -66,12 +67,12 @@ def validate_and_remove_folders(path, folder):
if path == "/*": # check if the root directory is passed to the function
print("Root folder cannot be deleted.")
exit()
if path and os.path.isdir(path + "/.."): # checks if directory string is not empty and it exists
output_folders = [folder_name for folder_name in os.listdir(path + "/..") if folder_name.startswith(folder)]
if path and os.path.isdir(path): # checks if directory string is not empty and it exists
output_folders = [folder_name for folder_name in os.listdir(path) if folder_name.startswith(folder)]

# Loop through each directory and delete it only if it exists
for folder_name in output_folders:
folder_path = os.path.join(path, "..", folder_name)
folder_path = os.path.join(path, folder_name)
if os.path.isdir(folder_path):
shutil.rmtree(folder_path) # Delete the directory if it exists
print("Deleted directory:", folder_path)
Expand Down Expand Up @@ -294,29 +295,30 @@ def rpp_test_suite_parser_and_validator():
batchSize = args.batch_size
roiList = ['0', '0', '0', '0'] if args.roi is None else args.roi

if preserveOutput == 0:
validate_and_remove_folders(scriptPath, "OUTPUT_IMAGES_HOST")
validate_and_remove_folders(scriptPath, "QA_RESULTS_HOST")
validate_and_remove_folders(scriptPath, "OUTPUT_PERFORMANCE_LOGS_HOST")

if qaMode and batchSize != 3:
print("QA mode can only run with a batch size of 3.")
exit(0)

# set the output folders and number of runs based on type of test (unit test / performance test)
if(testType == 0):
if qaMode:
outFilePath = scriptPath + "/../QA_RESULTS_HOST_" + timestamp
outFilePath = outFolderPath + "/QA_RESULTS_HOST_" + timestamp
else:
outFilePath = scriptPath + "/../OUTPUT_IMAGES_HOST_" + timestamp
outFilePath = outFolderPath + "/OUTPUT_IMAGES_HOST_" + timestamp
numRuns = 1
elif(testType == 1):
if "--num_runs" not in sys.argv:
numRuns = 1000 #default numRuns for running performance tests
outFilePath = scriptPath + "/../OUTPUT_PERFORMANCE_LOGS_HOST_" + timestamp
outFilePath = outFolderPath + "/OUTPUT_PERFORMANCE_LOGS_HOST_" + timestamp
else:
print("Invalid TEST_TYPE specified. TEST_TYPE should be 0/1 (0 = Unittests / 1 = Performancetests)")
exit()

if preserveOutput == 0:
validate_and_remove_folders(outFolderPath, "OUTPUT_IMAGES_HOST")
validate_and_remove_folders(outFolderPath, "QA_RESULTS_HOST")
validate_and_remove_folders(outFolderPath, "OUTPUT_PERFORMANCE_LOGS_HOST")

os.mkdir(outFilePath)
loggingFolder = outFilePath
dstPath = outFilePath
Expand Down
19 changes: 10 additions & 9 deletions utilities/test_suite/HOST/runTests_voxel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
headerFilePath = scriptPath + "/../TEST_QA_IMAGES_VOXEL"
dataFilePath = scriptPath + "/../TEST_QA_IMAGES_VOXEL"
qaInputFile = scriptPath + "/../TEST_QA_IMAGES_VOXEL"
outFolderPath = os.getcwd()

# Check if folder path is empty, if it is the root folder, or if it exists, and remove its contents
def validate_and_remove_contents(path):
Expand Down Expand Up @@ -62,12 +63,12 @@ def validate_and_remove_folders(path, folder):
if path == "/*": # check if the root directory is passed to the function
print("Root folder cannot be deleted.")
exit()
if path and os.path.isdir(path + "/.."): # checks if directory string is not empty and it exists
output_folders = [folder_name for folder_name in os.listdir(path + "/..") if folder_name.startswith(folder)]
if path and os.path.isdir(path): # checks if directory string is not empty and it exists
output_folders = [folder_name for folder_name in os.listdir(path) if folder_name.startswith(folder)]

# Loop through each directory and delete it only if it exists
for folder_name in output_folders:
folder_path = os.path.join(path, "..", folder_name)
folder_path = os.path.join(path, folder_name)
if os.path.isdir(folder_path):
shutil.rmtree(folder_path) # Delete the directory if it exists
print("Deleted directory:", folder_path)
Expand Down Expand Up @@ -256,22 +257,22 @@ def rpp_test_suite_parser_and_validator():
# set the output folders and number of runs based on type of test (unit test / performance test)
if(testType == 0):
if qaMode:
outFilePath = os.path.join(scriptPath + "/../QA_RESULTS_HOST_VOXEL_" + timestamp)
outFilePath = os.path.join(outFolderPath + "/QA_RESULTS_HOST_VOXEL_" + timestamp)
else:
outFilePath = os.path.join(scriptPath + "/../OUTPUT_VOXEL_HOST_" + timestamp)
outFilePath = os.path.join(outFolderPath + "/OUTPUT_VOXEL_HOST_" + timestamp)
numRuns = 1
elif(testType == 1):
if "--num_runs" not in sys.argv:
numRuns = 100 #default numRuns for running performance tests
outFilePath = os.path.join(scriptPath + "/../OUTPUT_PERFORMANCE_LOGS_HOST_VOXEL_" + timestamp)
outFilePath = os.path.join(outFolderPath + "/OUTPUT_PERFORMANCE_LOGS_HOST_VOXEL_" + timestamp)
else:
print("Invalid TEST_TYPE specified. TEST_TYPE should be 0/1 (0 = Unittests / 1 = Performancetests)")
exit()

if preserveOutput == 0:
validate_and_remove_folders(scriptPath, "OUTPUT_VOXEL_HOST")
validate_and_remove_folders(scriptPath, "QA_RESULTS_HOST_VOXEL")
validate_and_remove_folders(scriptPath, "OUTPUT_PERFORMANCE_LOGS_HOST_VOXEL")
validate_and_remove_folders(outFolderPath, "OUTPUT_VOXEL_HOST")
validate_and_remove_folders(outFolderPath, "QA_RESULTS_HOST_VOXEL")
validate_and_remove_folders(outFolderPath, "OUTPUT_PERFORMANCE_LOGS_HOST_VOXEL")

os.mkdir(outFilePath)
loggingFolder = outFilePath
Expand Down

0 comments on commit 6724cb9

Please sign in to comment.