[Tarantool-patches] [PATCH 07/11] test: fix signed integer overflow in vclock test

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Fri Jun 5 02:43:14 MSK 2020


Vclock unit test had a test where all vclock components were close
to INT64_MAX. The sum was bigger than INT64_MAX, and it caused
overflow in vclock's signature.

The patch reduces order of the LSNs in this test so their sum does
not overflow anymore.

Part of #4609
---
 test/unit/vclock.cc     | 28 ++++++++++++++--------------
 test/unit/vclock.result |  2 +-
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/test/unit/vclock.cc b/test/unit/vclock.cc
index 15e9f9379..cbda7f4fc 100644
--- a/test/unit/vclock.cc
+++ b/test/unit/vclock.cc
@@ -275,20 +275,20 @@ test_tostring()
 	test(arg(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15),
 	     "{1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, "
 	      "9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15}");
-	test(arg(9223372036854775000, 9223372036854775001, 9223372036854775002,
-		 9223372036854775003, 9223372036854775004, 9223372036854775005,
-		 9223372036854775006, 9223372036854775007, 9223372036854775008,
-		 9223372036854775009, 9223372036854775010, 9223372036854775011,
-		 9223372036854775012, 9223372036854775013, 9223372036854775014,
-		 9223372036854775015),
-	     "{0: 9223372036854775000, 1: 9223372036854775001, "
-	      "2: 9223372036854775002, 3: 9223372036854775003, "
-	      "4: 9223372036854775004, 5: 9223372036854775005, "
-	      "6: 9223372036854775006, 7: 9223372036854775007, "
-	      "8: 9223372036854775008, 9: 9223372036854775009, "
-	     "10: 9223372036854775010, 11: 9223372036854775011, "
-	     "12: 9223372036854775012, 13: 9223372036854775013, "
-	     "14: 9223372036854775014, 15: 9223372036854775015}");
+	test(arg(9223372054775000, 9223372054775001, 9223372054775002,
+		 9223372054775003, 9223372054775004, 9223372054775005,
+		 9223372054775006, 9223372054775007, 9223372054775008,
+		 9223372054775009, 9223372054775010, 9223372054775011,
+		 9223372054775012, 9223372054775013, 9223372054775014,
+		 9223372054775015),
+	     "{0: 9223372054775000, 1: 9223372054775001, "
+	      "2: 9223372054775002, 3: 9223372054775003, "
+	      "4: 9223372054775004, 5: 9223372054775005, "
+	      "6: 9223372054775006, 7: 9223372054775007, "
+	      "8: 9223372054775008, 9: 9223372054775009, "
+	     "10: 9223372054775010, 11: 9223372054775011, "
+	     "12: 9223372054775012, 13: 9223372054775013, "
+	     "14: 9223372054775014, 15: 9223372054775015}");
 
 	footer();
 	return check_plan();
diff --git a/test/unit/vclock.result b/test/unit/vclock.result
index 2ca741bbd..610ecbe78 100644
--- a/test/unit/vclock.result
+++ b/test/unit/vclock.result
@@ -92,7 +92,7 @@ ok 2 - subtests
     ok 5 - tostring (10, 15, 20) => {0: 10, 1: 15, 2: 20}
     ok 6 - tostring (10, -1, 15, -1, 20) => {0: 10, 2: 15, 4: 20}
     ok 7 - tostring (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) => {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15}
-    ok 8 - tostring (9223372036854775000, 9223372036854775001, 9223372036854775002, 9223372036854775003, 9223372036854775004, 9223372036854775005, 9223372036854775006, 9223372036854775007, 9223372036854775008, 9223372036854775009, 9223372036854775010, 9223372036854775011, 9223372036854775012, 9223372036854775013, 9223372036854775014, 9223372036854775015) => {0: 9223372036854775000, 1: 9223372036854775001, 2: 9223372036854775002, 3: 9223372036854775003, 4: 9223372036854775004, 5: 9223372036854775005, 6: 9223372036854775006, 7: 9223372036854775007, 8: 9223372036854775008, 9: 9223372036854775009, 10: 9223372036854775010, 11: 9223372036854775011, 12: 9223372036854775012, 13: 9223372036854775013, 14: 9223372036854775014, 15: 9223372036854775015}
+    ok 8 - tostring (9223372054775000, 9223372054775001, 9223372054775002, 9223372054775003, 9223372054775004, 9223372054775005, 9223372054775006, 9223372054775007, 9223372054775008, 9223372054775009, 9223372054775010, 9223372054775011, 9223372054775012, 9223372054775013, 9223372054775014, 9223372054775015) => {0: 9223372054775000, 1: 9223372054775001, 2: 9223372054775002, 3: 9223372054775003, 4: 9223372054775004, 5: 9223372054775005, 6: 9223372054775006, 7: 9223372054775007, 8: 9223372054775008, 9: 9223372054775009, 10: 9223372054775010, 11: 9223372054775011, 12: 9223372054775012, 13: 9223372054775013, 14: 9223372054775014, 15: 9223372054775015}
 	*** test_tostring: done ***
 ok 3 - subtests
     1..12
-- 
2.21.1 (Apple Git-122.3)



More information about the Tarantool-patches mailing list