mirror of
https://github.com/moparisthebest/curl
synced 2025-03-01 01:41:50 -05:00
test #558 verifies loop operation using malloc() and free()
This commit is contained in:
parent
417bac4055
commit
6db8f53445
@ -59,7 +59,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
|
||||
test1064 test1065 test1066 test1067 test1068 test1069 test1070 test1071 \
|
||||
test1072 test1073 test1074 test1075 test1076 test1077 test1078 test1079 \
|
||||
test1080 test1081 test1082 test1083 test1084 test1085 test633 test634 \
|
||||
test635 test636 test637
|
||||
test635 test636 test637 test558
|
||||
|
||||
filecheck:
|
||||
@mkdir test-place; \
|
||||
|
54
tests/data/test558
Normal file
54
tests/data/test558
Normal file
@ -0,0 +1,54 @@
|
||||
<testcase>
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
none
|
||||
</server>
|
||||
# tool is what to use instead of 'curl'
|
||||
<tool>
|
||||
lib558
|
||||
</tool>
|
||||
|
||||
<name>
|
||||
loop testing
|
||||
</name>
|
||||
<command>
|
||||
nothing
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<stdout mode="text">
|
||||
malloc of root struct OK
|
||||
malloc of pointer table OK
|
||||
initializing table...
|
||||
table initialized OK
|
||||
filling pointer table...
|
||||
malloc of pointed element (idx 0) OK
|
||||
malloc of pointed element (idx 1) OK
|
||||
malloc of pointed element (idx 2) OK
|
||||
malloc of pointed element (idx 3) OK
|
||||
malloc of pointed element (idx 4) OK
|
||||
malloc of pointed element (idx 5) OK
|
||||
malloc of pointed element (idx 6) OK
|
||||
malloc of pointed element (idx 7) OK
|
||||
malloc of pointed element (idx 8) OK
|
||||
malloc of pointed element (idx 9) OK
|
||||
pointer table filling OK
|
||||
freeing pointers in table...
|
||||
freeing pointers in table OK
|
||||
freeing table...
|
||||
freeing table OK
|
||||
freeing root struct...
|
||||
freeing root struct OK
|
||||
</stdout>
|
||||
</verify>
|
||||
|
||||
</testcase>
|
@ -53,7 +53,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \
|
||||
lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \
|
||||
lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \
|
||||
lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \
|
||||
lib539 lib557
|
||||
lib539 lib557 lib558
|
||||
|
||||
# Dependencies (may need to be overriden)
|
||||
LDADD = $(LIBDIR)/libcurl.la
|
||||
@ -162,3 +162,5 @@ lib554_SOURCES = lib554.c $(SUPPORTFILES)
|
||||
lib556_SOURCES = lib556.c $(SUPPORTFILES)
|
||||
|
||||
lib557_SOURCES = lib557.c $(SUPPORTFILES)
|
||||
|
||||
lib558_SOURCES = lib558.c $(SUPPORTFILES)
|
||||
|
127
tests/libtest/lib558.c
Normal file
127
tests/libtest/lib558.c
Normal file
@ -0,0 +1,127 @@
|
||||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TABLE_SIZE 10
|
||||
|
||||
|
||||
struct element_st {
|
||||
int idx;
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
struct root_st {
|
||||
struct element_st **table;
|
||||
int size;
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
struct root_st * new_root(void)
|
||||
{
|
||||
struct root_st *r;
|
||||
|
||||
r = malloc(sizeof(struct root_st));
|
||||
if(r != NULL)
|
||||
printf("malloc of root struct OK\n");
|
||||
else {
|
||||
printf("malloc of root struct failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
r->size = TABLE_SIZE;
|
||||
r->table = malloc(r->size * sizeof(struct element_st *));
|
||||
if(r->table != NULL)
|
||||
printf("malloc of pointer table OK\n");
|
||||
else {
|
||||
printf("malloc of pointer table failed\n");
|
||||
free(r);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
struct element_st * new_element(int idx)
|
||||
{
|
||||
struct element_st *e;
|
||||
|
||||
e = malloc(sizeof(struct element_st));
|
||||
if(e != NULL)
|
||||
printf("malloc of pointed element (idx %d) OK\n", idx);
|
||||
else {
|
||||
printf("malloc of pointed element (idx %d) failed\n", idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
e->idx = e->dummy = idx;
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
struct root_st *root;
|
||||
int error;
|
||||
int i;
|
||||
(void)URL; /* not used */
|
||||
|
||||
root = new_root();
|
||||
if(!root)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
|
||||
printf("initializing table...\n");
|
||||
for (i = 0; i < root->size; ++i) {
|
||||
root->table[i] = NULL;
|
||||
}
|
||||
printf("table initialized OK\n");
|
||||
|
||||
printf("filling pointer table...\n");
|
||||
error = 0;
|
||||
for (i = 0; i < root->size; ++i) {
|
||||
root->table[i] = new_element(i);
|
||||
if(!root->table[i]) {
|
||||
error = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(error) {
|
||||
printf("pointer table filling failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
else
|
||||
printf("pointer table filling OK\n");
|
||||
|
||||
printf("freeing pointers in table...\n");
|
||||
for (i = 0; i < root->size; ++i) {
|
||||
if(root->table[i])
|
||||
free(root->table[i]);
|
||||
}
|
||||
printf("freeing pointers in table OK\n");
|
||||
|
||||
printf("freeing table...\n");
|
||||
free(root->table);
|
||||
printf("freeing table OK\n");
|
||||
|
||||
printf("freeing root struct...\n");
|
||||
free(root);
|
||||
printf("freeing root struct OK\n");
|
||||
|
||||
return 0; /* OK */
|
||||
}
|
@ -1827,6 +1827,7 @@ sub singletest {
|
||||
if(($testnum != 1) && ($testnum != 100) &&
|
||||
($testnum != 500) && ($testnum != 507) &&
|
||||
($testnum != 517) && ($testnum != 534) &&
|
||||
($testnum != 558) &&
|
||||
($testnum != 557) && ($testnum != 1013)) {
|
||||
$why = "debugging icc build";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user