mirror of
https://github.com/ivre/masscanned.git
synced 2025-10-02 06:38:21 +00:00
Add check for masscanned panic in python tests
This commit is contained in:
parent
bf1a2c7429
commit
843729b961
2 changed files with 9 additions and 4 deletions
|
@ -44,9 +44,13 @@ def test(f):
|
||||||
KO = "\033[1m\033[1;%dmKO\033[0m" % 31
|
KO = "\033[1m\033[1;%dmKO\033[0m" % 31
|
||||||
fname = f.__name__.ljust(50, ".")
|
fname = f.__name__.ljust(50, ".")
|
||||||
|
|
||||||
def w():
|
def w(m):
|
||||||
try:
|
try:
|
||||||
|
# check that masscanned is still running
|
||||||
|
assert(m.poll() is None), "masscanned not running"
|
||||||
f()
|
f()
|
||||||
|
# check that masscanned is still running
|
||||||
|
assert(m.poll() is None), "masscanned terminated unexpectedly"
|
||||||
LOG.info("{}{}".format(fname, OK))
|
LOG.info("{}{}".format(fname, OK))
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
LOG.error("{}{}: {}".format(fname, KO, e))
|
LOG.error("{}{}: {}".format(fname, KO, e))
|
||||||
|
@ -56,11 +60,12 @@ def test(f):
|
||||||
return w
|
return w
|
||||||
|
|
||||||
|
|
||||||
def test_all():
|
def test_all(m):
|
||||||
global ERRORS, TESTS
|
global ERRORS, TESTS
|
||||||
# execute tests
|
# execute tests
|
||||||
for t in TESTS:
|
for t in TESTS:
|
||||||
t()
|
# perform unit test
|
||||||
|
t(m)
|
||||||
LOG.info(f"\033[1mRan {len(TESTS)} tests with {len(ERRORS)} errors\033[0m")
|
LOG.info(f"\033[1mRan {len(TESTS)} tests with {len(ERRORS)} errors\033[0m")
|
||||||
return len(ERRORS)
|
return len(ERRORS)
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ masscanned = subprocess.Popen(
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = test_all()
|
result = test_all(masscanned)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
result = -1
|
result = -1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue