r22757: test if calling talloc_free() works on parent elements from within a destrutor
[Samba.git] / source / torture / torture.c
blob66d7bbb1018d87bc0366d05a914fd12117aedebf
1 /*
2 Unix SMB/CIFS implementation.
3 SMB torture tester
4 Copyright (C) Andrew Tridgell 1997-2003
5 Copyright (C) Jelmer Vernooij 2006
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
23 #include "system/time.h"
24 #include "torture/torture.h"
25 #include "build.h"
26 #include "lib/util/dlinklist.h"
28 _PUBLIC_ int torture_numops=10;
29 _PUBLIC_ int torture_entries=1000;
30 _PUBLIC_ int torture_failures=1;
31 _PUBLIC_ int torture_seed=0;
32 _PUBLIC_ int torture_numasync=100;
34 struct torture_suite *torture_root = NULL;
36 bool torture_register_suite(struct torture_suite *suite)
38 if (!suite)
39 return true;
41 return torture_suite_add_suite(torture_root, suite);
44 struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
45 const struct torture_ui_ops *ui_ops)
47 struct torture_context *torture = talloc_zero(mem_ctx,
48 struct torture_context);
49 torture->ui_ops = ui_ops;
50 torture->returncode = true;
52 if (ui_ops->init)
53 ui_ops->init(torture);
55 return torture;
59 int torture_init(void)
61 init_module_fn static_init[] = STATIC_torture_MODULES;
62 init_module_fn *shared_init = load_samba_modules(NULL, "torture");
64 torture_root = talloc_zero(talloc_autofree_context(),
65 struct torture_suite);
67 run_init_functions(static_init);
68 run_init_functions(shared_init);
70 talloc_free(shared_init);
72 return 0;