from __future__ import print_function
+import sys
import os
import unittest
import shlex
"tests/emerging-current_events.rules")
self.assertIsNone(files)
- @unittest.skipIf(not has_python2(), "python2 not available")
- def test_run_python2(self):
+ def test_run(self):
old_path = os.getcwd()
try:
os.chdir(os.path.dirname(os.path.realpath(__file__)))
shutil.rmtree("tmp")
os.makedirs("./tmp/rules")
subprocess.check_call(
- ["/usr/bin/env", "python2",
+ ["/usr/bin/env", sys.executable,
"../bin/suricata-update",
+ "-D", "./tmp",
+ "-v",
"-c", "./update.yaml",
"--url",
"file://%s/emerging.rules.tar.gz" % (
],
env={
"PATH": os.getenv("PATH"),
- "SOURCE_DIRECTORY": "/tmp",
- },
- stdout=open("./tmp/stdout", "wb"),
- stderr=open("./tmp/stderr", "wb"),
- )
- shutil.rmtree("tmp")
- except:
- if os.path.exists("./tmp/stdout"):
- print("STDOUT")
- print(open("./tmp/stdout").read())
- if os.path.exists("./tmp/stderr"):
- print("STDERR")
- print(open("./tmp/stderr").read())
- raise
- finally:
- os.chdir(old_path)
-
- @unittest.skipIf(not has_python3(), "python3 not available")
- def test_run_python3(self):
- old_path = os.getcwd()
- try:
- os.chdir(os.path.dirname(os.path.realpath(__file__)))
- if os.path.exists("./tmp"):
- shutil.rmtree("tmp")
- os.makedirs("./tmp/rules")
- subprocess.check_call(
- ["/usr/bin/env", "python2",
- "../bin/suricata-update",
- "-c", "./update.yaml",
- "--url",
- "file://%s/emerging.rules.tar.gz" % (
- os.getcwd()),
- "--local", "./rule-with-unicode.rules",
- "--force",
- "--output", "./tmp/rules/",
- "--yaml-fragment", "./tmp/suricata-rules.yaml",
- "--sid-msg-map", "./tmp/sid-msg.map",
- "--sid-msg-map-2", "./tmp/sid-msg-v2.map",
- "--no-test",
- "--reload-command", "true",
- ],
- env={
- "PATH": os.getenv("PATH"),
- "SOURCE_DIRECTORY": "/tmp",
},
stdout=open("./tmp/stdout", "wb"),
stderr=open("./tmp/stderr", "wb"),