This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new 25ab679  [test] Avoid mod 0, resolve an exception like 'Floating point 
exception'.
25ab679 is described below

commit 25ab6797b72715c90abc0bb5b68e68fdbf021137
Author: YangSong01 <[email protected]>
AuthorDate: Mon Nov 25 12:55:55 2019 +0800

    [test] Avoid mod 0, resolve an exception like 'Floating point exception'.
    
    'kMaxLimit' may be 0, then an exception reported like 'Floating point 
exception'.
    Here we cannot mod 0, if 'KMaxLimit' is 0, we're not taking mod any
    more, we set 'kLimit' to 0 directly.
    
    Change-Id: Ia45372ff5e5460d220b7a3040de2e499541bf37f
    Reviewed-on: http://gerrit.cloudera.org:8080/14793
    Tested-by: Kudu Jenkins
    Reviewed-by: Alexey Serbin <[email protected]>
    Reviewed-by: Grant Henke <[email protected]>
---
 src/kudu/tserver/tablet_server-test.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/kudu/tserver/tablet_server-test.cc 
b/src/kudu/tserver/tablet_server-test.cc
index 8d0590b..a739056 100644
--- a/src/kudu/tserver/tablet_server-test.cc
+++ b/src/kudu/tserver/tablet_server-test.cc
@@ -2495,7 +2495,8 @@ TEST_F(TabletServerTest, TestRandomizedScanLimits) {
     const int kMaxLimit = kNumRows * static_cast<double>(0.01 * i);
 
     // Get a random limit, capped by the max, inclusive.
-    const int kLimit = rand() % kMaxLimit + 1;
+    // "kMaxLimit" cannot be 0, if it's 0, we set "kLimit" to 1 directly.
+    const int kLimit = kMaxLimit == 0 ? 1 : rand() % kMaxLimit + 1;
     LOG(INFO) << "Scanning with a limit of " << kLimit;
 
     ScanRequestPB req;

Reply via email to