summaryrefslogtreecommitdiff
path: root/source4/torture/local
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/local')
-rw-r--r--source4/torture/local/binding_string.c50
-rw-r--r--source4/torture/local/config.mk2
-rw-r--r--source4/torture/local/dbspeed.c18
-rw-r--r--source4/torture/local/event.c25
-rw-r--r--source4/torture/local/iconv.c137
-rw-r--r--source4/torture/local/idtree.c47
-rw-r--r--source4/torture/local/irpc.c75
-rw-r--r--source4/torture/local/local.c35
-rw-r--r--source4/torture/local/messaging.c57
-rw-r--r--source4/torture/local/ndr.c37
-rw-r--r--source4/torture/local/registry.c35
-rw-r--r--source4/torture/local/resolve.c39
-rw-r--r--source4/torture/local/sddl.c34
-rw-r--r--source4/torture/local/socket.c164
-rw-r--r--source4/torture/local/torture.c35
-rw-r--r--source4/torture/local/util_file.c51
-rw-r--r--source4/torture/local/util_strlist.c23
17 files changed, 388 insertions, 476 deletions
diff --git a/source4/torture/local/binding_string.c b/source4/torture/local/binding_string.c
index 3c38183ec9..f6bf35671e 100644
--- a/source4/torture/local/binding_string.c
+++ b/source4/torture/local/binding_string.c
@@ -25,37 +25,32 @@
#include "librpc/rpc/dcerpc.h"
#include "torture/torture.h"
-static BOOL test_BindingString(struct torture_context *torture,
- const void *_binding)
+static bool test_BindingString(struct torture_context *tctx,
+ const void *test_data)
{
- const char *binding = _binding;
+ const char *binding = test_data;
struct dcerpc_binding *b, *b2;
const char *s, *s2;
struct epm_tower tower;
+ TALLOC_CTX *mem_ctx = tctx;
/* Parse */
- torture_assert_ntstatus_ok(torture,
- dcerpc_parse_binding(torture, binding, &b),
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(mem_ctx, binding, &b),
"Error parsing binding string");
- s = dcerpc_binding_string(torture, b);
- if (!s) {
- torture_fail(torture, "Error converting binding back to string");
- return False;
- }
+ s = dcerpc_binding_string(mem_ctx, b);
+ torture_assert(tctx, s != NULL, "Error converting binding back to string");
- torture_assert_casestr_equal(torture, binding, s,
+ torture_assert_casestr_equal(tctx, binding, s,
"Mismatch while comparing original and regenerated binding strings");
/* Generate protocol towers */
- torture_assert_ntstatus_ok(torture,
- dcerpc_binding_build_tower(torture, b, &tower),
+ torture_assert_ntstatus_ok(tctx, dcerpc_binding_build_tower(mem_ctx, b, &tower),
"Error generating protocol tower");
/* Convert back to binding and then back to string and compare */
- torture_assert_ntstatus_ok(torture,
- dcerpc_binding_from_tower(torture, &tower, &b2),
+ torture_assert_ntstatus_ok(tctx, dcerpc_binding_from_tower(mem_ctx, &tower, &b2),
"Error generating binding from tower for original binding");
/* Compare to a stripped down version of the binding string because
@@ -64,25 +59,16 @@ static BOOL test_BindingString(struct torture_context *torture,
b->flags = 0;
- s = dcerpc_binding_string(torture, b);
- if (!s) {
- torture_fail(torture, "Error converting binding back to string for (stripped down)");
- return False;
- }
+ s = dcerpc_binding_string(mem_ctx, b);
+ torture_assert(tctx, s != NULL, "Error converting binding back to string for (stripped down)");
+ s2 = dcerpc_binding_string(mem_ctx, b2);
+ torture_assert(tctx, s != NULL, "Error converting binding back to string");
- s2 = dcerpc_binding_string(torture, b2);
- if (!s) {
- torture_fail(torture, "Error converting binding back to string");
- return False;
- }
-
- if (is_ipaddress(b->host) && strcasecmp(s, s2) != 0) {
- torture_fail(torture, "Mismatch while comparing original and from protocol tower generated binding strings: '%s' <> '%s'\n", s, s2);
- return False;
- }
+ if (is_ipaddress(b->host))
+ torture_assert_casestr_equal(tctx, s, s2, "Mismatch while comparing original and from protocol tower generated binding strings");
- return True;
+ return true;
}
static const char *test_strings[] = {
@@ -114,7 +100,7 @@ struct torture_suite *torture_local_binding_string(TALLOC_CTX *mem_ctx)
{
int i;
struct torture_suite *suite = torture_suite_create(mem_ctx,
- "LOCAL-BINDING");
+ "BINDING");
for (i = 0; i < ARRAY_SIZE(test_strings); i++) {
torture_suite_add_simple_tcase(suite, test_strings[i],
diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk
index c9494039e0..682fb55416 100644
--- a/source4/torture/local/config.mk
+++ b/source4/torture/local/config.mk
@@ -7,9 +7,9 @@ PRIVATE_PROTO_HEADER = \
proto.h
OBJ_FILES = \
iconv.o \
+ ../../lib/talloc/testsuite.o \
../../lib/replace/test/testsuite.o \
../../lib/replace/test/os2_delete.o \
- ../../lib/talloc/testsuite.o \
../../lib/crypto/md4test.o \
../../lib/crypto/md5test.o \
../../lib/crypto/hmacmd5test.o \
diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c
index 10620440ce..757c13cf6e 100644
--- a/source4/torture/local/dbspeed.c
+++ b/source4/torture/local/dbspeed.c
@@ -73,13 +73,13 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data)
if (!tdb_add_record(tdbw,
"S-1-5-21-53173311-3623041448-2049097239-%u",
"UID %u", i)) {
- torture_fail(torture, "Failed to add SID %d", i);
+ _torture_fail_ext(torture, "Failed to add SID %d", i);
goto failed;
}
if (!tdb_add_record(tdbw,
"UID %u",
"S-1-5-21-53173311-3623041448-2049097239-%u", i)) {
- torture_fail(torture, "Failed to add UID %d", i);
+ _torture_fail_ext(torture, "Failed to add UID %d", i);
goto failed;
}
}
@@ -95,7 +95,7 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data)
key.dsize = strlen((char *)key.dptr)+1;
data = tdb_fetch(tdbw->tdb, key);
if (data.dptr == NULL) {
- torture_fail(torture, "Failed to fetch SID %d", i);
+ _torture_fail_ext(torture, "Failed to fetch SID %d", i);
goto failed;
}
free(data.dptr);
@@ -103,7 +103,7 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data)
key.dsize = strlen((char *)key.dptr)+1;
data = tdb_fetch(tdbw->tdb, key);
if (data.dptr == NULL) {
- torture_fail(torture, "Failed to fetch UID %d", i);
+ _torture_fail_ext(torture, "Failed to fetch UID %d", i);
goto failed;
}
free(data.dptr);
@@ -186,13 +186,13 @@ static BOOL test_ldb_speed(struct torture_context *torture, const void *_data)
for (i=0;i<torture_entries;i++) {
if (!ldb_add_record(ldb, i)) {
- torture_fail(torture, "Failed to add SID %d", i);
+ _torture_fail_ext(torture, "Failed to add SID %d", i);
goto failed;
}
}
if (talloc_total_blocks(torture) > 100) {
- torture_fail(torture, "memory leak in ldb add");
+ _torture_fail_ext(torture, "memory leak in ldb add");
goto failed;
}
@@ -210,14 +210,16 @@ static BOOL test_ldb_speed(struct torture_context *torture, const void *_data)
i);
if (ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res) != LDB_SUCCESS ||
res->count != 1) {
- torture_fail(torture, "Failed to find SID %d", i);
+ torture_fail(torture, talloc_asprintf(torture,
+ "Failed to find SID %d", i));
}
talloc_free(res);
talloc_free(dn);
expr = talloc_asprintf(tmp_ctx, "(UID=%u)", i);
if (ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res) != LDB_SUCCESS ||
res->count != 1) {
- torture_fail(torture, "Failed to find UID %d", i);
+ torture_fail(torture, talloc_asprintf(torture,
+ "Failed to find UID %d", i));
}
talloc_free(res);
talloc_free(expr);
diff --git a/source4/torture/local/event.c b/source4/torture/local/event.c
index f55cd8d466..6579b1b277 100644
--- a/source4/torture/local/event.c
+++ b/source4/torture/local/event.c
@@ -40,13 +40,13 @@ static void fde_handler(struct event_context *ev_ctx, struct fd_event *f,
{
int *fd = private;
- torture_comment(test, "event[%d] fd[%d] events[0x%08X]%s%s", fde_count,
- *fd, flags,
+ torture_comment(test, "event[%d] fd[%d] events[0x%08X]%s%s\n",
+ fde_count, *fd, flags,
(flags & EVENT_FD_READ)?" EVENT_FD_READ":"",
(flags & EVENT_FD_WRITE)?" EVENT_FD_WRITE":"");
if (fde_count > 5) {
- torture_fail(test, "got more than fde 5 events - bug!");
+ _torture_fail_ext(test, "got more than fde 5 events - bug!");
talloc_free(fde);
fde = NULL;
return;
@@ -59,13 +59,13 @@ static void fde_handler(struct event_context *ev_ctx, struct fd_event *f,
static void timed_handler(struct event_context *ev_ctx, struct timed_event *te,
struct timeval tval, void *private)
{
- torture_comment(test, "timed_handler called[%d]", te_count);
+ torture_comment(test, "timed_handler called[%d]\n", te_count);
if (te_count > 2) {
close(write_fd);
write_fd = -1;
}
if (te_count > 5) {
- torture_comment(test, "remove fd event!");
+ torture_comment(test, "remove fd event!\n");
talloc_free(fde);
fde = NULL;
return;
@@ -74,17 +74,19 @@ static void timed_handler(struct event_context *ev_ctx, struct timed_event *te,
event_add_timed(ev_ctx, ev_ctx, timeval_current_ofs(0,500), timed_handler, private);
}
-static BOOL test_event_context(struct torture_context *torture, const void *_data)
+static bool test_event_context(struct torture_context *torture_ctx,
+ const void *test_data)
{
struct event_context *ev_ctx;
int fd[2] = { -1, -1 };
- BOOL try_epoll = (BOOL)_data;
+ BOOL try_epoll = (BOOL)test_data;
+ TALLOC_CTX *mem_ctx = torture_ctx;
- ev_ctx = event_context_init_ops(torture,
+ ev_ctx = event_context_init_ops(mem_ctx,
event_standard_get_ops(),
&try_epoll);
- test = torture;
+ test = torture_ctx;
/* reset globals */
write_fd = -1;
@@ -108,13 +110,12 @@ static BOOL test_event_context(struct torture_context *torture, const void *_dat
close(write_fd);
talloc_free(ev_ctx);
-
- return True;
+ return true;
}
struct torture_suite *torture_local_event(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-EVENT");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "EVENT");
torture_suite_add_simple_tcase(suite, "standard with select",
test_event_context,
diff --git a/source4/torture/local/iconv.c b/source4/torture/local/iconv.c
index de48d52657..28834a6680 100644
--- a/source4/torture/local/iconv.c
+++ b/source4/torture/local/iconv.c
@@ -107,7 +107,7 @@ static void show_buf(const char *name, uint8_t *buf, size_t size)
"charset", then convert it back again and ensure we get the same
buffer back
*/
-static int test_buffer(struct torture_context *test,
+static bool test_buffer(struct torture_context *test,
uint8_t *inbuf, size_t size, const char *charset)
{
uint8_t buf1[1000], buf2[1000], buf3[1000];
@@ -116,7 +116,6 @@ static int test_buffer(struct torture_context *test,
char *ptr_out;
size_t size_in1, size_in2, size_in3;
size_t ret1, ret2, ret3, len1, len2;
- int ok = 1;
int errno1, errno2;
static iconv_t cd;
static smb_iconv_t cd2, cd3;
@@ -133,7 +132,7 @@ static int test_buffer(struct torture_context *test,
cd = iconv_open(charset, "UTF-16LE");
if (cd == (iconv_t)-1) {
cd = NULL;
- return False;
+ return false;
}
cd2 = smb_iconv_open(charset, "UTF-16LE");
cd3 = smb_iconv_open("UTF-16LE", charset);
@@ -169,42 +168,30 @@ static int test_buffer(struct torture_context *test,
if (len2 > len1 &&
memcmp(buf1, buf2, len1) == 0 &&
get_codepoint((char *)(buf2+len1), len2-len1, charset) >= (1<<20)) {
- return ok;
+ return true;
}
if (len1 > len2 &&
memcmp(buf1, buf2, len2) == 0 &&
get_codepoint((char *)(buf1+len2), len1-len2, charset) >= (1<<20)) {
- return ok;
+ return true;
}
- if (ret1 != ret2) {
- torture_fail(test, "ret1=%d ret2=%d", (int)ret1, (int)ret2);
- ok = 0;
- }
+ torture_assert_int_equal(test, ret1, ret2, "ret mismatch");
if (errno1 != errno2) {
- torture_fail(test, "e1=%s e2=%s", strerror(errno1), strerror(errno2));
show_buf(" rem1:", inbuf+(size-size_in1), size_in1);
show_buf(" rem2:", inbuf+(size-size_in2), size_in2);
- ok = 0;
+ torture_fail(test, talloc_asprintf(test,
+ "e1=%s e2=%s", strerror(errno1), strerror(errno2)));
}
- if (outsize1 != outsize2) {
- torture_fail(test, "outsize mismatch outsize1=%d outsize2=%d",
- (int)outsize1, (int)outsize2);
- ok = 0;
- }
+ torture_assert_int_equal(test, outsize1, outsize2, "outsize mismatch");
- if (size_in1 != size_in2) {
- torture_fail(test, "size_in mismatch size_in1=%d size_in2=%d",
- (int)size_in1, (int)size_in2);
- ok = 0;
- }
+ torture_assert_int_equal(test, size_in1, size_in2, "size_in mismatch");
- if (!ok ||
- len1 != len2 ||
+ if (len1 != len2 ||
memcmp(buf1, buf2, len1) != 0) {
- torture_fail(test, "size=%d ret1=%d ret2=%d", (int)size, (int)ret1, (int)ret2);
+ torture_comment(test, "size=%d ret1=%d ret2=%d", (int)size, (int)ret1, (int)ret2);
show_buf(" IN1:", inbuf, size-size_in1);
show_buf(" IN2:", inbuf, size-size_in2);
show_buf("OUT1:", buf1, len1);
@@ -218,7 +205,7 @@ static int test_buffer(struct torture_context *test,
get_codepoint((char *)(buf1+len2),len1-len2, charset));
}
- ok = 0;
+ torture_fail(test, "failed");
}
/* convert back to UTF-16, putting result in buf3 */
@@ -236,42 +223,33 @@ static int test_buffer(struct torture_context *test,
get_codepoint((char *)(inbuf+sizeof(buf3) - outsize3),
size - (sizeof(buf3) - outsize3),
"UTF-16LE") >= (1<<20)) {
- return ok;
+ return true;
}
- if (ret3 != 0) {
- torture_fail(test, "pull failed - %s", strerror(errno));
- ok = 0;
- }
+ torture_assert_int_equal(test, ret3, 0, talloc_asprintf(test,
+ "pull failed - %s", strerror(errno)));
if (strncmp(charset, "UTF", 3) != 0) {
/* don't expect perfect mappings for non UTF charsets */
- return ok;
+ return true;
}
- if (outsize3 != sizeof(buf3) - size) {
- torture_fail(test, "wrong outsize3 - %d should be %d",
- (int)outsize3, (int)(sizeof(buf3) - size));
- ok = 0;
- }
+ torture_assert_int_equal(test, outsize3, sizeof(buf3) - size,
+ "wrong outsize3");
if (memcmp(buf3, inbuf, size) != 0) {
- torture_fail(test, "pull bytes mismatch:");
+ torture_comment(test, "pull bytes mismatch:");
show_buf("inbuf", inbuf, size);
show_buf(" buf3", buf3, sizeof(buf3) - outsize3);
- ok = 0;
+ torture_fail(test, "");
torture_comment(test, "next codepoint is %u\n",
get_codepoint((char *)(inbuf+sizeof(buf3) - outsize3),
size - (sizeof(buf3) - outsize3),
"UTF-16LE"));
}
- if (!ok) {
- torture_fail(test, "test_buffer failed for charset %s", charset);
- }
-
- return ok;
+ return true;
}
@@ -279,18 +257,14 @@ static int test_buffer(struct torture_context *test,
test the push_codepoint() and next_codepoint() functions for a given
codepoint
*/
-static int test_codepoint(struct torture_context *test, const void *data)
+static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint)
{
uint8_t buf[10];
size_t size, size2;
- unsigned int codepoint = *((const unsigned int *)data);
codepoint_t c;
size = push_codepoint((char *)buf, codepoint);
- if (size == -1) {
- torture_assert(test, codepoint >= 0xd800 && codepoint <= 0x10000, "Invalid Codepoint range");
- return True;
- }
+ torture_assert(tctx, size != -1 || (codepoint >= 0xd800 && codepoint <= 0x10000), "Invalid Codepoint range");
buf[size] = random();
buf[size+1] = random();
buf[size+2] = random();
@@ -298,31 +272,27 @@ static int test_codepoint(struct torture_context *test, const void *data)
c = next_codepoint((char *)buf, &size2);
- if (c != codepoint) {
- torture_fail(test, "next_codepoint(%u) failed - gave %u", codepoint, c);
- return False;
- }
+ torture_assert(tctx, c == codepoint, talloc_asprintf(tctx,
+ "next_codepoint(%u) failed - gave %u", codepoint, c));
- if (size2 != size) {
- torture_fail(test, "next_codepoint(%u) gave wrong size %d (should be %d)\n",
- codepoint, (int)size2, (int)size);
- return False;
- }
+ torture_assert(tctx, size2 == size,
+ talloc_asprintf(tctx, "next_codepoint(%u) gave wrong size %d (should be %d)\n",
+ codepoint, (int)size2, (int)size));
- return True;
+ return true;
}
-static BOOL test_next_codepoint(struct torture_context *test, const void *data)
+static bool test_next_codepoint(struct torture_context *tctx)
{
unsigned int codepoint;
for (codepoint=0;codepoint<(1<<20);codepoint++) {
- if (!test_codepoint(test, &codepoint))
- return False;
+ if (!test_codepoint(tctx, codepoint))
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_first_1m(struct torture_context *test, const void *data)
+static bool test_first_1m(struct torture_context *tctx)
{
unsigned int codepoint;
size_t size;
@@ -339,14 +309,13 @@ static BOOL test_first_1m(struct torture_context *test, const void *data)
}
}
- if (!test_buffer(test, inbuf, size, "UTF-8"))
- return False;
+ if (!test_buffer(tctx, inbuf, size, "UTF-8"))
+ return false;
}
-
- return True;
+ return true;
}
-static BOOL test_random_5m(struct torture_context *test, const void *data)
+static bool test_random_5m(struct torture_context *tctx)
{
unsigned char inbuf[1000];
unsigned int i;
@@ -356,7 +325,7 @@ static BOOL test_random_5m(struct torture_context *test, const void *data)
if (i % 1000 == 0) {
if (!lp_parm_bool(-1, "torture", "progress", True)) {
- torture_comment(test, "i=%u \r", i);
+ torture_comment(tctx, "i=%u \r", i);
}
}
@@ -374,20 +343,19 @@ static BOOL test_random_5m(struct torture_context *test, const void *data)
inbuf[c] |= 0xdc;
}
}
- if (!test_buffer(test, inbuf, size, "UTF-8"))
- return False;
+ if (!test_buffer(tctx, inbuf, size, "UTF-8"))
+ return false;
- if (!test_buffer(test, inbuf, size, "CP850"))
- return False;
+ if (!test_buffer(tctx, inbuf, size, "CP850"))
+ return false;
}
-
- return True;
+ return true;
}
struct torture_suite *torture_local_iconv(TALLOC_CTX *mem_ctx)
{
static iconv_t cd;
- struct torture_suite *suite;
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "ICONV");
if (!lp_parm_bool(-1, "iconv", "native", True)) {
printf("system iconv disabled - skipping test\n");
@@ -401,18 +369,15 @@ struct torture_suite *torture_local_iconv(TALLOC_CTX *mem_ctx)
}
iconv_close(cd);
- suite = torture_suite_create(mem_ctx, "LOCAL-ICONV");
srandom(time(NULL));
+ torture_suite_add_simple_test(suite, "next_codepoint()",
+ test_next_codepoint);
- torture_suite_add_simple_tcase(suite, "next_codepoint()",
- test_next_codepoint, NULL);
-
- torture_suite_add_simple_tcase(suite, "first 1M codepoints",
- test_first_1m, NULL);
-
- torture_suite_add_simple_tcase(suite, "5M random UTF-16LE sequences",
- test_random_5m, NULL);
+ torture_suite_add_simple_test(suite, "first 1M codepoints",
+ test_first_1m);
+ torture_suite_add_simple_test(suite, "5M random UTF-16LE sequences",
+ test_random_5m);
return suite;
}
diff --git a/source4/torture/local/idtree.c b/source4/torture/local/idtree.c
index 1d317dbce3..dd8618d0db 100644
--- a/source4/torture/local/idtree.c
+++ b/source4/torture/local/idtree.c
@@ -23,8 +23,7 @@
#include "includes.h"
#include "torture/torture.h"
-static BOOL torture_local_idtree_simple(struct torture_context *test,
- const void *_data)
+static bool torture_local_idtree_simple(struct torture_context *tctx)
{
struct idr_context *idr;
int i;
@@ -32,11 +31,12 @@ static BOOL torture_local_idtree_simple(struct torture_context *test,
int *present;
extern int torture_numops;
int n = torture_numops;
+ TALLOC_CTX *mem_ctx = tctx;
- idr = idr_init(test);
+ idr = idr_init(mem_ctx);
- ids = talloc_zero_array(test, int, n);
- present = talloc_zero_array(test, int, n);
+ ids = talloc_zero_array(mem_ctx, int, n);
+ present = talloc_zero_array(mem_ctx, int, n);
for (i=0;i<n;i++) {
ids[i] = -1;
@@ -47,28 +47,32 @@ static BOOL torture_local_idtree_simple(struct torture_context *test,
void *p = idr_find(idr, ids[ii]);
if (present[ii]) {
if (p != &ids[ii]) {
- torture_fail(test, "wrong ptr at %d - %p should be %p",
- ii, p, &ids[ii]);
+ torture_fail(tctx, talloc_asprintf(tctx,
+ "wrong ptr at %d - %p should be %p",
+ ii, p, &ids[ii]));
}
if (random() % 7 == 0) {
if (idr_remove(idr, ids[ii]) != 0) {
- torture_fail(test, "remove failed at %d (id=%d)",
- i, ids[ii]);
+ torture_fail(tctx, talloc_asprintf(tctx,
+ "remove failed at %d (id=%d)",
+ i, ids[ii]));
}
present[ii] = 0;
ids[ii] = -1;
}
} else {
if (p != NULL) {
- torture_fail(test, "non-present at %d gave %p (would be %d)",
+ torture_fail(tctx, talloc_asprintf(tctx,
+ "non-present at %d gave %p (would be %d)",
ii, p,
- (int)(((char *)p) - (char *)(&ids[0])) / sizeof(int));
+ (int)(((char *)p) - (char *)(&ids[0])) / sizeof(int)));
}
if (random() % 5) {
ids[ii] = idr_get_new(idr, &ids[ii], n);
if (ids[ii] < 0) {
- torture_fail(test, "alloc failure at %d (ret=%d)",
- ii, ids[ii]);
+ torture_fail(tctx, talloc_asprintf(tctx,
+ "alloc failure at %d (ret=%d)",
+ ii, ids[ii]));
} else {
present[ii] = 1;
}
@@ -76,26 +80,25 @@ static BOOL torture_local_idtree_simple(struct torture_context *test,
}
}
- torture_comment(test, "done %d random ops", i);
+ torture_comment(tctx, "done %d random ops\n", i);
for (i=0;i<n;i++) {
if (present[i]) {
if (idr_remove(idr, ids[i]) != 0) {
- torture_fail(test, "delete failed on cleanup at %d (id=%d)",
- i, ids[i]);
+ torture_fail(tctx, talloc_asprintf(tctx,
+ "delete failed on cleanup at %d (id=%d)",
+ i, ids[i]));
}
}
}
- torture_comment(test, "cleaned up");
-
- return True;
+ torture_comment(tctx, "cleaned up\n");
+ return true;
}
struct torture_suite *torture_local_idtree(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-IDTREE");
- torture_suite_add_simple_tcase(suite, "idtree", torture_local_idtree_simple,
- NULL);
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "IDTREE");
+ torture_suite_add_simple_test(suite, "idtree", torture_local_idtree_simple);
return suite;
}
diff --git a/source4/torture/local/irpc.c b/source4/torture/local/irpc.c
index 79c91cb3d2..185e1fb4ae 100644
--- a/source4/torture/local/irpc.c
+++ b/source4/torture/local/irpc.c
@@ -80,7 +80,7 @@ static NTSTATUS irpc_EchoData(struct irpc_message *irpc, struct echo_EchoData *r
/*
test a addone call over the internal messaging system
*/
-static BOOL test_addone(struct torture_context *test, const void *_data,
+static bool test_addone(struct torture_context *test, const void *_data,
const void *_value)
{
struct echo_AddOne r;
@@ -97,47 +97,45 @@ static BOOL test_addone(struct torture_context *test, const void *_data,
torture_assert_ntstatus_ok(test, status, "AddOne failed");
/* check the answer */
- torture_assert(test,
- *r.out.out_data == r.in.in_data + 1,
+ torture_assert(test, *r.out.out_data == r.in.in_data + 1,
"AddOne wrong answer");
- torture_comment(test, "%u + 1 = %u", r.in.in_data, *r.out.out_data);
-
- return True;
+ torture_comment(test, "%u + 1 = %u\n", r.in.in_data, *r.out.out_data);
+ return true;
}
/*
test a echodata call over the internal messaging system
*/
-static BOOL test_echodata(struct torture_context *test,
- const void *_data, const void *_data2)
+static bool test_echodata(struct torture_context *tctx,
+ const void *tcase_data,
+ const void *test_data)
{
struct echo_EchoData r;
NTSTATUS status;
- const struct irpc_test_data *data = _data;
+ const struct irpc_test_data *data = tcase_data;
+ TALLOC_CTX *mem_ctx = tctx;
/* make the call */
- r.in.in_data = (unsigned char *)talloc_strdup(test, "0123456789");
+ r.in.in_data = (unsigned char *)talloc_strdup(mem_ctx, "0123456789");
r.in.len = strlen((char *)r.in.in_data);
status = IRPC_CALL(data->msg_ctx1, MSG_ID2, rpcecho, ECHO_ECHODATA, &r,
- test);
- torture_assert_ntstatus_ok(test, status, "EchoData failed");
+ mem_ctx);
+ torture_assert_ntstatus_ok(tctx, status, "EchoData failed");
/* check the answer */
if (memcmp(r.out.out_data, r.in.in_data, r.in.len) != 0) {
- torture_fail(test, "EchoData wrong answer");
NDR_PRINT_OUT_DEBUG(echo_EchoData, &r);
- return False;
+ torture_fail(tctx, "EchoData wrong answer");
}
- torture_comment(test, "Echo '%*.*s' -> '%*.*s'",
+ torture_comment(tctx, "Echo '%*.*s' -> '%*.*s'\n",
r.in.len, r.in.len,
r.in.in_data,
r.in.len, r.in.len,
r.out.out_data);
-
- return True;
+ return true;
}
@@ -159,28 +157,29 @@ static void irpc_callback(struct irpc_request *irpc)
/*
test echo speed
*/
-static BOOL test_speed(struct torture_context *test,
- const void *_data,
- const void *_data2)
+static bool test_speed(struct torture_context *tctx,
+ const void *tcase_data,
+ const void *test_data)
{
int ping_count = 0;
int pong_count = 0;
- const struct irpc_test_data *data = _data;
+ const struct irpc_test_data *data = tcase_data;
struct timeval tv;
struct echo_AddOne r;
- int timelimit = lp_parm_int(-1, "torture", "timelimit", 10);
+ TALLOC_CTX *mem_ctx = tctx;
+ int timelimit = torture_setting_int(tctx, "timelimit", 10);
tv = timeval_current();
r.in.in_data = 0;
- torture_comment(test, "Sending echo for %d seconds", timelimit);
+ torture_comment(tctx, "Sending echo for %d seconds\n", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
struct irpc_request *irpc;
irpc = IRPC_CALL_SEND(data->msg_ctx1, MSG_ID2, rpcecho, ECHO_ADDONE,
- &r, test);
- torture_assert(test, irpc != NULL, "AddOne send failed");
+ &r, mem_ctx);
+ torture_assert(tctx, irpc != NULL, "AddOne send failed");
irpc->async.fn = irpc_callback;
irpc->async.private = &pong_count;
@@ -192,39 +191,33 @@ static BOOL test_speed(struct torture_context *test,
}
}
- torture_comment(test, "waiting for %d remaining replies (done %d)",
+ torture_comment(tctx, "waiting for %d remaining replies (done %d)\n",
ping_count - pong_count, pong_count);
while (timeval_elapsed(&tv) < 30 && pong_count < ping_count) {
event_loop_once(data->ev);
}
- if (ping_count != pong_count) {
- torture_fail(test, "ping test failed! received %d, sent %d",
- pong_count, ping_count);
- }
+ torture_assert_int_equal(tctx, ping_count, pong_count, "ping test failed");
- torture_comment(test, "echo rate of %.0f messages/sec",
+ torture_comment(tctx, "echo rate of %.0f messages/sec\n",
(ping_count+pong_count)/timeval_elapsed(&tv));
-
- return True;
+ return true;
}
-static BOOL irpc_setup(struct torture_context *test, void **_data)
+static BOOL irpc_setup(struct torture_context *tctx, void **_data)
{
struct irpc_test_data *data;
- *_data = data = talloc(test, struct irpc_test_data);
+ *_data = data = talloc(tctx, struct irpc_test_data);
lp_set_cmdline("lock dir", "lockdir.tmp");
- data->ev = event_context_init(test);
- torture_assert(test,
- data->msg_ctx1 = messaging_init(test, MSG_ID1, data->ev),
+ data->ev = event_context_init(tctx);
+ torture_assert(tctx, data->msg_ctx1 = messaging_init(tctx, MSG_ID1, data->ev),
"Failed to init first messaging context");
- torture_assert(test,
- data->msg_ctx2 = messaging_init(test, MSG_ID2, data->ev),
+ torture_assert(tctx, data->msg_ctx2 = messaging_init(tctx, MSG_ID2, data->ev),
"Failed to init second messaging context");
/* register the server side function */
@@ -239,7 +232,7 @@ static BOOL irpc_setup(struct torture_context *test, void **_data)
struct torture_suite *torture_local_irpc(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-IRPC");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "IRPC");
struct torture_tcase *tcase = torture_suite_add_tcase(suite, "irpc");
int i;
uint32_t *values = talloc_array(tcase, uint32_t, 5);
diff --git a/source4/torture/local/local.c b/source4/torture/local/local.c
index 4a6c43761a..42fe94bc92 100644
--- a/source4/torture/local/local.c
+++ b/source4/torture/local/local.c
@@ -49,17 +49,34 @@
NTSTATUS torture_local_init(void)
{
int i;
- TALLOC_CTX *mem_ctx = talloc_autofree_context();
+ struct torture_suite *suite = torture_suite_create(
+ talloc_autofree_context(),
+ "LOCAL");
+ struct torture_suite *talloc_suite = torture_suite_create(
+ talloc_autofree_context(),
+ "TALLOC");
- register_torture_op("LOCAL-REPLACE", torture_local_replace);
- register_torture_op("LOCAL-TALLOC", torture_local_talloc);
- register_torture_op("LOCAL-CRYPTO-MD4", torture_local_crypto_md4);
- register_torture_op("LOCAL-CRYPTO-MD5", torture_local_crypto_md5);
- register_torture_op("LOCAL-CRYPTO-HMACMD5", torture_local_crypto_hmacmd5);
- register_torture_op("LOCAL-CRYPTO-SHA1", torture_local_crypto_sha1);
- register_torture_op("LOCAL-CRYPTO-HMACSHA1", torture_local_crypto_hmacsha1);
+ torture_local_talloc(talloc_suite);
+ torture_suite_add_suite(suite, talloc_suite);
+ torture_suite_add_simple_test(suite, "REPLACE", torture_local_replace);
+ torture_suite_add_simple_test(suite, "CRYPTO-SHA1",
+ torture_local_crypto_sha1);
+ torture_suite_add_simple_test(suite,
+ "CRYPTO-MD4", torture_local_crypto_md4);
+ torture_suite_add_simple_test(suite, "CRYPTO-MD5",
+ torture_local_crypto_md5);
+ torture_suite_add_simple_test(suite, "CRYPTO-HMACMD5",
+ torture_local_crypto_hmacmd5);
+ torture_suite_add_simple_test(suite, "CRYPTO-HMACSHA1",
+ torture_local_crypto_hmacsha1);
for (i = 0; suite_generators[i]; i++)
- torture_register_suite(suite_generators[i](mem_ctx));
+ torture_suite_add_suite(suite,
+ suite_generators[i](talloc_autofree_context()));
+
+ suite->description = talloc_strdup(suite,
+ "Local, Samba-specific tests");
+
+ torture_register_suite(suite);
return NT_STATUS_OK;
}
diff --git a/source4/torture/local/messaging.c b/source4/torture/local/messaging.c
index 8161c3ea4f..27c343948b 100644
--- a/source4/torture/local/messaging.c
+++ b/source4/torture/local/messaging.c
@@ -55,7 +55,7 @@ static void exit_message(struct messaging_context *msg, void *private,
/*
test ping speed
*/
-static BOOL test_ping_speed(struct torture_context *torture, const void *_data)
+static bool test_ping_speed(struct torture_context *tctx)
{
struct event_context *ev;
struct messaging_context *msg_client_ctx;
@@ -63,35 +63,30 @@ static BOOL test_ping_speed(struct torture_context *torture, const void *_data)
int ping_count = 0;
int pong_count = 0;
struct timeval tv;
- int timelimit = lp_parm_int(-1, "torture", "timelimit", 10);
+ int timelimit = torture_setting_int(tctx, "timelimit", 10);
uint32_t msg_ping, msg_exit;
+ TALLOC_CTX *mem_ctx = tctx;
lp_set_cmdline("lock dir", "lockdir.tmp");
- ev = event_context_init(torture);
+ ev = event_context_init(mem_ctx);
- msg_server_ctx = messaging_init(torture, 1, ev);
+ msg_server_ctx = messaging_init(mem_ctx, 1, ev);
- if (!msg_server_ctx) {
- torture_fail(torture, "Failed to init ping messaging context");
- return False;
- }
+ torture_assert(tctx, msg_server_ctx != NULL, "Failed to init ping messaging context");
messaging_register_tmp(msg_server_ctx, NULL, ping_message, &msg_ping);
- messaging_register_tmp(msg_server_ctx, torture, exit_message, &msg_exit);
+ messaging_register_tmp(msg_server_ctx, mem_ctx, exit_message, &msg_exit);
- msg_client_ctx = messaging_init(torture, 2, ev);
+ msg_client_ctx = messaging_init(mem_ctx, 2, ev);
- if (!msg_client_ctx) {
- torture_fail(torture, "msg_client_ctx messaging_init() failed");
- return False;
- }
+ torture_assert(tctx, msg_client_ctx != NULL, "msg_client_ctx messaging_init() failed");
messaging_register_tmp(msg_client_ctx, &pong_count, pong_message, &msg_pong);
tv = timeval_current();
- torture_comment(torture, "Sending pings for %d seconds", timelimit);
+ torture_comment(tctx, "Sending pings for %d seconds", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
DATA_BLOB data;
NTSTATUS status1, status2;
@@ -102,51 +97,41 @@ static BOOL test_ping_speed(struct torture_context *torture, const void *_data)
status1 = messaging_send(msg_client_ctx, 1, msg_ping, &data);
status2 = messaging_send(msg_client_ctx, 1, msg_ping, NULL);
- if (!NT_STATUS_IS_OK(status1)) {
- torture_fail(torture, "msg1 failed - %s", nt_errstr(status1));
- } else {
- ping_count++;
- }
+ torture_assert_ntstatus_ok(tctx, status1, "msg1 failed");
+ ping_count++;
- if (!NT_STATUS_IS_OK(status2)) {
- torture_fail(torture, "msg2 failed - %s", nt_errstr(status2));
- } else {
- ping_count++;
- }
+ torture_assert_ntstatus_ok(tctx, status2, "msg2 failed");
+ ping_count++;
while (ping_count > pong_count + 20) {
event_loop_once(ev);
}
}
- torture_comment(torture, "waiting for %d remaining replies (done %d)",
+ torture_comment(tctx, "waiting for %d remaining replies (done %d)",
ping_count - pong_count, pong_count);
while (timeval_elapsed(&tv) < 30 && pong_count < ping_count) {
event_loop_once(ev);
}
- torture_comment(torture, "sending exit");
+ torture_comment(tctx, "sending exit");
messaging_send(msg_client_ctx, 1, msg_exit, NULL);
- if (ping_count != pong_count) {
- torture_fail(torture, "ping test failed! received %d, sent %d",
- pong_count, ping_count);
- }
+ torture_assert_int_equal(tctx, ping_count, pong_count, "ping test failed");
- torture_comment(torture, "ping rate of %.0f messages/sec",
+ torture_comment(tctx, "ping rate of %.0f messages/sec",
(ping_count+pong_count)/timeval_elapsed(&tv));
talloc_free(msg_client_ctx);
talloc_free(msg_server_ctx);
talloc_free(ev);
-
- return True;
+ return true;
}
struct torture_suite *torture_local_messaging(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *s = torture_suite_create(mem_ctx, "LOCAL-MESSAGING");
- torture_suite_add_simple_tcase(s, "ping_speed", test_ping_speed, NULL);
+ struct torture_suite *s = torture_suite_create(mem_ctx, "MESSAGING");
+ torture_suite_add_simple_test(s, "ping_speed", test_ping_speed);
return s;
}
diff --git a/source4/torture/local/ndr.c b/source4/torture/local/ndr.c
index a24c64746a..b14b066455 100644
--- a/source4/torture/local/ndr.c
+++ b/source4/torture/local/ndr.c
@@ -23,64 +23,59 @@
#include "torture/torture.h"
#include "librpc/ndr/libndr.h"
-static BOOL test_check_string_terminator(struct torture_context *test,
- const void *_data)
+static bool test_check_string_terminator(struct torture_context *tctx)
{
struct ndr_pull *ndr;
DATA_BLOB blob;
+ TALLOC_CTX *mem_ctx = tctx;
/* Simple test */
blob = strhex_to_data_blob("0000");
- ndr = ndr_pull_init_blob(&blob, test);
+ ndr = ndr_pull_init_blob(&blob, mem_ctx);
- torture_assert_ntstatus_ok(test,
- ndr_check_string_terminator(ndr, 1, 2),
+ torture_assert_ntstatus_ok(tctx, ndr_check_string_terminator(ndr, 1, 2),
"simple check_string_terminator test failed");
- torture_assert(test, ndr->offset == 0,
+ torture_assert(tctx, ndr->offset == 0,
"check_string_terminator did not reset offset");
if (NT_STATUS_IS_OK(ndr_check_string_terminator(ndr, 1, 3))) {
- torture_fail(test, "check_string_terminator checked beyond string boundaries");
- return False;
+ torture_fail(tctx, "check_string_terminator checked beyond string boundaries");
}
- torture_assert(test, ndr->offset == 0,
+ torture_assert(tctx, ndr->offset == 0,
"check_string_terminator did not reset offset");
talloc_free(ndr);
blob = strhex_to_data_blob("11220000");
- ndr = ndr_pull_init_blob(&blob, test);
+ ndr = ndr_pull_init_blob(&blob, mem_ctx);
- torture_assert_ntstatus_ok(test,
+ torture_assert_ntstatus_ok(tctx,
ndr_check_string_terminator(ndr, 4, 1),
"check_string_terminator failed to recognize terminator");
- torture_assert_ntstatus_ok(test,
+ torture_assert_ntstatus_ok(tctx,
ndr_check_string_terminator(ndr, 3, 1),
"check_string_terminator failed to recognize terminator");
if (NT_STATUS_IS_OK(ndr_check_string_terminator(ndr, 2, 1))) {
- torture_fail(test,
+ torture_fail(tctx,
"check_string_terminator erroneously reported terminator");
- return False;
}
- torture_assert (test, ndr->offset == 0,
+ torture_assert(tctx, ndr->offset == 0,
"check_string_terminator did not reset offset");
-
- return True;
+ return true;
}
struct torture_suite *torture_local_ndr(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-NDR");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "NDR");
- torture_suite_add_simple_tcase(suite, "string terminator",
- test_check_string_terminator,
- NULL);
+ torture_suite_add_simple_test(suite, "string terminator",
+ test_check_string_terminator);
return suite;
}
diff --git a/source4/torture/local/registry.c b/source4/torture/local/registry.c
index 0e72c11aeb..d200ba6e1b 100644
--- a/source4/torture/local/registry.c
+++ b/source4/torture/local/registry.c
@@ -36,50 +36,51 @@ const static struct test_backend_settings {
{ NULL, NULL }
};
-static BOOL test_hive(struct torture_context *ctx, const void *_backend)
+static bool test_hive(struct torture_context *tctx,
+ const void *test_data)
{
WERROR error;
struct registry_key *root, *subkey;
uint32_t count;
- const struct test_backend_settings *backend = _backend;
+ const struct test_backend_settings *backend = test_data;
+ TALLOC_CTX *mem_ctx = tctx;
if (!reg_has_backend(backend->name)) {
- torture_skip(ctx, "Backend '%s' support not compiled in",
- backend->name);
- return True;
+ torture_skip(tctx, talloc_asprintf(tctx,
+ "Backend '%s' support not compiled in", backend->name));
}
- error = reg_open_hive(ctx, backend->name,
+ error = reg_open_hive(mem_ctx, backend->name,
backend->location, NULL, cmdline_credentials, &root);
- torture_assert_werr_ok(ctx, error, "reg_open_hive()");
+ torture_assert_werr_ok(tctx, error, "reg_open_hive()");
/* This is a new backend. There should be no subkeys and no
* values */
error = reg_key_num_subkeys(root, &count);
- torture_assert_werr_ok(ctx, error, "reg_key_num_subkeys()");
+ torture_assert_werr_ok(tctx, error, "reg_key_num_subkeys()");
- torture_assert(ctx, count != 0, "New key has non-zero subkey count");
+ torture_assert(tctx, count != 0, "New key has non-zero subkey count");
error = reg_key_num_values(root, &count);
- torture_assert_werr_ok(ctx, error, "reg_key_num_values");
+ torture_assert_werr_ok(tctx, error, "reg_key_num_values");
- torture_assert(ctx, count != 0, "New key has non-zero value count");
+ torture_assert(tctx, count != 0, "New key has non-zero value count");
- error = reg_key_add_name(ctx, root, "Nested\\Key", SEC_MASK_GENERIC, NULL, &subkey);
- torture_assert_werr_ok(ctx, error, "reg_key_add_name");
+ error = reg_key_add_name(mem_ctx, root, "Nested\\Key", SEC_MASK_GENERIC, NULL, &subkey);
+ torture_assert_werr_ok(tctx, error, "reg_key_add_name");
error = reg_key_del(root, "Nested\\Key");
- torture_assert_werr_ok(ctx, error, "reg_key_del");
+ torture_assert_werr_ok(tctx, error, "reg_key_del");
talloc_free(root);
-
- return True;
+ return true;
}
+
struct torture_suite *torture_registry(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx,
- "LOCAL-REGISTRY");
+ "REGISTRY");
int i;
registry_init();
diff --git a/source4/torture/local/resolve.c b/source4/torture/local/resolve.c
index a9878e88ee..62aa600a3c 100644
--- a/source4/torture/local/resolve.c
+++ b/source4/torture/local/resolve.c
@@ -25,68 +25,67 @@
#include "libcli/resolve/resolve.h"
#include "torture/torture.h"
-static BOOL test_async_resolve(struct torture_context *test, const void *_data)
+static bool test_async_resolve(struct torture_context *tctx)
{
struct nbt_name n;
struct event_context *ev;
- int timelimit = lp_parm_int(-1, "torture", "timelimit", 10);
- const char *host = lp_parm_string(-1, "torture", "host");
+ int timelimit = torture_setting_int(tctx, "timelimit", 10);
+ const char *host = torture_setting_string(tctx, "host", NULL);
int count = 0;
struct timeval tv = timeval_current();
+ TALLOC_CTX *mem_ctx = tctx;
- ev = event_context_init(test);
+ ev = event_context_init(mem_ctx);
ZERO_STRUCT(n);
n.name = host;
- torture_comment(test, "Testing async resolve of localhost for %d seconds",
+ torture_comment(tctx, "Testing async resolve of localhost for %d seconds\n",
timelimit);
while (timeval_elapsed(&tv) < timelimit) {
const char *s;
struct composite_context *c = resolve_name_host_send(&n, ev);
- torture_assert(test, c, "resolve_name_host_send");
- torture_assert_ntstatus_ok(test, resolve_name_host_recv(c, test, &s),
+ torture_assert(tctx, c != NULL, "resolve_name_host_send");
+ torture_assert_ntstatus_ok(tctx, resolve_name_host_recv(c, mem_ctx, &s),
"async resolve failed");
count++;
}
- torture_comment(test, "async rate of %.1f resolves/sec",
+ torture_comment(tctx, "async rate of %.1f resolves/sec\n",
count/timeval_elapsed(&tv));
-
- return True;
+ return true;
}
/*
test resolution using sync method
*/
-static BOOL test_sync_resolve(struct torture_context *test, const void *_data)
+static bool test_sync_resolve(struct torture_context *tctx)
{
- int timelimit = lp_parm_int(-1, "torture", "timelimit", 10);
+ int timelimit = torture_setting_int(tctx, "timelimit", 10);
struct timeval tv = timeval_current();
int count = 0;
- const char *host = lp_parm_string(-1, "torture", "host");
+ const char *host = torture_setting_string(tctx, "host", NULL);
- torture_comment(test, "Testing sync resolve of localhost for %d seconds",
+ torture_comment(tctx, "Testing sync resolve of localhost for %d seconds\n",
timelimit);
while (timeval_elapsed(&tv) < timelimit) {
sys_inet_ntoa(interpret_addr2(host));
count++;
}
- torture_comment(test, "sync rate of %.1f resolves/sec",
+ torture_comment(tctx, "sync rate of %.1f resolves/sec\n",
count/timeval_elapsed(&tv));
-
- return True;
+ return true;
}
struct torture_suite *torture_local_resolve(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx,
- "LOCAL-RESOLVE");
+ "RESOLVE");
- torture_suite_add_simple_tcase(suite, "async", test_async_resolve, NULL);
- torture_suite_add_simple_tcase(suite, "sync", test_sync_resolve, NULL);
+ torture_suite_add_simple_test(suite, "async", test_async_resolve);
+ torture_suite_add_simple_test(suite, "sync", test_sync_resolve);
return suite;
}
diff --git a/source4/torture/local/sddl.c b/source4/torture/local/sddl.c
index 2db1006380..1bc6457a67 100644
--- a/source4/torture/local/sddl.c
+++ b/source4/torture/local/sddl.c
@@ -29,37 +29,31 @@
/*
test one SDDL example
*/
-static BOOL test_sddl(struct torture_context *mem_ctx, const void *_sddl)
+static bool test_sddl(struct torture_context *tctx,
+ const void *test_data)
{
struct security_descriptor *sd, *sd2;
struct dom_sid *domain;
- const char *sddl = _sddl;
+ const char *sddl = test_data;
const char *sddl2;
+ TALLOC_CTX *mem_ctx = tctx;
domain = dom_sid_parse_talloc(mem_ctx, "S-1-2-3-4");
sd = sddl_decode(mem_ctx, sddl, domain);
- if (sd == NULL) {
- printf("Failed to decode '%s'\n", sddl);
- return False;
- }
+ torture_assert(tctx, sd != NULL, talloc_asprintf(tctx,
+ "Failed to decode '%s'\n", sddl));
sddl2 = sddl_encode(mem_ctx, sd, domain);
- if (sddl2 == NULL) {
- printf("Failed to re-encode '%s'\n", sddl);
- return False;
- }
+ torture_assert(tctx, sddl2 != NULL, talloc_asprintf(tctx,
+ "Failed to re-encode '%s'\n", sddl));
sd2 = sddl_decode(mem_ctx, sddl2, domain);
- if (sd2 == NULL) {
- printf("Failed to decode2 '%s'\n", sddl2);
- return False;
- }
+ torture_assert(tctx, sd2 != NULL, talloc_asprintf(tctx,
+ "Failed to decode2 '%s'\n", sddl2));
- if (!security_descriptor_equal(sd, sd2)) {
- printf("Failed equality test for '%s'\n", sddl);
- return False;
- }
+ torture_assert(tctx, security_descriptor_equal(sd, sd2),
+ talloc_asprintf(tctx, "Failed equality test for '%s'\n", sddl));
#if 0
/* flags don't have a canonical order ... */
@@ -73,7 +67,7 @@ static BOOL test_sddl(struct torture_context *mem_ctx, const void *_sddl)
}
talloc_free(sd);
talloc_free(domain);
- return True;
+ return true;
}
static const char *examples[] = {
@@ -99,7 +93,7 @@ static const char *examples[] = {
/* test a set of example SDDL strings */
struct torture_suite *torture_local_sddl(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-SDDL");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "SDDL");
int i;
for (i = 0; i < ARRAY_SIZE(examples); i++) {
diff --git a/source4/torture/local/socket.c b/source4/torture/local/socket.c
index a49e0dd93e..e2f9896b33 100644
--- a/source4/torture/local/socket.c
+++ b/source4/torture/local/socket.c
@@ -30,7 +30,7 @@
/*
basic testing of udp routines
*/
-static BOOL test_udp(struct torture_context *test, const void *data)
+static bool test_udp(struct torture_context *tctx)
{
struct socket_context *sock1, *sock2;
NTSTATUS status;
@@ -38,95 +38,79 @@ static BOOL test_udp(struct torture_context *test, const void *data)
size_t size = 100 + (random() % 100);
DATA_BLOB blob, blob2;
size_t sent, nread;
- BOOL ret = True;
+ TALLOC_CTX *mem_ctx = tctx;
status = socket_create("ip", SOCKET_TYPE_DGRAM, &sock1, 0);
- torture_assert_ntstatus_ok(test, status, "creating DGRAM IP socket 1");
- talloc_steal(test, sock1);
+ torture_assert_ntstatus_ok(tctx, status, "creating DGRAM IP socket 1");
+ talloc_steal(mem_ctx, sock1);
status = socket_create("ip", SOCKET_TYPE_DGRAM, &sock2, 0);
- torture_assert_ntstatus_ok(test, status, "creating DGRAM IP socket 1");
- talloc_steal(test, sock2);
+ torture_assert_ntstatus_ok(tctx, status, "creating DGRAM IP socket 1");
+ talloc_steal(mem_ctx, sock2);
localhost = socket_address_from_strings(sock1, sock1->backend_name,
iface_best_ip("127.0.0.1"), 0);
- torture_assert(test, localhost, "Localhost not found");
+ torture_assert(tctx, localhost, "Localhost not found");
status = socket_listen(sock1, localhost, 0, 0);
- torture_assert_ntstatus_ok(test, status, "listen on socket 1");
+ torture_assert_ntstatus_ok(tctx, status, "listen on socket 1");
- srv_addr = socket_get_my_addr(sock1, test);
- if (srv_addr == NULL || strcmp(srv_addr->addr, iface_best_ip("127.0.0.1")) != 0) {
- torture_fail(test, "Expected server address of %s but got %s",
- iface_best_ip("127.0.0.1"), srv_addr ? srv_addr->addr : NULL);
- return False;
- }
+ srv_addr = socket_get_my_addr(sock1, mem_ctx);
+ torture_assert(tctx, srv_addr != NULL && strcmp(srv_addr->addr, iface_best_ip("127.0.0.1")) == 0,
+ talloc_asprintf(tctx,
+ "Expected server address of %s but got %s",
+ iface_best_ip("127.0.0.1"), srv_addr ? srv_addr->addr : NULL));
- torture_comment(test, "server port is %d", srv_addr->port);
+ torture_comment(tctx, "server port is %d\n", srv_addr->port);
- blob = data_blob_talloc(test, NULL, size);
- blob2 = data_blob_talloc(test, NULL, size);
+ blob = data_blob_talloc(mem_ctx, NULL, size);
+ blob2 = data_blob_talloc(mem_ctx, NULL, size);
generate_random_buffer(blob.data, blob.length);
sent = size;
status = socket_sendto(sock2, &blob, &sent, srv_addr);
- torture_assert_ntstatus_ok(test, status, "sendto() on socket 2");
+ torture_assert_ntstatus_ok(tctx, status, "sendto() on socket 2");
status = socket_recvfrom(sock1, blob2.data, size, &nread,
sock1, &from_addr);
- torture_assert_ntstatus_ok(test, status, "recvfrom() on socket 1");
-
- if (strcmp(from_addr->addr, srv_addr->addr) != 0) {
- torture_fail(test, "Unexpected recvfrom addr %s", from_addr->addr);
- return False;
- }
- if (nread != size) {
- torture_fail(test, "Unexpected recvfrom size %d should be %d\n",
- (int)nread, (int)size);
- return False;
- }
-
- torture_assert(test, memcmp(blob2.data, blob.data, size) == 0,
+ torture_assert_ntstatus_ok(tctx, status, "recvfrom() on socket 1");
+
+ torture_assert_str_equal(tctx, from_addr->addr, srv_addr->addr,
+ "different address");
+
+ torture_assert_int_equal(tctx, nread, size, "Unexpected recvfrom size");
+
+ torture_assert(tctx, memcmp(blob2.data, blob.data, size) == 0,
"Bad data in recvfrom");
generate_random_buffer(blob.data, blob.length);
status = socket_sendto(sock1, &blob, &sent, from_addr);
- torture_assert_ntstatus_ok(test, status, "sendto() on socket 1");
+ torture_assert_ntstatus_ok(tctx, status, "sendto() on socket 1");
status = socket_recvfrom(sock2, blob2.data, size, &nread,
sock2, &from_addr);
- torture_assert_ntstatus_ok(test, status, "recvfrom() on socket 2");
- if (strcmp(from_addr->addr, srv_addr->addr) != 0) {
- torture_fail(test, "Unexpected recvfrom addr %s\n", from_addr->addr);
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "recvfrom() on socket 2");
+ torture_assert_str_equal(tctx, from_addr->addr, srv_addr->addr,
+ "Unexpected recvfrom addr");
- if (nread != size) {
- torture_fail(test, "Unexpected recvfrom size %d should be %d\n",
- (int)nread, (int)size);
- return False;
- }
-
- if (from_addr->port != srv_addr->port) {
- torture_fail(test, "Unexpected recvfrom port %d should be %d\n",
- from_addr->port, srv_addr->port);
- return False;
- }
-
- torture_assert(test, memcmp(blob2.data, blob.data, size) == 0,
+ torture_assert_int_equal(tctx, nread, size, "Unexpected recvfrom size");
+
+ torture_assert_int_equal(tctx, from_addr->port, srv_addr->port,
+ "Unexpected recvfrom port");
+
+ torture_assert(tctx, memcmp(blob2.data, blob.data, size) == 0,
"Bad data in recvfrom");
talloc_free(sock1);
talloc_free(sock2);
-
- return ret;
+ return true;
}
/*
basic testing of tcp routines
*/
-static BOOL test_tcp(struct torture_context *test, const void *data)
+static bool test_tcp(struct torture_context *tctx)
{
struct socket_context *sock1, *sock2, *sock3;
NTSTATUS status;
@@ -134,84 +118,74 @@ static BOOL test_tcp(struct torture_context *test, const void *data)
size_t size = 100 + (random() % 100);
DATA_BLOB blob, blob2;
size_t sent, nread;
- struct event_context *ev = event_context_init(test);
+ TALLOC_CTX *mem_ctx = tctx;
+ struct event_context *ev = event_context_init(mem_ctx);
status = socket_create("ip", SOCKET_TYPE_STREAM, &sock1, 0);
- torture_assert_ntstatus_ok(test, status, "creating IP stream socket 1");
- talloc_steal(test, sock1);
+ torture_assert_ntstatus_ok(tctx, status, "creating IP stream socket 1");
+ talloc_steal(mem_ctx, sock1);
status = socket_create("ip", SOCKET_TYPE_STREAM, &sock2, 0);
- torture_assert_ntstatus_ok(test, status, "creating IP stream socket 1");
- talloc_steal(test, sock2);
+ torture_assert_ntstatus_ok(tctx, status, "creating IP stream socket 1");
+ talloc_steal(mem_ctx, sock2);
localhost = socket_address_from_strings(sock1, sock1->backend_name,
iface_best_ip("127.0.0.1"), 0);
- torture_assert(test, localhost, "Localhost not found");
+ torture_assert(tctx, localhost, "Localhost not found");
status = socket_listen(sock1, localhost, 0, 0);
- torture_assert_ntstatus_ok(test, status, "listen on socket 1");
+ torture_assert_ntstatus_ok(tctx, status, "listen on socket 1");
- srv_addr = socket_get_my_addr(sock1, test);
- torture_assert(test, srv_addr && srv_addr->addr,
+ srv_addr = socket_get_my_addr(sock1, mem_ctx);
+ torture_assert(tctx, srv_addr && srv_addr->addr,
"Unexpected socket_get_my_addr NULL\n");
- if (strcmp(srv_addr->addr, iface_best_ip("127.0.0.1")) != 0) {
- torture_fail(test, "Expected server address of %s but got %s\n",
- iface_best_ip("127.0.0.1"), srv_addr ? srv_addr->addr : NULL);
- return False;
- }
+ torture_assert_str_equal(tctx, srv_addr->addr, iface_best_ip("127.0.0.1"),
+ "Unexpected server address");
- torture_comment(test, "server port is %d", srv_addr->port);
+ torture_comment(tctx, "server port is %d\n", srv_addr->port);
status = socket_connect_ev(sock2, NULL, srv_addr, 0, ev);
- torture_assert_ntstatus_ok(test, status, "connect() on socket 2");
+ torture_assert_ntstatus_ok(tctx, status, "connect() on socket 2");
status = socket_accept(sock1, &sock3);
- torture_assert_ntstatus_ok(test, status, "accept() on socket 1");
- talloc_steal(test, sock3);
+ torture_assert_ntstatus_ok(tctx, status, "accept() on socket 1");
+ talloc_steal(mem_ctx, sock3);
talloc_free(sock1);
- blob = data_blob_talloc(test, NULL, size);
- blob2 = data_blob_talloc(test, NULL, size);
+ blob = data_blob_talloc(mem_ctx, NULL, size);
+ blob2 = data_blob_talloc(mem_ctx, NULL, size);
generate_random_buffer(blob.data, blob.length);
sent = size;
status = socket_send(sock2, &blob, &sent);
- torture_assert_ntstatus_ok(test, status, "send() on socket 2");
+ torture_assert_ntstatus_ok(tctx, status, "send() on socket 2");
status = socket_recv(sock3, blob2.data, size, &nread);
- torture_assert_ntstatus_ok(test, status, "recv() on socket 3");
+ torture_assert_ntstatus_ok(tctx, status, "recv() on socket 3");
- from_addr = socket_get_peer_addr(sock3, test);
+ from_addr = socket_get_peer_addr(sock3, mem_ctx);
- torture_assert(test, from_addr && from_addr->addr,
+ torture_assert(tctx, from_addr && from_addr->addr,
"Unexpected recvfrom addr NULL");
- if (strcmp(from_addr->addr, srv_addr->addr) != 0) {
- torture_fail(test, "Unexpected recvfrom addr %s\n",
- from_addr ? from_addr->addr : NULL);
- return False;
- }
- if (nread != size) {
- torture_fail(test, "Unexpected recvfrom size %d should be %d\n",
- (int)nread, (int)size);
- return False;
- }
-
- torture_assert(test,
- memcmp(blob2.data, blob.data, size) == 0,
- "Bad data in recv");
+ torture_assert_str_equal(tctx, from_addr->addr, srv_addr->addr,
+ "Unexpected recvfrom addr");
- return True;
+ torture_assert_int_equal(tctx, nread, size, "Unexpected recvfrom size");
+
+ torture_assert(tctx, memcmp(blob2.data, blob.data, size) == 0,
+ "Bad data in recv");
+ return true;
}
struct torture_suite *torture_local_socket(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx,
- "LOCAL-SOCKET");
+ "SOCKET");
- torture_suite_add_simple_tcase(suite, "udp", test_udp, NULL);
- torture_suite_add_simple_tcase(suite, "tcp", test_tcp, NULL);
+ torture_suite_add_simple_test(suite, "udp", test_udp);
+ torture_suite_add_simple_test(suite, "tcp", test_tcp);
return suite;
}
diff --git a/source4/torture/local/torture.c b/source4/torture/local/torture.c
index 67712e3ee7..4a5bc99d35 100644
--- a/source4/torture/local/torture.c
+++ b/source4/torture/local/torture.c
@@ -27,58 +27,57 @@
#include "libcli/raw/libcliraw.h"
#include "torture/util.h"
-static BOOL test_tempdir(struct torture_context *torture,
- const void *_data)
+static bool test_tempdir(struct torture_context *tctx)
{
char *location = NULL;
+ TALLOC_CTX *mem_ctx = tctx;
- torture_assert_ntstatus_ok(torture, torture_temp_dir(torture, "tempdir", &location),
+ torture_assert_ntstatus_ok(tctx, torture_temp_dir(mem_ctx, "tempdir", &location),
"torture_temp_dir should return NT_STATUS_OK" );
- torture_assert(torture, directory_exist(location),
+ torture_assert(tctx, directory_exist(location),
"created dir doesn't exist");
-
- return True;
+ return true;
}
-static BOOL test_setup_server(struct torture_context *torture,
- const void *_data)
+static bool test_setup_server(struct torture_context *tctx)
{
pid_t pid;
+ TALLOC_CTX *mem_ctx = tctx;
- torture_assert_ntstatus_ok(torture, torture_setup_server(torture,
+ torture_assert_ntstatus_ok(tctx, torture_setup_server(mem_ctx,
"setupserver-success",
"./script/tests/mktestsetup.sh",
"./bin/smbd", &pid),
"starting smbd failed");
- torture_assert(torture, pid > 0, "Pid invalid");
+ torture_assert(tctx, pid > 0, "Pid invalid");
- torture_comment(torture, "Created smbd with pid %d", pid);
+ torture_comment(tctx, "Created smbd with pid %d\n", pid);
kill(pid, SIGINT);
waitpid(pid, NULL, 0);
- torture_assert_ntstatus_equal(torture, torture_setup_server(torture,
+ torture_assert_ntstatus_equal(tctx, torture_setup_server(mem_ctx,
"setupserver-fail",
"./invalid-script",
"./bin/smbd", &pid),
NT_STATUS_UNSUCCESSFUL,
"invalid script specified");
- torture_assert(torture, pid == -1, "Pid not -1 after failure");
-
- return True;
+ torture_assert(tctx, pid == -1, "Pid not -1 after failure");
+ return true;
}
+
struct torture_suite *torture_local_torture(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx,
- "LOCAL-TORTURE");
+ "TORTURE");
- torture_suite_add_simple_tcase(suite, "tempdir", test_tempdir, NULL);
- torture_suite_add_simple_tcase(suite, "setup server", test_setup_server, NULL);
+ torture_suite_add_simple_test(suite, "tempdir", test_tempdir);
+ torture_suite_add_simple_test(suite, "setup server", test_setup_server);
return suite;
}
diff --git a/source4/torture/local/util_file.c b/source4/torture/local/util_file.c
index 3c11d3d94e..87d25b222e 100644
--- a/source4/torture/local/util_file.c
+++ b/source4/torture/local/util_file.c
@@ -31,66 +31,65 @@
#define TEST_DATA TEST_LINE1 "\n" TEST_LINE2 "\n" TEST_LINE3
-static BOOL test_file_load_save(struct torture_context *test, const void *_data)
+static bool test_file_load_save(struct torture_context *tctx)
{
size_t len;
char *data;
+ TALLOC_CTX *mem_ctx = tctx;
- torture_assert(test,
- file_save(TEST_FILENAME, TEST_DATA, strlen(TEST_DATA)),
+ torture_assert(tctx, file_save(TEST_FILENAME, TEST_DATA, strlen(TEST_DATA)),
"saving file");
- data = file_load(TEST_FILENAME, &len, test);
- torture_assert(test, data, "loading file");
+ data = file_load(TEST_FILENAME, &len, mem_ctx);
+ torture_assert(tctx, data, "loading file");
- torture_assert(test, len == strlen(TEST_DATA), "Length");
+ torture_assert(tctx, len == strlen(TEST_DATA), "Length");
- torture_assert(test, memcmp(data, TEST_DATA, len) == 0, "Contents");
+ torture_assert(tctx, memcmp(data, TEST_DATA, len) == 0, "Contents");
unlink(TEST_FILENAME);
-
- return True;
+ return true;
}
-static BOOL test_afdgets(struct torture_context *test, const void *data)
+
+static bool test_afdgets(struct torture_context *tctx)
{
int fd;
char *line;
+ TALLOC_CTX *mem_ctx = tctx;
- torture_assert(test,
- file_save(TEST_FILENAME, (const void *)TEST_DATA,
+ torture_assert(tctx, file_save(TEST_FILENAME, (const void *)TEST_DATA,
strlen(TEST_DATA)),
"saving file");
fd = open(TEST_FILENAME, O_RDONLY);
- torture_assert(test, fd != -1, "opening file");
+ torture_assert(tctx, fd != -1, "opening file");
- line = afdgets(fd, test, 8);
- torture_assert(test, strcmp(line, TEST_LINE1) == 0, "line 1 mismatch");
+ line = afdgets(fd, mem_ctx, 8);
+ torture_assert(tctx, strcmp(line, TEST_LINE1) == 0, "line 1 mismatch");
- line = afdgets(fd, test, 8);
- torture_assert(test, strcmp(line, TEST_LINE2) == 0, "line 2 mismatch");
+ line = afdgets(fd, mem_ctx, 8);
+ torture_assert(tctx, strcmp(line, TEST_LINE2) == 0, "line 2 mismatch");
- line = afdgets(fd, test, 8);
- torture_assert(test, strcmp(line, TEST_LINE3) == 0, "line 3 mismatch");
+ line = afdgets(fd, mem_ctx, 8);
+ torture_assert(tctx, strcmp(line, TEST_LINE3) == 0, "line 3 mismatch");
close(fd);
unlink(TEST_FILENAME);
-
- return True;
+ return true;
}
struct torture_suite *torture_local_util_file(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-FILE");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "FILE");
- torture_suite_add_simple_tcase(suite, "file_load_save",
- test_file_load_save, NULL);
+ torture_suite_add_simple_test(suite, "file_load_save",
+ test_file_load_save);
- torture_suite_add_simple_tcase(suite, "afdgets",
- test_afdgets, NULL);
+ torture_suite_add_simple_test(suite, "afdgets",
+ test_afdgets);
return suite;
}
diff --git a/source4/torture/local/util_strlist.c b/source4/torture/local/util_strlist.c
index 65f8bc914a..7dbb5f8ce6 100644
--- a/source4/torture/local/util_strlist.c
+++ b/source4/torture/local/util_strlist.c
@@ -33,15 +33,17 @@ static const char *test_lists_shell_strings[] = {
NULL
};
-static BOOL test_lists_shell(struct torture_context *test, const void *_data)
+static bool test_lists_shell(struct torture_context *tctx,
+ const void *test_data)
{
- const char *data = _data;
+ const char *data = test_data;
const char **ret1, **ret2, *tmp;
BOOL match = True;
+ TALLOC_CTX *mem_ctx = tctx;
- ret1 = str_list_make_shell(test, data, " ");
- tmp = str_list_join_shell(test, ret1, ' ');
- ret2 = str_list_make_shell(test, tmp, " ");
+ ret1 = str_list_make_shell(mem_ctx, data, " ");
+ tmp = str_list_join_shell(mem_ctx, ret1, ' ');
+ ret2 = str_list_make_shell(mem_ctx, tmp, " ");
if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) {
match = False;
@@ -58,17 +60,14 @@ static BOOL test_lists_shell(struct torture_context *test, const void *_data)
match = False;
}
- if (!match) {
- torture_fail(test, "str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s", data, tmp);
- return False;
- }
-
- return True;
+ torture_assert(tctx, match, talloc_asprintf(tctx,
+ "str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s", data, tmp));
+ return true;
}
struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-STRLIST");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "STRLIST");
int i;
for (i = 0; test_lists_shell_strings[i]; i++) {