Bug #62572 "make test" fails on "my_vsnprintf"
Submitted: 29 Sep 2011 11:19 Modified: 3 Jun 2013 14:09
Reporter: Oleksii Moskvin Email Updates:
Status: Closed Impact on me:
None 
Category:Tests Severity:S3 (Non-critical)
Version:5.5.16, 5.5.20, 5.5.21 OS:Linux
Assigned to: CPU Architecture:Any
Tags: make test, my_vsnprintf, unit tests

[29 Sep 2011 11:19] Oleksii Moskvin
Description:
When running "make test" in source folder after compilation tests always fail on my_vsnprintf checks

[root@srv mysql-5.5.16]# make test
Running tests...
Start processing tests
Test project /usr/local/src/mysql-5.5.16
  1/ 12 Testing pfs_instr_class                  Passed
  2/ 12 Testing pfs_instr_class-oom              Passed
  3/ 12 Testing pfs_instr                        Passed
  4/ 12 Testing pfs_instr-oom                    Passed
  5/ 12 Testing pfs                              Passed
  6/ 12 Testing bitmap                           Passed
  7/ 12 Testing base64                           Passed
  8/ 12 Testing my_vsnprintf                     *** Failed
  9/ 12 Testing my_atomic                        Passed
 10/ 12 Testing my_rdtsc                         Passed
 11/ 12 Testing lf                               Passed
 12/ 12 Testing my_malloc                        Passed

How to repeat:
cmake .
make
make test

Suggested fix:
in ./unittest/mysys/my_vsnprintf-t.c

following function tests my_vsnprintf. 1-st argument is the expected result which my_vsnprintf should produce by processing 2..n args.

 22 void test1(const char *res, const char *fmt, ...)
 23 {
 24   va_list args;
 25   size_t len;
 26   va_start(args,fmt);
 27   len= my_vsnprintf(buf, sizeof(buf)-1, fmt, args);
 28   va_end(args);
 29   ok(strlen(res) == len && strcmp(buf, res) == 0, "\"%s\"", buf);
 30 }

and here we have statement which fails

157   test1("Hello string `I am a string`",
158         "Hello string %`s", "I am a string");

%`s seems to be a problem - backquote in invalid place and 2-nd backquote is missing. Suggested fix is

157   test1("Hello string `I am a string`",
158         "Hello string `%s`", "I am a string");
[29 Sep 2011 12:54] MySQL Verification Team
I couldn't repeat with source tree code 1 week older:

miguel@lara ~/mysql-5.5 $ make test
Running tests...
Test project /home/miguel/mysql-5.5
      Start  1: pfs_instr_class
 1/12 Test  #1: pfs_instr_class ..................   Passed    0.05 sec
      Start  2: pfs_instr_class-oom
 2/12 Test  #2: pfs_instr_class-oom ..............   Passed    0.06 sec
      Start  3: pfs_instr
 3/12 Test  #3: pfs_instr ........................   Passed    0.05 sec
      Start  4: pfs_instr-oom
 4/12 Test  #4: pfs_instr-oom ....................   Passed    0.05 sec
      Start  5: pfs
 5/12 Test  #5: pfs ..............................   Passed    0.63 sec
      Start  6: bitmap
 6/12 Test  #6: bitmap ...........................   Passed    7.14 sec
      Start  7: base64
 7/12 Test  #7: base64 ...........................   Passed    0.12 sec
      Start  8: my_vsnprintf
 8/12 Test  #8: my_vsnprintf .....................   Passed    0.04 sec
[30 Sep 2011 6:35] Valeriy Kravchuk
With 5.5.17 (current mysql-5.5 tree) on Mac OS X I see no problems:

macbook-pro:mysql-5.5-work openxs$ make test
Running tests...
Test project /Users/openxs/bzr2/mysql-5.5-work
      Start  1: pfs_instr_class
 1/12 Test  #1: pfs_instr_class ..................   Passed    0.12 sec
      Start  2: pfs_instr_class-oom
 2/12 Test  #2: pfs_instr_class-oom ..............   Passed    0.09 sec
      Start  3: pfs_instr
 3/12 Test  #3: pfs_instr ........................   Passed    0.03 sec
      Start  4: pfs_instr-oom
 4/12 Test  #4: pfs_instr-oom ....................   Passed    0.03 sec
      Start  5: pfs
 5/12 Test  #5: pfs ..............................   Passed    0.67 sec
      Start  6: bitmap
 6/12 Test  #6: bitmap ...........................   Passed    5.14 sec
      Start  7: base64
 7/12 Test  #7: base64 ...........................   Passed    0.10 sec
      Start  8: my_vsnprintf
 8/12 Test  #8: my_vsnprintf .....................   Passed    0.07 sec
      Start  9: my_atomic
 9/12 Test  #9: my_atomic ........................   Passed    2.14 sec
      Start 10: my_rdtsc
10/12 Test #10: my_rdtsc .........................   Passed    0.16 sec
      Start 11: lf
11/12 Test #11: lf ...............................   Passed    2.29 sec
      Start 12: my_malloc
12/12 Test #12: my_malloc ........................   Passed    0.05 sec

100% tests passed, 0 tests failed out of 12

Total Test time (real) =  11.08 sec
[30 Dec 2011 18:30] Valeriy Kravchuk
Please, check if the problem is still repeatable in your environment with recent version, 5.5.19.
[4 Jan 2012 13:17] Oleksii Moskvin
Checked.
Works fine with gcc but still fails the same way using latest version of Intel compiler (icc).
[23 Jan 2012 19:07] Sveta Smirnova
Thank you for the feedback.

Verified as described.
[4 Feb 2013 6:11] Sayantan Dutta
Not a bug. The code is supposed to work the way it is with gcc
[25 Feb 2013 13:13] Sayantan Dutta
Bug Fixed.
[15 May 2013 15:11] Paul DuBois
Test suite changes. No changelog entry needed.
[16 May 2013 13:46] Laurent Blume
I am hitting that bug on Solaris 10, compiling MySQL 5.5.31 with Studio 12.3.

This is most definitely a bug: one of the tests is disabled in my_vsnprintf-t.c if the compiler is not GCC (#if defined (__GNUC__) clause), but the number of tests expected to pass is kept the same.

So it's impossible that those tests succeed if the compiler is not GCC, which makes me wonder how there is an official build for Solaris that doesn't even pass "make test".

I've made that change, it is enough for make test to succeed for me:

--- my_vsnprintf-t.c.original   lun. mars 25 14:14:58 2013
+++ my_vsnprintf-t.c    jeu. mai  16 15:35:30 2013
@@ -31,7 +31,11 @@

 int main(void)
 {
+#if defined (__GNUC__)
   plan(58);
+#else
+  plan(57);
+#endif

   test1("Constant string",
         "Constant string");
[3 Jun 2013 14:09] Paul DuBois
Changes for test suite. No changelog entry needed.