From: W.C.A. Wijngaards Date: Wed, 4 Dec 2019 10:37:24 +0000 (+0100) Subject: - Fix testbound for alloccheck runs, memory purify and lock checks. X-Git-Tag: release-1.9.6rc1~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f7eb3ea9f756085a85a4f9d6442253dcc653792;p=thirdparty%2Funbound.git - Fix testbound for alloccheck runs, memory purify and lock checks. --- diff --git a/doc/Changelog b/doc/Changelog index 21d250348..9eea61490 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,5 +1,6 @@ 4 December 2019: Wouter - Fix lock type for memory purify log lock deletion. + - Fix testbound for alloccheck runs, memory purify and lock checks. 3 December 2019: Wouter - Merge pull request #124 from rmetrich: Changed log lock diff --git a/testcode/testbound.c b/testcode/testbound.c index 735cbea62..4405231c0 100644 --- a/testcode/testbound.c +++ b/testcode/testbound.c @@ -65,6 +65,23 @@ /** config files (removed at exit) */ static struct config_strlist* cfgfiles = NULL; +#ifdef UNBOUND_ALLOC_STATS +# define strdup(s) unbound_stat_strdup_log(s, __FILE__, __LINE__, __func__) +char* unbound_stat_strdup_log(char* s, const char* file, int line, + const char* func); +char* unbound_stat_strdup_log(char* s, const char* file, int line, + const char* func) { + char* result; + size_t len; + if(!s) return NULL; + len = strlen(s); + log_info("%s:%d %s strdup(%u)", file, line, func, (unsigned)len+1); + result = unbound_stat_malloc(len+1); + memmove(result, s, len+1); + return result; +} +#endif /* UNBOUND_ALLOC_STATS */ + /** give commandline usage for testbound. */ static void testbound_usage(void) @@ -463,6 +480,12 @@ main(int argc, char* argv[]) free(pass_argv[c]); if(res == 0) { log_info("Testbound Exit Success\n"); + /* remove configfile from here, the atexit() is for when + * there is a crash to remove the tmpdir file. + * This one removes the file while alloc and log locks are + * still valid, and can be logged (for memory calculation), + * it leaves the ptr NULL so the atexit does nothing. */ + remove_configfile(); if(log_get_lock()) { lock_basic_destroy((lock_basic_type*)log_get_lock()); }