-/*
+/*
Unix SMB/CIFS implementation.
local testing of talloc routines.
Copyright (C) Andrew Tridgell 2004
-
+
** NOTE! The following LGPL license applies to the talloc
** library. This does NOT imply that all of Samba is released
** under the LGPL
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
static double private_timeval_elapsed(struct timeval *tv)
{
struct timeval tv2 = private_timeval_current();
- return (tv2.tv_sec - tv->tv_sec) +
+ return (tv2.tv_sec - tv->tv_sec) +
(tv2.tv_usec - tv->tv_usec)*1.0e-6;
}
}
/*
- test references
+ test references
*/
static bool test_ref1(void)
{
talloc_named_const(p1, 2, "x2");
talloc_named_const(p1, 3, "x3");
- r1 = talloc_named_const(root, 1, "r1");
+ r1 = talloc_named_const(root, 1, "r1");
ref = talloc_reference(r1, p2);
talloc_report_full(root, stderr);
}
/*
- test references
+ test references
*/
static bool test_ref2(void)
{
talloc_named_const(p1, 1, "x3");
p2 = talloc_named_const(p1, 1, "p2");
- r1 = talloc_named_const(root, 1, "r1");
+ r1 = talloc_named_const(root, 1, "r1");
ref = talloc_reference(r1, p2);
talloc_report_full(root, stderr);
}
/*
- test references
+ test references
*/
static bool test_ref3(void)
{
}
/*
- test references
+ test references
*/
static bool test_ref4(void)
{
talloc_named_const(p1, 1, "x3");
p2 = talloc_named_const(p1, 1, "p2");
- r1 = talloc_named_const(root, 1, "r1");
+ r1 = talloc_named_const(root, 1, "r1");
ref = talloc_reference(r1, p2);
talloc_report_full(root, stderr);
/*
- test references
+ test references
*/
static bool test_unlink1(void)
{
talloc_named_const(p1, 1, "x3");
p2 = talloc_named_const(p1, 1, "p2");
- r1 = talloc_named_const(p1, 1, "r1");
+ r1 = talloc_named_const(p1, 1, "r1");
ref = talloc_reference(r1, p2);
talloc_report_full(root, stderr);
CHECK_BLOCKS("misc", p1, 2);
CHECK_BLOCKS("misc", root, 3);
- torture_assert("misc", talloc_free(NULL) == -1,
+ torture_assert("misc", talloc_free(NULL) == -1,
"talloc_free(NULL) should give -1\n");
talloc_set_destructor(p1, fail_destructor);
- torture_assert("misc", talloc_free(p1) == -1,
+ torture_assert("misc", talloc_free(p1) == -1,
"Failed destructor should cause talloc_free to fail\n");
talloc_set_destructor(p1, NULL);
"failed: strdup on NULL should give NULL\n");
p2 = talloc_strndup(p1, "foo", 2);
- torture_assert("misc", strcmp("fo", p2) == 0,
+ torture_assert("misc", strcmp("fo", p2) == 0,
"strndup doesn't work\n");
p2 = talloc_asprintf_append_buffer(p2, "o%c", 'd');
- torture_assert("misc", strcmp("food", p2) == 0,
+ torture_assert("misc", strcmp("food", p2) == 0,
"talloc_asprintf_append_buffer doesn't work\n");
CHECK_BLOCKS("misc", p2, 1);
CHECK_BLOCKS("misc", p1, 3);
el1->list3 = talloc(el1, struct el2 *);
el1->list3[0] = talloc(el1->list3, struct el2);
el1->list3[0]->name = talloc_strdup(el1->list3[0], "testing2");
-
+
el2 = talloc(el1->list, struct el2);
CHECK_PARENT("el2", el2, el1->list);
el2_2 = talloc(el1->list2, struct el2);
talloc_steal(root, p2);
CHECK_BLOCKS("steal", root, 2);
CHECK_SIZE("steal", root, 20);
-
+
talloc_free(p2);
CHECK_BLOCKS("steal", root, 1);
static bool test_lifeless(void)
{
void *top = talloc_new(NULL);
- char *parent, *child;
+ char *parent, *child;
void *child_owner = talloc_new(NULL);
printf("test: lifeless\n# TALLOC_UNLINK LOOP\n");
parent = talloc_strdup(top, "parent");
- child = talloc_strdup(parent, "child");
+ child = talloc_strdup(parent, "child");
(void)talloc_reference(child, parent);
- (void)talloc_reference(child_owner, child);
+ (void)talloc_reference(child_owner, child);
talloc_report_full(top, stderr);
talloc_unlink(top, parent);
talloc_unlink(top, child);
parent = talloc_strdup(top, "parent");
req1 = talloc(parent, struct req1);
- req1->req2 = talloc_strdup(req1, "req2");
+ req1->req2 = talloc_strdup(req1, "req2");
talloc_set_destructor(req1->req2, test_loop_destructor);
req1->req3 = talloc_strdup(req1, "req3");
(void)talloc_reference(req1->req3, req1);
talloc_report_full(NULL, stderr);
talloc_free(top);
- torture_assert("loop", loop_destructor_count == 1,
+ torture_assert("loop", loop_destructor_count == 1,
"FAILED TO FIRE LOOP DESTRUCTOR\n");
loop_destructor_count = 0;
test_reset();
ret &= test_ref4();
test_reset();
- ret &= test_unlink1();
+ ret &= test_unlink1();
test_reset();
ret &= test_misc();
test_reset();
ret &= test_realloc();
test_reset();
- ret &= test_realloc_child();
+ ret &= test_realloc_child();
test_reset();
- ret &= test_steal();
+ ret &= test_steal();
test_reset();
- ret &= test_move();
+ ret &= test_move();
test_reset();
ret &= test_unref_reparent();
test_reset();
- ret &= test_realloc_fn();
+ ret &= test_realloc_fn();
test_reset();
ret &= test_type();
test_reset();
- ret &= test_lifeless();
+ ret &= test_lifeless();
test_reset();
ret &= test_loop();
test_reset();
- ret &= test_free_parent_deny_child();
+ ret &= test_free_parent_deny_child();
test_reset();
ret &= test_realloc_on_destructor_parent();
test_reset();