summaryrefslogtreecommitdiffstats
path: root/source/torture
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-09-30 17:13:37 +0000
committerGerald Carter <jerry@samba.org>2005-09-30 17:13:37 +0000
commit796cade5585f1237e2c047293ad6a9b8a4e923ba (patch)
tree5f3a22ba40783ce548328a44b9262a451f33ad27 /source/torture
parent38730479cfd0c1d46fcb8950fc30da3fa3f8b154 (diff)
downloadsamba-796cade5585f1237e2c047293ad6a9b8a4e923ba.tar.gz
samba-796cade5585f1237e2c047293ad6a9b8a4e923ba.tar.xz
samba-796cade5585f1237e2c047293ad6a9b8a4e923ba.zip
r10656: BIG merge from trunk. Features not copied over
* \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck)
Diffstat (limited to 'source/torture')
-rw-r--r--source/torture/locktest2.c4
-rw-r--r--source/torture/mangle_test.c2
-rw-r--r--source/torture/msgtest.c10
-rw-r--r--source/torture/t_asn1.c61
-rw-r--r--source/torture/t_strappend.c45
-rw-r--r--source/torture/torture.c1
-rw-r--r--source/torture/vfstest.c2
7 files changed, 116 insertions, 9 deletions
diff --git a/source/torture/locktest2.c b/source/torture/locktest2.c
index d0b502c74e7..fc180bfafe2 100644
--- a/source/torture/locktest2.c
+++ b/source/torture/locktest2.c
@@ -133,12 +133,12 @@ static BOOL try_unlock(struct cli_state *c, int fstype,
return False;
}
-static void print_brl(SMB_DEV_T dev, SMB_INO_T ino, int pid,
+static void print_brl(SMB_DEV_T dev, SMB_INO_T ino, struct process_id pid,
enum brl_type lock_type,
br_off start, br_off size)
{
printf("%6d %05x:%05x %s %.0f:%.0f(%.0f)\n",
- (int)pid, (int)dev, (int)ino,
+ (int)procid_to_pid(&pid), (int)dev, (int)ino,
lock_type==READ_LOCK?"R":"W",
(double)start, (double)start+size-1,(double)size);
diff --git a/source/torture/mangle_test.c b/source/torture/mangle_test.c
index df0855d93d7..9ce6afa038f 100644
--- a/source/torture/mangle_test.c
+++ b/source/torture/mangle_test.c
@@ -98,7 +98,7 @@ static BOOL test_one(struct cli_state *cli, const char *name)
} else {
TDB_DATA namedata;
/* store it for later */
- namedata.dptr = name;
+ namedata.dptr = CONST_DISCARD(char *, name);
namedata.dsize = strlen(name)+1;
tdb_store_bystring(tdb, shortname, namedata, TDB_REPLACE);
}
diff --git a/source/torture/msgtest.c b/source/torture/msgtest.c
index ac55d703276..d691ab32f1d 100644
--- a/source/torture/msgtest.c
+++ b/source/torture/msgtest.c
@@ -28,7 +28,7 @@ static int pong_count;
/****************************************************************************
a useful function for testing the message system
****************************************************************************/
-void pong_message(int msg_type, pid_t src, void *buf, size_t len)
+void pong_message(int msg_type, struct process_id src, void *buf, size_t len)
{
pong_count++;
}
@@ -56,7 +56,7 @@ void pong_message(int msg_type, pid_t src, void *buf, size_t len)
message_register(MSG_PONG, pong_message);
for (i=0;i<n;i++) {
- message_send_pid(pid, MSG_PING, NULL, 0, True);
+ message_send_pid(pid_to_procid(pid), MSG_PING, NULL, 0, True);
}
while (pong_count < i) {
@@ -70,8 +70,10 @@ void pong_message(int msg_type, pid_t src, void *buf, size_t len)
safe_strcpy(buf, "1234567890", sizeof(buf)-1);
for (i=0;i<n;i++) {
- message_send_pid(getpid(), MSG_PING, NULL, 0, False);
- message_send_pid(getpid(), MSG_PING, buf, 11, False);
+ message_send_pid(pid_to_procid(getpid()), MSG_PING,
+ NULL, 0, False);
+ message_send_pid(pid_to_procid(getpid()), MSG_PING,
+ buf, 11, False);
}
for (i=0;i<n;i++) {
diff --git a/source/torture/t_asn1.c b/source/torture/t_asn1.c
new file mode 100644
index 00000000000..98ee7baf929
--- /dev/null
+++ b/source/torture/t_asn1.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2004 by Volker Lendecke
+ *
+ * Test harness for asn1_write_*, inspired by Love Hornquist Astrand
+ */
+
+#include "includes.h"
+
+static DATA_BLOB tests[] = {
+ {"\x02\x01\x00", 3, NULL},
+ {"\x02\x01\x7f", 3, NULL},
+ {"\x02\x02\x00\x80", 4, NULL},
+ {"\x02\x02\x01\x00", 4, NULL},
+ {"\x02\x01\x80", 3, NULL},
+ {"\x02\x02\xff\x7f", 4, NULL},
+ {"\x02\x01\xff", 3, NULL},
+ {"\x02\x02\xff\x01", 4, NULL},
+ {"\x02\x02\x00\xff", 4, NULL},
+ {"\x02\x04\x80\x00\x00\x00", 6, NULL},
+ {"\x02\x04\x7f\xff\xff\xff", 6, NULL},
+ {NULL, 0, NULL}
+};
+
+static int values[] = {0, 127, 128, 256, -128, -129, -1, -255, 255,
+ 0x80000000, 0x7fffffff};
+
+int main(void)
+{
+ int i = 0;
+ int val;
+ BOOL ok = True;
+
+ for (i=0; tests[i].data != NULL; i++) {
+ ASN1_DATA data;
+ DATA_BLOB blob;
+
+ ZERO_STRUCT(data);
+ asn1_write_Integer(&data, values[i]);
+
+ if ((data.length != tests[i].length) ||
+ (memcmp(data.data, tests[i].data, data.length) != 0)) {
+ printf("Test for %d failed\n", values[i]);
+ ok = False;
+ }
+
+ blob.data = data.data;
+ blob.length = data.length;
+ asn1_load(&data, blob);
+ if (!asn1_read_Integer(&data, &val)) {
+ printf("Could not read our own Integer for %d\n",
+ values[i]);
+ ok = False;
+ }
+ if (val != values[i]) {
+ printf("%d -> ASN -> Int %d\n", values[i], val);
+ ok = False;
+ }
+ }
+
+ return ok ? 0 : 1;
+}
diff --git a/source/torture/t_strappend.c b/source/torture/t_strappend.c
new file mode 100644
index 00000000000..becc691c7f9
--- /dev/null
+++ b/source/torture/t_strappend.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2005 by Volker Lendecke
+ *
+ * Test harness for sprintf_append
+ */
+
+#include "includes.h"
+#include <assert.h>
+
+int main(int argc, char *argv[])
+{
+ TALLOC_CTX *mem_ctx;
+ char *string = NULL;
+ int len = 0;
+ int bufsize = 4;
+ int i;
+
+ mem_ctx = talloc_init("t_strappend");
+ if (mem_ctx == NULL) {
+ fprintf(stderr, "talloc_init failed\n");
+ return 1;
+ }
+
+ sprintf_append(mem_ctx, &string, &len, &bufsize, "");
+ assert(strlen(string) == len);
+ sprintf_append(mem_ctx, &string, &len, &bufsize, "");
+ assert(strlen(string) == len);
+ sprintf_append(mem_ctx, &string, &len, &bufsize,
+ "01234567890123456789012345678901234567890123456789\n");
+ assert(strlen(string) == len);
+
+
+ for (i=0; i<(100000); i++) {
+ if (i%1000 == 0) {
+ printf("%d %d\r", i, bufsize);
+ fflush(stdout);
+ }
+ sprintf_append(mem_ctx, &string, &len, &bufsize, "%d\n", i);
+ assert(strlen(string) == len);
+ }
+
+ talloc_destroy(mem_ctx);
+
+ return 0;
+}
diff --git a/source/torture/torture.c b/source/torture/torture.c
index 11cea53188f..8ad567f1778 100644
--- a/source/torture/torture.c
+++ b/source/torture/torture.c
@@ -698,7 +698,6 @@ static BOOL run_netbench(int client)
{
struct cli_state *cli;
int i;
- fstring fname;
pstring line;
char cname[20];
FILE *f;
diff --git a/source/torture/vfstest.c b/source/torture/vfstest.c
index 69acd01c1a4..b5ccf930bc6 100644
--- a/source/torture/vfstest.c
+++ b/source/torture/vfstest.c
@@ -38,7 +38,7 @@ extern pstring user_socket_options;
/****************************************************************************
handle completion of commands for readline
****************************************************************************/
-static char **completion_fn(char *text, int start, int end)
+static char **completion_fn(const char *text, int start, int end)
{
#define MAX_COMPLETIONS 100
char **matches;