]> granicus.if.org Git - libexpat/commitdiff
Make test_nsalloc_realloc_long_context_in_dtd() robust.
authorRhodri James <rhodri@kynesim.co.uk>
Wed, 26 Jul 2017 17:14:46 +0000 (18:14 +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 changes in the pattern
of memory allocations inside the library.

expat/tests/runtests.c

index 59dc1b24feb15801454fc84b30c0f13214e35bdd..a61c394cd3642060509fb05ed3f1f64a77177bd9 100644 (file)
@@ -11713,15 +11713,9 @@ START_TEST(test_nsalloc_realloc_long_context_in_dtd)
         { NULL, NULL }
     };
     int i;
-#define MAX_REALLOC_COUNT 10
-    int repeat = 0;
+#define MAX_REALLOC_COUNT 20
 
     for (i = 0; i < MAX_REALLOC_COUNT; i++) {
-        /* Repeat some counts to defeat allocation caching */
-        if (i == 2 && repeat < 11) {
-            i--;
-            repeat++;
-        }
         reallocation_count = i;
         XML_SetUserData(parser, options);
         XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
@@ -11729,7 +11723,9 @@ START_TEST(test_nsalloc_realloc_long_context_in_dtd)
         if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
                                     XML_TRUE) != XML_STATUS_ERROR)
             break;
-        XML_ParserReset(parser, NULL);
+        /* See comment in test_nsalloc_xmlns() */
+        nsalloc_teardown();
+        nsalloc_setup();
     }
     if (i == 0)
         fail("Parsing worked despite failing reallocations");