summaryrefslogtreecommitdiff
path: root/source4/torture/basic/utable.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/basic/utable.c')
-rw-r--r--source4/torture/basic/utable.c72
1 files changed, 28 insertions, 44 deletions
diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c
index 8e13babd0a..28122da214 100644
--- a/source4/torture/basic/utable.c
+++ b/source4/torture/basic/utable.c
@@ -26,9 +26,9 @@
#include "torture/util.h"
#include "pstring.h"
-BOOL torture_utable(struct torture_context *torture)
+bool torture_utable(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
- struct smbcli_state *cli;
fstring fname;
const char *alt_name;
int fnum;
@@ -37,19 +37,12 @@ BOOL torture_utable(struct torture_context *torture)
int chars_allowed=0, alt_allowed=0;
uint8_t valid[0x10000];
- printf("starting utable\n");
-
- printf("Generating valid character table\n");
-
- if (!torture_open_connection(&cli, 0)) {
- return False;
- }
+ torture_comment(tctx, "Generating valid character table\n");
memset(valid, 0, sizeof(valid));
- if (!torture_setup_dir(cli, "\\utable")) {
- return False;
- }
+ torture_assert(tctx, torture_setup_dir(cli, "\\utable"),
+ "Setting up dir \\utable failed");
for (c=1; c < 0x10000; c++) {
char *p;
@@ -74,32 +67,31 @@ BOOL torture_utable(struct torture_context *torture)
if (strncmp(alt_name, "X_A_L", 5) != 0) {
alt_allowed++;
valid[c] = 1;
- d_printf("fname=[%s] alt_name=[%s]\n", fname, alt_name);
+ torture_comment(tctx, "fname=[%s] alt_name=[%s]\n", fname, alt_name);
}
smbcli_close(cli->tree, fnum);
smbcli_unlink(cli->tree, fname);
if (c % 100 == 0) {
- printf("%d (%d/%d)\r", c, chars_allowed, alt_allowed);
+ torture_comment(tctx, "%d (%d/%d)\r", c, chars_allowed, alt_allowed);
}
}
- printf("%d (%d/%d)\n", c, chars_allowed, alt_allowed);
+ torture_comment(tctx, "%d (%d/%d)\n", c, chars_allowed, alt_allowed);
smbcli_rmdir(cli->tree, "\\utable");
- d_printf("%d chars allowed %d alt chars allowed\n", chars_allowed, alt_allowed);
+ torture_comment(tctx, "%d chars allowed %d alt chars allowed\n", chars_allowed, alt_allowed);
fd = open("valid.dat", O_WRONLY|O_CREAT|O_TRUNC, 0644);
- if (fd == -1) {
- d_printf("Failed to create valid.dat - %s", strerror(errno));
- return False;
- }
+ torture_assert(tctx, fd != -1,
+ talloc_asprintf(tctx,
+ "Failed to create valid.dat - %s", strerror(errno)));
write(fd, valid, 0x10000);
close(fd);
- d_printf("wrote valid.dat\n");
+ torture_comment(tctx, "wrote valid.dat\n");
- return True;
+ return true;
}
@@ -121,34 +113,28 @@ static char *form_name(int c)
return fname;
}
-BOOL torture_casetable(struct torture_context *torture)
+bool torture_casetable(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
- static struct smbcli_state *cli;
char *fname;
int fnum;
int c, i;
#define MAX_EQUIVALENCE 8
codepoint_t equiv[0x10000][MAX_EQUIVALENCE];
- printf("starting casetable\n");
- if (!torture_open_connection(&cli, 0)) {
- return False;
- }
-
- printf("Determining upper/lower case table\n");
+ torture_comment(tctx, "Determining upper/lower case table\n");
memset(equiv, 0, sizeof(equiv));
- if (!torture_setup_dir(cli, "\\utable")) {
- return False;
- }
+ torture_assert(tctx, torture_setup_dir(cli, "\\utable"),
+ "Error setting up dir \\utable");
for (c=1; c < 0x10000; c++) {
size_t size;
if (c == '.' || c == '\\') continue;
- d_printf("%04x (%c)\n", c, isprint(c)?c:'.');
+ torture_comment(tctx, "%04x (%c)\n", c, isprint(c)?c:'.');
fname = form_name(c);
fnum = smbcli_nt_create_full(cli->tree, fname, 0,
@@ -161,10 +147,9 @@ BOOL torture_casetable(struct torture_context *torture)
NTCREATEX_SHARE_ACCESS_NONE,
NTCREATEX_DISP_OPEN_IF, 0, 0);
- if (fnum == -1) {
- printf("Failed to create file with char %04x\n", c);
- continue;
- }
+ torture_assert(tctx, fnum != -1,
+ talloc_asprintf(tctx,
+ "Failed to create file with char %04x\n", c));
size = 0;
@@ -176,21 +161,20 @@ BOOL torture_casetable(struct torture_context *torture)
int c2[MAX_EQUIVALENCE];
if (size/sizeof(int) >= MAX_EQUIVALENCE) {
- printf("too many chars match?? size=%d c=0x%04x\n",
+ torture_comment(tctx, "too many chars match?? size=%d c=0x%04x\n",
(int)size, c);
smbcli_close(cli->tree, fnum);
return False;
}
smbcli_read(cli->tree, fnum, c2, 0, size);
- printf("%04x: ", c);
+ torture_comment(tctx, "%04x: ", c);
equiv[c][0] = c;
for (i=0; i<size/sizeof(int); i++) {
- printf("%04x ", c2[i]);
+ torture_comment(tctx, "%04x ", c2[i]);
equiv[c][i+1] = c2[i];
}
- printf("\n");
- fflush(stdout);
+ torture_comment(tctx, "\n");
}
smbcli_write(cli->tree, fnum, 0, &c, size, sizeof(c));
@@ -200,5 +184,5 @@ BOOL torture_casetable(struct torture_context *torture)
smbcli_unlink(cli->tree, "\\utable\\*");
smbcli_rmdir(cli->tree, "\\utable");
- return True;
+ return true;
}