Skip to content

Commit e82ee81

Browse files
committed
[#3163] relax time-senstitive tests in dhcpsrv
1 parent 55b6da5 commit e82ee81

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/lib/dhcpsrv/testutils/test_utils.cc

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

77
#include <config.h>
8-
#include "test_utils.h"
8+
99
#include <asiolink/io_address.h>
10+
#include <dhcpsrv/testutils/test_utils.h>
11+
#include <testutils/gtest_utils.h>
12+
1013
#include <gtest/gtest.h>
11-
#include <sstream>
12-
#include <sys/types.h>
1314
#include <sys/stat.h>
15+
#include <sys/types.h>
1416
#include <unistd.h>
1517

1618
using namespace std;
@@ -50,8 +52,12 @@ detailCompareLease(const Lease4Ptr& first, const Lease4Ptr& second) {
5052
// else here would mean that both leases do not have client_id_
5153
// which makes them equal in that regard. It is ok.
5254
}
53-
EXPECT_EQ(first->valid_lft_, second->valid_lft_);
54-
EXPECT_EQ(first->cltt_, second->cltt_);
55+
56+
// Since the initial time values were set, one second could have ticked,
57+
// so allow one second of margin error.
58+
EXPECT_EQ_MARGIN(first->valid_lft_, second->valid_lft_, 1);
59+
EXPECT_EQ_MARGIN(first->cltt_, second->cltt_, 1);
60+
5561
EXPECT_EQ(first->subnet_id_, second->subnet_id_);
5662
EXPECT_EQ(first->pool_id_, second->pool_id_);
5763
EXPECT_EQ(first->fqdn_fwd_, second->fqdn_fwd_);
@@ -83,9 +89,13 @@ detailCompareLease(const Lease6Ptr& first, const Lease6Ptr& second) {
8389
ASSERT_TRUE(first->duid_);
8490
ASSERT_TRUE(second->duid_);
8591
EXPECT_TRUE(*first->duid_ == *second->duid_);
86-
EXPECT_EQ(first->preferred_lft_, second->preferred_lft_);
87-
EXPECT_EQ(first->valid_lft_, second->valid_lft_);
88-
EXPECT_EQ(first->cltt_, second->cltt_);
92+
93+
// Since the initial time values were set, one second could have ticked,
94+
// so allow one second of margin error.
95+
EXPECT_EQ_MARGIN(first->preferred_lft_, second->preferred_lft_, 1);
96+
EXPECT_EQ_MARGIN(first->valid_lft_, second->valid_lft_, 1);
97+
EXPECT_EQ_MARGIN(first->cltt_, second->cltt_, 1);
98+
8999
EXPECT_EQ(first->subnet_id_, second->subnet_id_);
90100
EXPECT_EQ(first->pool_id_, second->pool_id_);
91101
EXPECT_EQ(first->fqdn_fwd_, second->fqdn_fwd_);

0 commit comments

Comments
 (0)