diff options
author | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2008-08-22 10:47:02 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2008-08-22 10:47:02 +0000 |
commit | eedefef10ef19172a26e813372af174007d6c995 (patch) | |
tree | b17689b5bac63de51e947e5ed30f0a5083035f3d | |
parent | d3892dbb6c4ed4e325de60846cdaa27fc3fc34cf (diff) | |
download | libhubbub-eedefef10ef19172a26e813372af174007d6c995.tar.gz libhubbub-eedefef10ef19172a26e813372af174007d6c995.tar.bz2 |
Play with CHUNK_SIZE to attempt to tickle bugs. Causes tree tests to fail with a double-free
svn path=/trunk/hubbub/; revision=5172
-rw-r--r-- | test/parser.c | 25 | ||||
-rw-r--r-- | test/tree.c | 27 |
2 files changed, 37 insertions, 15 deletions
diff --git a/test/parser.c b/test/parser.c index 1ab77d7..31cf541 100644 --- a/test/parser.c +++ b/test/parser.c @@ -19,22 +19,16 @@ static void *myrealloc(void *ptr, size_t len, void *pw) return realloc(ptr, len); } -int main(int argc, char **argv) +static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE) { hubbub_parser *parser; hubbub_parser_optparams params; FILE *fp; size_t len, origlen; -#define CHUNK_SIZE (4096) uint8_t buf[CHUNK_SIZE]; const char *charset; hubbub_charset_source cssource; - if (argc != 3) { - printf("Usage: %s <aliases_file> <filename>\n", argv[0]); - return 1; - } - /* Initialise library */ assert(hubbub_initialise(argv[1], myrealloc, NULL) == HUBBUB_OK); @@ -91,6 +85,23 @@ int main(int argc, char **argv) return 0; } +int main(int argc, char **argv) +{ + int ret; + int shift; + int offset; + if (argc != 3) { + printf("Usage: %s <aliases_file> <filename>\n", argv[0]); + return 1; + } +#define DO_TEST(n) if ((ret = run_test(argc, argv, (n))) != 0) return ret + for (shift = 0; (1 << shift) != 16384; shift++) + for (offset = 0; offset < 10; offset += 3) + DO_TEST((1 << shift) + offset); + return 0; +#undef DO_TEST +} + hubbub_error token_handler(const hubbub_token *token, void *pw) { static const char *token_names[] = { diff --git a/test/tree.c b/test/tree.c index 4e42afc..026c447 100644 --- a/test/tree.c +++ b/test/tree.c @@ -77,23 +77,17 @@ static void *myrealloc(void *ptr, size_t len, void *pw) return realloc(ptr, len); } -int main(int argc, char **argv) +static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE) { hubbub_parser *parser; hubbub_parser_optparams params; FILE *fp; size_t len, origlen; -#define CHUNK_SIZE (4096) uint8_t buf[CHUNK_SIZE]; const char *charset; hubbub_charset_source cssource; bool passed = true; - if (argc != 3) { - printf("Usage: %s <aliases_file> <filename>\n", argv[0]); - return 1; - } - node_ref = calloc(NODE_REF_CHUNK, sizeof(uint16_t)); if (node_ref == NULL) { printf("Failed allocating node_ref\n"); @@ -168,7 +162,24 @@ int main(int argc, char **argv) printf("%s\n", passed ? "PASS" : "FAIL"); - return 0; + return passed ? 0 : 1; +} + +int main(int argc, char **argv) +{ + int ret; + int shift; + int offset; + if (argc != 3) { + printf("Usage: %s <aliases_file> <filename>\n", argv[0]); + return 1; + } +#define DO_TEST(n) if ((ret = run_test(argc, argv, (n))) != 0) return ret + for (shift = 0; (1 << shift) != 16384; shift++) + for (offset = 0; offset < 10; offset += 3) + DO_TEST((1 << shift) + offset); + return 0; +#undef DO_TEST } int create_comment(void *ctx, const hubbub_string *data, void **result) |