[Fix #2274] Relax return code checks for osqueryd tests (#2353)

This commit is contained in:
Teddy Reed 2016-08-12 18:02:28 -07:00 committed by GitHub
parent 381e86a931
commit 9ee90f4f2d
2 changed files with 11 additions and 7 deletions

View File

@ -437,9 +437,10 @@ def flaky(gen):
worked = gen(this) worked = gen(this)
return True return True
except Exception as e: except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info() import traceback
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] exc_type, exc_obj, tb = sys.exc_info()
exceptions.append((e, fname, exc_tb.tb_lineno)) exceptions.append((e))
print (traceback.format_tb(tb)[1])
return False return False
def wrapper(this): def wrapper(this):
for i in range(3): for i in range(3):
@ -447,12 +448,12 @@ def flaky(gen):
return True return True
i = 1 i = 1
for exc in exceptions: for exc in exceptions:
print("Test (attempt %d) %s::%s failed: %s (%s:%d)" % ( print("Test (attempt %d) %s::%s failed: %s" % (
i, i,
this.__class__.__name__, this.__class__.__name__,
gen.__name__, str(exc[0]), exc[1], exc[2])) gen.__name__, str(exc[0])))
i += 1 i += 1
raise exceptions[0][0] raise Exception(exceptions[0][0])
return wrapper return wrapper

View File

@ -90,13 +90,16 @@ class DaemonTests(test_base.ProcessGenerator, unittest.TestCase):
# An interrupt signal will cause the daemon to stop. # An interrupt signal will cause the daemon to stop.
daemon = self._run_daemon({ daemon = self._run_daemon({
"disable_watchdog": True, "disable_watchdog": True,
"ephemeral": True,
"disable_database": True,
"disable_logging": True,
}) })
self.assertTrue(daemon.isAlive()) self.assertTrue(daemon.isAlive())
# Send a SIGINT # Send a SIGINT
os.kill(daemon.pid, signal.SIGINT) os.kill(daemon.pid, signal.SIGINT)
self.assertTrue(daemon.isDead(daemon.pid, 10)) self.assertTrue(daemon.isDead(daemon.pid, 10))
self.assertEqual(daemon.retcode, 128 + signal.SIGINT) self.assertTrue(daemon.retcode in [128 + signal.SIGINT, -2])
@test_base.flaky @test_base.flaky
def test_6_logger_mode(self): def test_6_logger_mode(self):