summaryrefslogtreecommitdiff
path: root/src/debug.c
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2021-11-01 13:41:35 +0200
committerGitHub <noreply@github.com>2021-11-01 13:41:35 +0200
commitf1f3cceb50ac97187f9dca37b041583a5f6ee6aa (patch)
tree552e89e51adfaff8a2b20a0bd96eb3a9722c86bd /src/debug.c
parent155c29100663c15b26938663aed1405ad3b482cd (diff)
downloadredis-f1f3cceb50ac97187f9dca37b041583a5f6ee6aa.tar.gz
fix valgrind issues with long double module test (#9709)
The module test in reply.tcl was introduced by #8521 but didn't run until recently (see #9639) and then it started failing with valgrind. This is because valgrind uses 64 bit long double (unlike most other platforms that have at least 80 bits) But besides valgrind, the tests where also incompatible with ARM32, which also uses 64 bit long doubles. We now use appropriate value to avoid issues with either valgrind or ARM32 In all the double tests, i use 3.141, which is safe since since addReplyDouble uses `%.17Lg` which is able to represent this value without adding any digits due to precision loss. In the long double, since we use `%.17Lf` in ld2string, it preserves 17 significant digits, rather than 17 digit after the decimal point (like in `%.17Lg`). So to make these similar, i use value lower than 1 (no digits left of the period) Lastly, we have the same issue with TCL (no long doubles) so we read raw protocol in that test. Note that the only error before this fix (in both valgrind and ARM32 is this: ``` *** [err]: RM_ReplyWithLongDouble: a float reply in tests/unit/moduleapi/reply.tcl Expected '3.141' to be equal to '3.14100000000000001' (context: type eval line 2 cmd {assert_equal 3.141 [r rw.longdouble 3.141]} proc ::test) ``` so the changes to debug.c and scripting.tcl aren't really needed, but i consider them a cleanup (i.e. scripting.c validated a different constant than the one that's sent to it from debug.c). Another unrelated change is to add the RESP version to the repeated tests in reply.tcl
Diffstat (limited to 'src/debug.c')
-rw-r--r--src/debug.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/debug.c b/src/debug.c
index ccaf93758..114b1bd92 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -723,7 +723,7 @@ NULL
} else if (!strcasecmp(name,"integer")) {
addReplyLongLong(c,12345);
} else if (!strcasecmp(name,"double")) {
- addReplyDouble(c,3.14159265359);
+ addReplyDouble(c,3.141);
} else if (!strcasecmp(name,"bignum")) {
addReplyBigNum(c,"1234567999999999999999999999999999999",37);
} else if (!strcasecmp(name,"null")) {