aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-14 08:40:33 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-14 08:40:33 +0000
commit4ab0d74250b3a69e3980ca961b9867bf365580ab (patch)
tree68afc3f419f9ee8739a24aca55b423b2b6fc0cdf /tests
parentb5f85ba77d11b3e1de2fb5f2989badeff983f5e7 (diff)
downloadgnurl-4ab0d74250b3a69e3980ca961b9867bf365580ab.tar.gz
gnurl-4ab0d74250b3a69e3980ca961b9867bf365580ab.tar.bz2
gnurl-4ab0d74250b3a69e3980ca961b9867bf365580ab.zip
enable memory debugging the same way the curl command line tool already does
Diffstat (limited to 'tests')
-rw-r--r--tests/libtest/first.c19
-rw-r--r--tests/libtest/test.h1
2 files changed, 17 insertions, 3 deletions
diff --git a/tests/libtest/first.c b/tests/libtest/first.c
index d8bfdd19a..c4f35df22 100644
--- a/tests/libtest/first.c
+++ b/tests/libtest/first.c
@@ -3,6 +3,7 @@
#ifdef CURLDEBUG
/* provide a proto for this debug function */
extern void curl_memdebug(const char *);
+extern void curl_memlimit(int);
#endif
/* test is provided in the test code file */
@@ -13,6 +14,21 @@ char *arg2=NULL;
int main(int argc, char **argv)
{
char *URL;
+
+#ifdef CURLDEBUG
+ /* this sends all memory debug messages to a logfile named memdump */
+ char *env = curl_getenv("CURL_MEMDEBUG");
+ if(env) {
+ curl_free(env);
+ curl_memdebug("memdump");
+ }
+ /* this enables the fail-on-alloc-number-N functionality */
+ env = curl_getenv("CURL_MEMLIMIT");
+ if(env) {
+ curl_memlimit(atoi(env));
+ curl_free(env);
+ }
+#endif
if(argc< 2 ) {
fprintf(stderr, "Pass URL as argument please\n");
return 1;
@@ -24,8 +40,5 @@ int main(int argc, char **argv)
fprintf(stderr, "URL: %s\n", URL);
-#ifdef CURLDEBUG
- curl_memdebug("memdump");
-#endif
return test(URL);
}
diff --git a/tests/libtest/test.h b/tests/libtest/test.h
index f0e13b20f..a442ba4bd 100644
--- a/tests/libtest/test.h
+++ b/tests/libtest/test.h
@@ -9,6 +9,7 @@
#include <curl.h>
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>