r22969: fix some more places where we could end up with more than one event
[jelmer/samba4-debian.git] / source / torture / torture.c
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB torture tester
4    Copyright (C) Andrew Tridgell 1997-2003
5    Copyright (C) Jelmer Vernooij 2006
6    
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.
11    
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.
16    
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.
20 */
21
22 #include "includes.h"
23 #include "system/time.h"
24 #include "torture/torture.h"
25 #include "build.h"
26 #include "lib/util/dlinklist.h"
27 #include "auth/credentials/credentials.h"
28 #include "lib/cmdline/popt_common.h"
29
30 _PUBLIC_ int torture_numops=10;
31 _PUBLIC_ int torture_entries=1000;
32 _PUBLIC_ int torture_failures=1;
33 _PUBLIC_ int torture_seed=0;
34 _PUBLIC_ int torture_numasync=100;
35
36 struct torture_suite *torture_root = NULL;
37
38 bool torture_register_suite(struct torture_suite *suite)
39 {
40         if (!suite)
41                 return true;
42
43         return torture_suite_add_suite(torture_root, suite);
44 }
45
46 struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx, 
47                                              const struct torture_ui_ops *ui_ops)
48 {
49         struct torture_context *torture = talloc_zero(mem_ctx, 
50                                                       struct torture_context);
51         torture->ui_ops = ui_ops;
52         torture->returncode = true;
53         torture->ev = cli_credentials_get_event_context(cmdline_credentials);
54
55         if (ui_ops->init)
56                 ui_ops->init(torture);
57
58         return torture;
59 }
60
61
62 int torture_init(void)
63 {
64         init_module_fn static_init[] = STATIC_torture_MODULES;
65         init_module_fn *shared_init = load_samba_modules(NULL, "torture");
66
67         torture_root = talloc_zero(talloc_autofree_context(), 
68                                    struct torture_suite);
69         
70         run_init_functions(static_init);
71         run_init_functions(shared_init);
72
73         talloc_free(shared_init);
74
75         return 0;
76 }