r24872: Use torture API a bit more
[kai/samba.git] / source4 / torture / torture.c
index 4699df7d89125c39673377f04727ffc1e9e04db9..aa3dc14d55869bf291a110135d8208b5e5b9692e 100644 (file)
@@ -6,7 +6,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -15,8 +15,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -24,6 +23,8 @@
 #include "torture/torture.h"
 #include "build.h"
 #include "lib/util/dlinklist.h"
+#include "auth/credentials/credentials.h"
+#include "lib/cmdline/popt_common.h"
 
 _PUBLIC_ int torture_numops=10;
 _PUBLIC_ int torture_entries=1000;
@@ -38,16 +39,20 @@ bool torture_register_suite(struct torture_suite *suite)
        if (!suite)
                return true;
 
+       if (torture_root == NULL)
+               torture_root = talloc_zero(talloc_autofree_context(), struct torture_suite);
+
        return torture_suite_add_suite(torture_root, suite);
 }
 
 struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx, 
-                                                                                        const struct torture_ui_ops *ui_ops)
+                                            const struct torture_ui_ops *ui_ops)
 {
        struct torture_context *torture = talloc_zero(mem_ctx, 
-                                                                                                 struct torture_context);
+                                                     struct torture_context);
        torture->ui_ops = ui_ops;
        torture->returncode = true;
+       torture->ev = cli_credentials_get_event_context(cmdline_credentials);
 
        if (ui_ops->init)
                ui_ops->init(torture);
@@ -61,9 +66,6 @@ int torture_init(void)
        init_module_fn static_init[] = STATIC_torture_MODULES;
        init_module_fn *shared_init = load_samba_modules(NULL, "torture");
 
-       torture_root = talloc_zero(talloc_autofree_context(), 
-                                                       struct torture_suite);
-       
        run_init_functions(static_init);
        run_init_functions(shared_init);