class StatsCheck:
- def __init__(self, config):
+ def __init__(self, config, outdir):
self.config = config
+ self.outdir = outdir
def run(self):
stats = None
class FilterCheck:
- def __init__(self, config):
+ def __init__(self, config, outdir):
self.config = config
+ self.outdir = outdir
def run(self):
eve_json_path = "eve.json"
class TestRunner:
- def __init__(self, cwd, directory, suricata_config, verbose=False):
+ def __init__(self, cwd, directory, outdir, suricata_config, verbose=False):
self.cwd = cwd
self.directory = directory
self.suricata_config = suricata_config
self.verbose = verbose
- self.output = os.path.join(self.directory, "output")
+ self.output = os.path.join(outdir, "output")
# The name is just the directory name.
self.name = os.path.basename(self.directory)
subprocess.check_call(
"%s" % setup[command],
shell=True,
- cwd=os.path.join(self.directory, "output"))
+ cwd=self.output)
def check_skip(self):
if not "skip" in self.config:
"SRCDIR": self.cwd,
"TZ": "UTC",
"TEST_DIR": self.directory,
+ "OUTPUT_DIR": self.output,
"ASAN_OPTIONS": "detect_leaks=0",
}
def check(self):
pdir = os.getcwd()
- os.chdir(os.path.join(self.directory, "output"))
+ os.chdir(self.output)
try:
if "checks" in self.config:
for check in self.config["checks"]:
for key in check:
if key == "filter":
- if not FilterCheck(check[key]).run():
+ if not FilterCheck(check[key], self.output).run():
raise TestError("filter did not match: %s" % (
str(check[key])))
elif key == "shell":
"shell output did not match: %s" % (
str(check[key])))
elif key == "stats":
- if not StatsCheck(check[key]).run():
+ if not StatsCheck(check[key], self.output).run():
raise TestError("stats check did not pass")
else:
raise TestError("Unknown check type: %s" % (key))
# Old style check script.
pdir = os.getcwd()
- os.chdir(os.path.join(self.directory, "output"))
+ os.chdir(self.output)
try:
if not os.path.exists(os.path.join(self.directory, "check.sh")):
return True
help="Exit on test failure")
parser.add_argument("--dir", action="store",
help="Runs tests from custom directory")
+ parser.add_argument("--outdir", action="store",
+ help="Outputs to custom directory")
parser.add_argument("patterns", nargs="*", default=[])
args = parser.parse_args()
for dirpath in tests:
name = os.path.basename(dirpath)
+ outdir = os.path.join(dirpath, "output")
+ if args.outdir:
+ outdir = os.path.join(args.outdir, name)
+
test_runner = TestRunner(
- cwd, dirpath, suricata_config, args.verbose)
+ cwd, dirpath, outdir, suricata_config, args.verbose)
try:
if test_runner.run():
passed += 1