accept validations.yml without tests and validations, to simply run and log trace

This commit is contained in:
Raphael Bauduin 2015-06-01 10:19:30 -07:00
parent 793f51be69
commit ded9226e2a
2 changed files with 22 additions and 20 deletions

View File

@ -62,16 +62,17 @@ for test_name in [name for name in os.listdir(tests_dir) if os.path.isdir(os.pat
# Run validations # Run validations
with open(validation_file, 'r') as f: with open(validation_file, 'r') as f:
validations = load(f) validations = load(f)
for k in validations.keys(): if validations!=None:
# Identify checker class for k in validations.keys():
name = k.title().replace("_","")+"Checker" # Identify checker class
klass= globals()[name] name = k.title().replace("_","")+"Checker"
# instantiate checker with validations and test_name klass= globals()[name]
checker = klass(validations, test_name, destDir) # instantiate checker with validations and test_name
if checker.check(): checker = klass(validations, test_name, destDir)
print checker.logs if checker.check():
else: print checker.logs
print checker.logs else:
print checker.logs

View File

@ -141,16 +141,17 @@ class Checker:
def check(self): def check(self):
is_ok = True is_ok = True
self.logs=self.test_id+"\n" self.logs=self.test_id+"\n"
for test in self.yml: if self.yml!=None:
name=test["test"].title().replace("_","")+"Test" for test in self.yml:
klass = globals()[name] name=test["test"].title().replace("_","")+"Test"
r = klass(test, self.trace) klass = globals()[name]
if r.validate(): r = klass(test, self.trace)
self.logs = self.logs + " *" + self.test_id + " " + r.name() + " SUCCESS\n" if r.validate():
self.logs = self.logs + r.logs self.logs = self.logs + " *" + self.test_id + " " + r.name() + " SUCCESS\n"
else: self.logs = self.logs + r.logs
self.logs = self.logs + " *" + self.test_id + " " + r.name() + " FAIL\n" else:
self.logs = self.logs + r.logs self.logs = self.logs + " *" + self.test_id + " " + r.name() + " FAIL\n"
self.logs = self.logs + r.logs
# Runs tests based on tcptrace # Runs tests based on tcptrace
# It (in the method inherited from its parent class) instanciates the ...Test class passing it the TcptraceData instance # It (in the method inherited from its parent class) instanciates the ...Test class passing it the TcptraceData instance