From 66753a8b4a5167f72667c81148b904ec48ab7501 Mon Sep 17 00:00:00 2001 From: Nischal Sheth Date: Mon, 29 Feb 2016 10:26:02 -0800 Subject: [PATCH] Make service_chain_test more robust Change-Id: Ib9b6b81fec3333cd52b5b4dbf81cd22a7b9ea261 Partial-Bug: 1548570 --- src/bgp/test/service_chain_test.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/bgp/test/service_chain_test.cc b/src/bgp/test/service_chain_test.cc index 791eba4717c..8e904ec1ef6 100644 --- a/src/bgp/test/service_chain_test.cc +++ b/src/bgp/test/service_chain_test.cc @@ -618,18 +618,24 @@ class ServiceChainTest : public ::testing::Test { return dynamic_cast(db_entry); } - BgpRoute *VerifyRouteExists(const string &instance, const string &prefix) { - TASK_UTIL_EXPECT_TRUE(RouteLookup(instance, prefix) != NULL); + bool CheckRouteExists(const string &instance, const string &prefix) { + task_util::TaskSchedulerLock lock; BgpRoute *rt = RouteLookup(instance, prefix); - if (rt == NULL) { - return NULL; - } - TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); - return rt; + return (rt && rt->BestPath() != NULL); + } + + void VerifyRouteExists(const string &instance, const string &prefix) { + TASK_UTIL_EXPECT_TRUE(CheckRouteExists(instance, prefix)); + } + + bool CheckRouteNoExists(const string &instance, const string &prefix) { + task_util::TaskSchedulerLock lock; + BgpRoute *rt = RouteLookup(instance, prefix); + return !rt; } void VerifyRouteNoExists(const string &instance, const string &prefix) { - TASK_UTIL_EXPECT_TRUE(RouteLookup(instance, prefix) == NULL); + TASK_UTIL_EXPECT_TRUE(CheckRouteNoExists(instance, prefix)); } void VerifyRouteIsDeleted(const string &instance, const string &prefix) {