You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.4 KiB
Python
81 lines
2.4 KiB
Python
import filecmp
|
|
import os.path
|
|
import numpy as np
|
|
|
|
def are_dir_trees_equal(dir1, dir2):
|
|
"""
|
|
Compare two directories recursively. Files in each directory are
|
|
assumed to be equal if their names and contents are equal.
|
|
|
|
@param dir1: First directory path
|
|
@param dir2: Second directory path
|
|
|
|
@return: True if the directory trees are the same and
|
|
there were no errors while accessing the directories or files,
|
|
False otherwise.
|
|
"""
|
|
|
|
dirs_cmp = filecmp.dircmp(dir1, dir2)
|
|
if len(dirs_cmp.left_only)>0 or len(dirs_cmp.right_only)>0 or \
|
|
len(dirs_cmp.funny_files)>0:
|
|
print("error aca :(")
|
|
return False
|
|
(_, mismatch, errors) = filecmp.cmpfiles(
|
|
dir1, dir2, dirs_cmp.common_files, shallow=False)
|
|
if (len(mismatch)>0 or len(errors)>0) and dirs_cmp.common_files[0] != 'config.ini':
|
|
print(dir1)
|
|
print(dir2)
|
|
#print(dirs_cmp.common_files)
|
|
print(mismatch)
|
|
print(errors)
|
|
print("error aca 2 :(")
|
|
|
|
return False
|
|
print(dirs_cmp.common_dirs)
|
|
for common_dir in dirs_cmp.common_dirs:
|
|
print(common_dir)
|
|
new_dir1 = os.path.join(dir1, common_dir)
|
|
new_dir2 = os.path.join(dir2, common_dir)
|
|
are_equal = are_dir_trees_equal(new_dir1, new_dir2)
|
|
if not are_equal:
|
|
print("error aca 3 :(")
|
|
return False
|
|
print("todo ok!")
|
|
print(dir1, dir2)
|
|
return True
|
|
|
|
def equal_binaries(path_original, path):
|
|
binary_original = np.load(path_original)
|
|
|
|
binary = np.load(path)
|
|
|
|
diffs = binary_original - binary
|
|
|
|
comparisons = np.array([abs(x) < 0.001 for x in diffs]) #NO ME DA TAMPOCO CON ESTE ERROR
|
|
|
|
if comparisons.all():
|
|
return True
|
|
return False
|
|
|
|
|
|
binaries = ['Cmap', 'D', 'P', 'V']
|
|
|
|
def test():
|
|
os.chdir('../..') #LO COMENTE PARA EVITAR VOLVER A CORRERLO
|
|
#config_file = os.path.abspath("./tests/integration/conf_test.ini")
|
|
#os.system("CONFIG_FILE_PATH="+ config_file + " mpirun python mpirunner.py")
|
|
|
|
#are_equal = are_dir_trees_equal("./tests/integration/tmp_output","./test_loop")
|
|
|
|
for i in range(90):
|
|
for binary in binaries:
|
|
path = './tests/integration/tmp_output/{}/{}.npy'.format(i, binary)
|
|
path_original = './test_loop/{}/{}.npy'.format(i, binary)
|
|
|
|
if not equal_binaries(path_original, path):
|
|
print("Failure :( on {}".format(i))
|
|
return
|
|
|
|
print("Success!")
|
|
|
|
test() |