import multiprocessing as mp
from collections import namedtuple
import threading
-
+import filecmp
import yaml
WIN32 = sys.platform == "win32"
return False
return True
+class FileCompareCheck:
+
+ def __init__(self, config, directory):
+ self.config = config
+ self.directory = directory
+
+ def run(self):
+ expected = os.path.join(self.directory, self.config["expected"])
+ filename = self.config["filename"]
+ if filecmp.cmp(expected, filename):
+ return True
+ else:
+ raise TestError("%s %s \nFAILED: verification failed" % (expected, filename))
class ShellCheck:
count = StatsCheck(check, self.output).run()
return count
+ @handle_exceptions
+ def perform_file_compare_checks(self, check, count, test_num, test_name):
+ count = FileCompareCheck(check, self.directory).run()
+ return count
+
def reset_count(self, dictionary):
for k in dictionary.keys():
dictionary[k] = 0
self.reset_count(count)
for check_count, check in enumerate(self.config["checks"]):
for key in check:
- if key in ["filter", "shell", "stats"]:
- func = getattr(self, "perform_{}_checks".format(key))
+ if key in ["filter", "shell", "stats", "file-compare"]:
+ func = getattr(self, "perform_{}_checks".format(key.replace("-","_")))
count = func(check=check[key], count=count,
test_num=check_count + 1, test_name=os.path.basename(self.directory))
else: