From 989ec98ebdc1c73b70b957f9eeacb4de7882970a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 16 Dec 2003 09:49:36 +0000 Subject: modified and corrected test 506 --- tests/data/test506 | 106 ++++++++++++++++++++++++++----------------------- tests/libtest/lib506.c | 28 +++++++++---- 2 files changed, 77 insertions(+), 57 deletions(-) diff --git a/tests/data/test506 b/tests/data/test506 index 1fbd4bac8..85a5bc9a0 100644 --- a/tests/data/test506 +++ b/tests/data/test506 @@ -63,73 +63,79 @@ CURL_LOCK_DATA_COOKIE CURL_LOCK_DATA_DNS *** run 1 CURLOPT_SHARE -lock: share -unlock: share +lock: share : 0 +unlock: share : 1 PERFORM -lock: dns -unlock: dns -lock: dns -unlock: dns -lock: cookie -unlock: cookie -lock: cookie -unlock: cookie -lock: cookie -unlock: cookie -lock: cookie -unlock: cookie +lock: dns : 2 +unlock: dns : 3 +lock: dns : 4 +unlock: dns : 5 +lock: cookie : 6 +unlock: cookie : 7 +lock: cookie : 8 +unlock: cookie : 9 +lock: cookie : 10 +unlock: cookie : 11 +lock: cookie : 12 +unlock: cookie : 13 run 1: set cookie 1, 2 and 3 -lock: dns -unlock: dns +lock: dns : 14 +unlock: dns : 15 +lock: dns : 16 +unlock: dns : 17 CLEANUP -lock: cookie -unlock: cookie +lock: cookie : 18 +unlock: cookie : 19 *** run 2 CURLOPT_SHARE -lock: share -unlock: share +lock: share : 20 +unlock: share : 21 PERFORM -lock: dns -unlock: dns -lock: cookie -unlock: cookie -lock: cookie -unlock: cookie -lock: cookie -unlock: cookie +lock: dns : 22 +unlock: dns : 23 +lock: cookie : 24 +unlock: cookie : 25 +lock: cookie : 26 +unlock: cookie : 27 +lock: cookie : 28 +unlock: cookie : 29 run 2: set cookie 4 and 5 -lock: dns -unlock: dns +lock: dns : 30 +unlock: dns : 31 +lock: dns : 32 +unlock: dns : 33 CLEANUP -lock: cookie -unlock: cookie +lock: cookie : 34 +unlock: cookie : 35 *** run 3 CURLOPT_SHARE -lock: share -unlock: share +lock: share : 36 +unlock: share : 37 CURLOPT_COOKIEJAR PERFORM -lock: dns -unlock: dns -lock: cookie -unlock: cookie -lock: cookie -unlock: cookie -lock: cookie -unlock: cookie +lock: dns : 38 +unlock: dns : 39 +lock: cookie : 40 +unlock: cookie : 41 +lock: cookie : 42 +unlock: cookie : 43 +lock: cookie : 44 +unlock: cookie : 45 run 3: overwrite cookie 1 and 4 -lock: dns -unlock: dns +lock: dns : 46 +unlock: dns : 47 +lock: dns : 48 +unlock: dns : 49 try SHARE_CLEANUP... -lock: share -unlock: share +lock: share : 50 +unlock: share : 51 SHARE_CLEANUP failed, correct CLEANUP -lock: cookie -unlock: cookie +lock: cookie : 52 +unlock: cookie : 53 SHARE_CLEANUP -lock: share -unlock: share +lock: share : 54 +unlock: share : 55 GLOBAL_CLEANUP diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 52f6a38e7..998c1370c 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -14,20 +14,27 @@ struct Tdata { char *url; }; +struct userdata { + char *text; + int counter; +}; /* lock callback */ void lock(CURL *handle, curl_lock_data data, curl_lock_access access, void *useptr ) { const char *what; + struct userdata *user = (struct userdata *)useptr; + (void)handle; (void)access; + switch ( data ) { case CURL_LOCK_DATA_SHARE: - what = "share "; + what = "share"; break; case CURL_LOCK_DATA_DNS: - what = "dns "; + what = "dns"; break; case CURL_LOCK_DATA_COOKIE: what = "cookie"; @@ -36,20 +43,22 @@ void lock(CURL *handle, curl_lock_data data, curl_lock_access access, fprintf(stderr, "lock: no such data: %d\n",data); return; } - printf("lock: %s <%s>\n", what, (char *)useptr); + printf("lock: %-6s <%s>: %d\n", what, user->text, user->counter); + user->counter++; } /* unlock callback */ void unlock(CURL *handle, curl_lock_data data, void *useptr ) { const char *what; + struct userdata *user = (struct userdata *)useptr; (void)handle; switch ( data ) { case CURL_LOCK_DATA_SHARE: - what = "share "; + what = "share"; break; case CURL_LOCK_DATA_DNS: - what = "dns "; + what = "dns"; break; case CURL_LOCK_DATA_COOKIE: what = "cookie"; @@ -58,7 +67,8 @@ void unlock(CURL *handle, curl_lock_data data, void *useptr ) fprintf(stderr, "unlock: no such data: %d\n",data); return; } - printf("unlock: %s <%s>\n", what, (char *)useptr); + printf("unlock: %-6s <%s>: %d\n", what, user->text, user->counter); + user->counter++; } @@ -127,6 +137,10 @@ CURLcode test(char *URL) CURLSH *share; struct curl_slist *headers; int i; + struct userdata user; + + user.text = (char *)"Pigs in space"; + user.counter = 0; printf( "GLOBAL_INIT\n" ); curl_global_init( CURL_GLOBAL_ALL ); @@ -136,7 +150,7 @@ CURLcode test(char *URL) share = curl_share_init(); curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock); curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock); - curl_share_setopt( share, CURLSHOPT_USERDATA, "Pigs in space"); + curl_share_setopt( share, CURLSHOPT_USERDATA, &user); printf( "CURL_LOCK_DATA_COOKIE\n" ); curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); printf( "CURL_LOCK_DATA_DNS\n" ); -- cgit v1.2.3