diff --git a/src/mpIterator.py b/src/mpIterator.py index 8eee00b..30c4731 100755 --- a/src/mpIterator.py +++ b/src/mpIterator.py @@ -65,7 +65,7 @@ for test_name in [name for name in os.listdir(tests_dir) if os.path.isdir(os.pat name = k.title().replace("_","")+"Checker" klass= globals()[name] # instantiate checker with validations and test_name - checker = klass(validations, test_name) + checker = klass(validations, test_name, destDir) if checker.check(): print checker.logs else: diff --git a/src/mpValidations.py b/src/mpValidations.py index 58782fd..c8ff105 100644 --- a/src/mpValidations.py +++ b/src/mpValidations.py @@ -21,6 +21,14 @@ class Validation: class MinValueValidation(Validation): def validate(self, value): return self.compared<=value +# checks a value passed is greater or equal (generic) +class MaxValueValidation(Validation): + def validate(self, value): + return self.compared>=value +# checks a value passed is greater or equal (generic) +class ExactValueValidation(Validation): + def validate(self, value): + return self.compared==value # individual flow validation (specific) # gets flow_spec = (index, flows) where index is the index of the flow to validate, and flows is the array of flows @@ -45,14 +53,15 @@ class TcptraceTest: def validate(self): is_ok = True self.logs = "" + print self.yml for val in self.yml: + print val["name"] tested_value = self.get_tested_value(val) klass_name=val["name"].title().replace("_","")+"Validation" tester_klass=globals()[klass_name] tester = tester_klass(val) if tester.validate(tested_value): self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" OK\n" - return True else: self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" FAILS\n" is_ok = False @@ -75,9 +84,9 @@ class FlowsTest(TcptraceTest): # Runs tests based on tcptrace class TcptraceChecker: - def __init__(self, yml, test_id): + def __init__(self, yml, test_id, destDir): self.yml = yml["tcptrace"] - self.trace = TcptraceData("/tmp/dest/client.pcap") + self.trace = TcptraceData(destDir+"/client.pcap") self.test_id = test_id def check(self): is_ok = True diff --git a/src/tests/base/validation.yml b/src/tests/base/validation.yml index 9a5725e..07f8c80 100644 --- a/src/tests/base/validation.yml +++ b/src/tests/base/validation.yml @@ -3,8 +3,12 @@ tcptrace: validations: - name: "min_value" target: 2 + - name: "max_value" + target: 4 + - name: "exact_value" + target: 4 - test: "flows" validations: - name: "min_delay" index: 1 - target: 29000 + target: 2000