s4-smbtorture: Make test names lowercase and dot-separated.
[metze/samba/wip.git] / source4 / torture / nbench / nbench.c
index ddedd102f9fcd42d28508c7dc2f178f627bafcca..b0e3364f7e8dcd6dbf6c5e7f9bd07466ed50bd7a 100644 (file)
 
 #include "includes.h"
 #include "libcli/libcli.h"
-#include "torture/ui.h"
 #include "torture/util.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
 #include "system/filesys.h"
 #include "system/locale.h"
-#include "pstring.h"
 
 #include "torture/nbench/proto.h"
 
@@ -39,14 +37,14 @@ static int read_only;
 static unsigned long nb_max_retries;
 
 #define NB_RETRY(op) \
-       for (n=0;n<=nb_max_retries && !op;n++) do_reconnect(&cli, client)
+       for (n=0;n<=nb_max_retries && !op;n++) do_reconnect(&cli, tctx, client)
 
-static void do_reconnect(struct smbcli_state **cli, int client)
+static void do_reconnect(struct smbcli_state **cli, struct torture_context *tctx, int client)
 {
        int n;
        printf("[%d] Reconnecting client %d\n", nbench_line_count, client);
        for (n=0;n<nb_max_retries;n++) {
-               if (nb_reconnect(cli, client)) {
+               if (nb_reconnect(cli, tctx, client)) {
                        printf("[%d] Reconnected client %d\n", nbench_line_count, client);
                        return;
                }
@@ -60,7 +58,7 @@ static bool run_netbench(struct torture_context *tctx, struct smbcli_state *cli,
 {
        int torture_nprocs = torture_setting_int(tctx, "nprocs", 4);
        int i;
-       pstring line;
+       char line[1024];
        char *cname;
        FILE *f;
        bool correct = true;
@@ -97,11 +95,14 @@ again:
 
                nbench_line_count++;
 
-               line[strlen(line)-1] = 0;
+               if ((strlen(line) > 0) && line[strlen(line)-1] == '\n') {
+                       line[strlen(line)-1] = 0;
+               }
 
-               all_string_sub(line,"client1", cname, sizeof(line));
+               all_string_sub(line, "client1", cname, sizeof(line));
                
-               params = params0 = str_list_make_shell(NULL, line, " ");
+               params = params0 = const_str_list(
+                                       str_list_make_shell(NULL, line, " "));
                i = str_list_length(params);
 
                if (i > 0 && isdigit(params[0][0])) {
@@ -244,7 +245,7 @@ bool torture_nbench(struct torture_context *torture)
        }
 
        if (torture_nprocs > 1) {
-               if (!torture_open_connection(&cli, 0)) {
+               if (!torture_open_connection(&cli, torture, 0)) {
                        return false;
                }
 
@@ -281,12 +282,10 @@ bool torture_nbench(struct torture_context *torture)
 
 NTSTATUS torture_nbench_init(void)
 {
-       struct torture_suite *suite = 
-               torture_suite_create(
-                       talloc_autofree_context(),
-                       "BENCH");
+       struct torture_suite *suite = torture_suite_create(
+                                                  talloc_autofree_context(), "bench");
 
-       torture_suite_add_simple_test(suite, "NBENCH", torture_nbench);
+       torture_suite_add_simple_test(suite, "nbench", torture_nbench);
 
        suite->description = talloc_strdup(suite, "Benchmarks");