dsdb/mod/extended_dn_out: use faster removal filters
[bbaumbach/samba-autobuild/.git] / source4 / torture / torture.c
index d5cb0511f7e7065708cd003bab1192dbcba693e9..cc29ffad09af63b2a02f7a7bf50842f237f9726a 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,
    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"
 #include "system/time.h"
-#include "torture/torture.h"
-#include "build.h"
-#include "lib/util/dlinklist.h"
+#include "param/param.h"
+#include "lib/cmdline/popt_common.h"
+#include "torture/smbtorture.h"
+#include "lib/util/samba_modules.h"
 
-_PUBLIC_ int torture_nprocs=4;
 _PUBLIC_ int torture_numops=10;
 _PUBLIC_ int torture_entries=1000;
 _PUBLIC_ int torture_failures=1;
 _PUBLIC_ int torture_seed=0;
 _PUBLIC_ int torture_numasync=100;
-_PUBLIC_ bool torture_showall = false;
 
-struct torture_suite_list *torture_suites = NULL;
+struct torture_suite *torture_root = NULL;
 
-NTSTATUS torture_register_suite(struct torture_suite *suite)
+bool torture_register_suite(TALLOC_CTX *mem_ctx, struct torture_suite *suite)
 {
-       struct torture_suite_list *p, *n;
+       if (!suite)
+               return true;
 
-       if (!suite) {
-               return NT_STATUS_OK;
-       }
+       if (torture_root == NULL)
+               torture_root = talloc_zero(mem_ctx, struct torture_suite);
 
-       n = talloc(talloc_autofree_context(), struct torture_suite_list);
-       n->suite = suite;
-
-       for (p = torture_suites; p; p = p->next) {
-               if (strcmp(p->suite->name, suite->name) == 0) {
-                       /* Check for duplicates */
-                       DEBUG(0,("There already is a suite registered with the name %s!\n", suite->name));
-                       return NT_STATUS_OBJECT_NAME_COLLISION;
-               }
-
-               if (strcmp(p->suite->name, suite->name) < 0 && 
-                       (!p->next || strcmp(p->next->suite->name, suite->name) > 0)) {
-                       DLIST_ADD_AFTER(torture_suites, n, p);
-                       return NT_STATUS_OK;
-               }
-       }
-
-       DLIST_ADD_END(torture_suites, n, struct torture_suite_list *);
-
-       return NT_STATUS_OK;
+       return torture_suite_add_suite(torture_root, suite);
 }
 
-int torture_init(void)
+_PUBLIC_ int torture_init(TALLOC_CTX *mem_ctx)
 {
-       init_module_fn static_init[] = STATIC_torture_MODULES;
-       init_module_fn *shared_init = load_samba_modules(NULL, "torture");
-       
-       run_init_functions(static_init);
-       run_init_functions(shared_init);
+#define _MODULE_PROTO(init) extern NTSTATUS init(TALLOC_CTX *);
+       STATIC_smbtorture_MODULES_PROTO;
+       init_module_fn static_init[] = { STATIC_smbtorture_MODULES };
+       init_module_fn *shared_init = load_samba_modules(mem_ctx, "smbtorture");
+
+       run_init_functions(mem_ctx, static_init);
+       run_init_functions(mem_ctx, shared_init);
 
        talloc_free(shared_init);