class ShellCheck:
- def __init__(self, config):
+ def __init__(self, config, env):
self.config = config
+ self.env = env
def run(self):
if not self.config or "args" not in self.config:
if WIN32:
print("skipping shell check on windows")
return True;
- output = subprocess.check_output(self.config["args"], shell=True)
+ output = subprocess.check_output(self.config["args"], shell=True, env=self.env)
if "expect" in self.config:
return str(self.config["expect"]) == output.decode().strip()
return True
glob.glob(os.path.join(self.directory, "*.pcapng")):
raise UnsatisfiedRequirementError("No pcap file found")
+ def build_env(self):
+ env = os.environ.copy()
+ env["SRCDIR"] = self.cwd
+ env["TZ"] = "UTC"
+ env["TEST_DIR"] = self.directory
+ env["OUTPUT_DIR"] = self.output
+ env["ASAN_OPTIONS"] = "detect_leaks=1"
+ return env
+
def run(self, outdir):
if not self.force:
else:
args = self.default_args()
- extraenv = {
- # The suricata source directory.
- "SRCDIR": self.cwd,
- "TZ": "UTC",
- "TEST_DIR": self.directory,
- "OUTPUT_DIR": self.output,
- "ASAN_OPTIONS": "detect_leaks=1",
- }
- env = os.environ.copy()
- env.update(extraenv)
+ env = self.build_env()
if "count" in self.config:
count = self.config["count"]
@handle_exceptions
def perform_shell_checks(self, check, count, test_num, test_name):
- count = ShellCheck(check).run()
+ count = ShellCheck(check, self.build_env()).run()
return count
@handle_exceptions