Package: check
Version: 0.9.4-2
Severity: grave
Tags: patch
Justification: renders package unusable

check uses "i" in the loop test macro, which breaks every use that uses
"i" locally. since "i" is the most ommon loop variable in C, it will
break in almost any case.

cu  robert

-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (670, 'unstable'), (600, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17.6
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

-- no debconf information

-- 
Robert Lemmen                               http://www.semistable.com 
Index: src/check.h.in
===================================================================
--- src/check.h.in      (revision 368)
+++ src/check.h.in      (revision 369)
@@ -174,7 +174,7 @@
    One must use braces within a START_/END_ pair to declare new variables
 */ 
 #define START_TEST(__testname)\
-static void __testname (int i __attribute__((unused)))\
+static void __testname (int _i __attribute__((unused)))\
 {\
   tcase_fn_start (""# __testname, __FILE__, __LINE__);
 
Index: tests/ex_xml_output.c
===================================================================
--- tests/ex_xml_output.c       (revision 368)
+++ tests/ex_xml_output.c       (revision 369)
@@ -29,7 +29,7 @@
 
 START_TEST(test_loop)
 {
-  fail_unless (i==1, "Iteration %d failed", i);
+  fail_unless (_i==1, "Iteration %d failed", _i);
 }
 END_TEST
 
Index: tests/check_check_master.c
===================================================================
--- tests/check_check_master.c  (revision 368)
+++ tests/check_check_master.c  (revision 369)
@@ -204,14 +204,14 @@
 START_TEST(test_check_tcnames)
 {
   const char *tcname;   
-  tcname = tr_tcname(tr_all_array[i]);
-  if (strcmp(tcname, master_tests[i].tcname) != 0) {
+  tcname = tr_tcname(tr_all_array[_i]);
+  if (strcmp(tcname, master_tests[_i].tcname) != 0) {
     char *emsg = malloc (MAXSTR);
     snprintf(emsg, MAXSTR,"Expected %s, got %s",
-             master_tests[i].tcname, tcname);
+             master_tests[_i].tcname, tcname);
     fail(emsg);
     free(emsg);
-  }
+  } 
 }
 END_TEST
 
@@ -219,11 +219,11 @@
 START_TEST(test_check_all_msgs)
 {
   const char *msg;
-  msg = tr_msg(tr_all_array[i]);
-  if (strcmp(msg, master_tests[i].msg) != 0) {
+  msg = tr_msg(tr_all_array[_i]);
+  if (strcmp(msg, master_tests[_i].msg) != 0) {
     char *emsg = malloc (MAXSTR);
     snprintf(emsg, MAXSTR,"Expected %s, got %s",
-             master_tests[i].msg, msg);
+             master_tests[_i].msg, msg);
     fail(emsg);
     free(emsg);
   }
@@ -232,8 +232,8 @@
 
 START_TEST(test_check_all_ftypes)
 {
-  fail_unless(master_tests[i].failure_type == tr_rtype(tr_all_array[i]),
-              "Failure type wrong for test %d", i);
+  fail_unless(master_tests[_i].failure_type == tr_rtype(tr_all_array[_i]),
+              "Failure type wrong for test %d", _i);
 }
 END_TEST
 
Index: doc/check.texi
===================================================================
--- doc/check.texi      (revision 368)
+++ doc/check.texi      (revision 369)
@@ -1001,7 +1001,7 @@
 Adding a normal test with @code{tcase_add_loop_test()} instead of
 @code{tcase_add_test()} will make the test function the body of a
 @code{for} loop, with the addition of a fork before each call.  The
-loop variable @code{i} is available for use inside the test function;
+loop variable @code{_i} is available for use inside the test function;
 for example, it could serve as an index into a table.  For failures,
 the iteration which caused the failure is available in error messages
 and logs.  
@@ -1011,15 +1011,32 @@
 pseudo-code to show the concept:
 @example
 @verbatim
-for (i = tfun->loop_start; i < tfun->loop_end; i++)
+for (_i = tfun->loop_start; _i < tfun->loop_end; _i++)
 {
   fork();      /* New context */
-  tfun->f(i);  /* Call test function */
+  tfun->f(_i);  /* Call test function */
   wait();      /* Wait for child to terminate */
 }
 @end verbatim
 @end example
 
+An example of looping test usage follows:
[EMAIL PROTECTED]
[EMAIL PROTECTED]
+static const int primes[5] = {2,3,5,7,11};
+
+START_TEST (check_is_prime)
+{
+  fail_unless (is_prime (primes[_i]));
+}
+END_TEST
+
+...
+
+tcase_add_loop_test (tcase, check_is_prime, 0, 5);
[EMAIL PROTECTED] verbatim
[EMAIL PROTECTED] example
+
 Looping tests work in @code{CK_NOFORK} mode as well, but without the
 forking.  This means that only the first error will be shown.
 

Attachment: signature.asc
Description: Digital signature

Reply via email to