]> granicus.if.org Git - libexpat/commitdiff
Make test_nsalloc_long_systemid_in_ext() robust
authorRhodri James <rhodri@kynesim.co.uk>
Wed, 26 Jul 2017 17:18:46 +0000 (18:18 +0100)
committerRhodri James <rhodri@kynesim.co.uk>
Wed, 26 Jul 2017 17:56:37 +0000 (18:56 +0100)
Makes test more predictable in the face of changing memory
allocation patterns in the library.

expat/tests/runtests.c

index ef21b2ae3fa2bbab287213b4f07855afe472cda0..f9ca3396f851bfd35b22ec6745d1e20256c3f9a6 100644 (file)
@@ -11838,23 +11838,9 @@ START_TEST(test_nsalloc_long_systemid_in_ext)
         { NULL, NULL }
     };
     int i;
-#define MAX_ALLOC_COUNT 30
-    int repeat = 0;
+#define MAX_ALLOC_COUNT 55
 
     for (i = 0; i < MAX_ALLOC_COUNT; i++) {
-        /* Repeat some counts to allow for cached allocations */
-        if ((i == 4 && repeat == 3) || (i == 10 && repeat == 8)) {
-            i -= 2;
-            repeat++;
-        }
-        else if ((i == 2 && repeat < 2) ||
-                 (i == 3 && (repeat == 2 || repeat == 4 || repeat == 5)) ||
-                 (i == 4 && repeat == 6) ||
-                 (i == 5 && repeat == 7) ||
-                 (i == 9 && repeat == 8)) {
-            i--;
-            repeat++;
-        }
         allocation_count = i;
         XML_SetUserData(parser, options);
         XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
@@ -11863,8 +11849,9 @@ START_TEST(test_nsalloc_long_systemid_in_ext)
                                     XML_TRUE) != XML_STATUS_ERROR)
             break;
 
-        XML_ParserFree(parser);
-        parser = XML_ParserCreate(NULL);
+        /* See comment in test_nsalloc_xmlns() */
+        nsalloc_teardown();
+        nsalloc_setup();
     }
     if (i == 0)
         fail("Parsing worked despite failing allocations");