未验证 提交 010f2caa 编写于 作者: C Chen Weihang 提交者: GitHub

try to fix reader and signal test failed (#30960)

上级 3ba69809
...@@ -68,7 +68,7 @@ TEST(BlockingQueue, SenderBlockingTest) { ...@@ -68,7 +68,7 @@ TEST(BlockingQueue, SenderBlockingTest) {
++send_count; ++send_count;
} }
}); });
std::this_thread::sleep_for(std::chrono::milliseconds(200)); std::this_thread::sleep_for(std::chrono::milliseconds(1000));
q.Close(); q.Close();
sender.join(); sender.join();
EXPECT_EQ(send_count, queue_cap); EXPECT_EQ(send_count, queue_cap);
......
...@@ -70,16 +70,26 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase): ...@@ -70,16 +70,26 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase):
core._set_process_signal_handler() core._set_process_signal_handler()
os.kill(os.getpid(), signal.SIGSEGV) os.kill(os.getpid(), signal.SIGSEGV)
def try_except_exit():
exception = None exception = None
try: try:
test_process = multiprocessing.Process(target=__test_process__) test_process = multiprocessing.Process(target=__test_process__)
test_process.start() test_process.start()
set_child_signal_handler(id(self), test_process.pid) set_child_signal_handler(id(self), test_process.pid)
time.sleep(10) time.sleep(5)
except SystemError as ex: except SystemError as ex:
self.assertIn("Segmentation fault", cpt.get_exception_message(ex)) self.assertIn("Segmentation fault",
cpt.get_exception_message(ex))
exception = ex exception = ex
return exception
try_time = 10
exception = None
for i in range(try_time):
exception = try_except_exit()
if exception is not None:
break
self.assertIsNotNone(exception) self.assertIsNotNone(exception)
...@@ -88,16 +98,25 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase): ...@@ -88,16 +98,25 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase):
core._set_process_signal_handler() core._set_process_signal_handler()
os.kill(os.getpid(), signal.SIGBUS) os.kill(os.getpid(), signal.SIGBUS)
def try_except_exit():
exception = None exception = None
try: try:
test_process = multiprocessing.Process(target=__test_process__) test_process = multiprocessing.Process(target=__test_process__)
test_process.start() test_process.start()
set_child_signal_handler(id(self), test_process.pid) set_child_signal_handler(id(self), test_process.pid)
time.sleep(10) time.sleep(5)
except SystemError as ex: except SystemError as ex:
self.assertIn("Bus error", cpt.get_exception_message(ex)) self.assertIn("Bus error", cpt.get_exception_message(ex))
exception = ex exception = ex
return exception
try_time = 10
exception = None
for i in range(try_time):
exception = try_except_exit()
if exception is not None:
break
self.assertIsNotNone(exception) self.assertIsNotNone(exception)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册