*/
#include "includes.h"
+#include "libcli/libcli.h"
+#include "torture/ui.h"
+#include "torture/util.h"
+#include "torture/torture.h"
#include "system/filesys.h"
#include "pstring.h"
+#include "torture/nbench/proto.h"
+
int nbench_line_count = 0;
static int timelimit = 600;
static int warmup;
#define ival(s) strtol(s, NULL, 0)
/* run a test that simulates an approximate netbench client load */
-static BOOL run_netbench(struct smbcli_state *cli, int client)
+static BOOL run_netbench(struct torture_context *tctx, struct smbcli_state *cli, int client)
{
extern int torture_nprocs;
int i;
pstring line;
char *cname;
FILE *f;
- fstring params[20];
- const char *p;
+ const char **params;
BOOL correct = True;
if (torture_nprocs == 1) {
all_string_sub(line,"client1", cname, sizeof(line));
- p = line;
- for (i=0;
- i<19 && next_token(&p, params[i], " ", sizeof(fstring));
- i++) ;
-
- params[i][0] = 0;
+ params = str_list_make_shell(NULL, line, " ");
+ i = str_list_length(params);
if (i < 2 || params[0][0] == '#') continue;
if (strncmp(params[i-1], "NT_STATUS_", 10) != 0) {
printf("Badly formed status at line %d\n", nbench_line_count);
+ talloc_free(params);
continue;
}
} else {
printf("[%d] Unknown operation %s\n", nbench_line_count, params[0]);
}
+
+ talloc_free(params);
if (nb_tick()) goto done;
}
done:
fclose(f);
+ if (torture_nprocs == 1) {
+ smbcli_deltree(cli->tree, "\\clients");
+ }
if (!torture_close_connection(cli)) {
correct = False;
}
/* run a test that simulates an approximate netbench client load */
-BOOL torture_nbench(void)
+BOOL torture_nbench(struct torture_context *torture)
{
BOOL correct = True;
extern int torture_nprocs;
struct smbcli_state *cli;
const char *p;
- p = lp_parm_string(-1, "torture", "timelimit");
+ p = torture_setting_string(torture, "timelimit", NULL);
if (p && *p) {
timelimit = atoi(p);
}
warmup = timelimit / 20;
- loadfile = lp_parm_string(-1, "torture", "loadfile");
+ loadfile = torture_setting_string(torture, "loadfile", NULL);
if (!loadfile || !*loadfile) {
loadfile = "client.txt";
}
if (torture_nprocs > 1) {
- if (!torture_open_connection(&cli)) {
+ if (!torture_open_connection(&cli, 0)) {
return False;
}
printf("Running for %d seconds with load '%s' and warmup %d secs\n",
timelimit, loadfile, warmup);
+ /* we need to reset SIGCHLD here as the name resolution
+ library may have changed it. We rely on correct signals
+ from childs in the main torture code which reaps
+ children. This is why smbtorture BENCH-NBENCH was sometimes
+ failing */
+ signal(SIGCHLD, SIG_DFL);
+
+
signal(SIGALRM, nb_alarm);
alarm(1);
- torture_create_procs(run_netbench, &correct);
+ torture_create_procs(torture, run_netbench, &correct);
alarm(0);
- smbcli_deltree(cli->tree, "\\clients");
+ if (torture_nprocs > 1) {
+ smbcli_deltree(cli->tree, "\\clients");
+ }
printf("\nThroughput %g MB/sec\n", nbio_result());
return correct;
}
+
+NTSTATUS torture_nbench_init(void)
+{
+ struct torture_suite *suite = torture_suite_create(
+ talloc_autofree_context(),
+ "BENCH");
+
+ torture_suite_add_simple_test(suite, "NBENCH", torture_nbench);
+
+ suite->description = talloc_strdup(suite,
+ "Benchmarks");
+
+ torture_register_suite(suite);
+ return NT_STATUS_OK;
+}