summaryrefslogtreecommitdiff
path: root/source3/torture
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-09-30 17:13:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:04:48 -0500
commit54abd2aa66069e6baf7769c496f46d9dba18db39 (patch)
tree9cf8e88168011797319ba9e9866749201b1eac1e /source3/torture
parent4a2cc231d22a82ed21771a72508f15d21ed63227 (diff)
downloadsamba-54abd2aa66069e6baf7769c496f46d9dba18db39.tar.gz
samba-54abd2aa66069e6baf7769c496f46d9dba18db39.tar.bz2
samba-54abd2aa66069e6baf7769c496f46d9dba18db39.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) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3)
Diffstat (limited to 'source3/torture')
-rw-r--r--source3/torture/locktest2.c4
-rw-r--r--source3/torture/mangle_test.c2
-rw-r--r--source3/torture/msgtest.c10
-rw-r--r--source3/torture/t_asn1.c61
-rw-r--r--source3/torture/t_strappend.c45
-rw-r--r--source3/torture/torture.c1
-rw-r--r--source3/torture/vfstest.c2
7 files changed, 116 insertions, 9 deletions
diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
index d0b502c74e..fc180bfafe 100644
--- a/source3/torture/locktest2.c
+++ b/source3/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/source3/torture/mangle_test.c b/source3/torture/mangle_test.c
index df0855d93d..9ce6afa038 100644
--- a/source3/torture/mangle_test.c
+++ b/source3/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/source3/torture/msgtest.c b/source3/torture/msgtest.c
index ac55d70327..d691ab32f1 100644
--- a/source3/torture/msgtest.c
+++ b/source3/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/source3/torture/t_asn1.c b/source3/torture/t_asn1.c
new file mode 100644
index 0000000000..98ee7baf92
--- /dev/null
+++ b/source3/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/source3/torture/t_strappend.c b/source3/torture/t_strappend.c
new file mode 100644
index 0000000000..becc691c7f
--- /dev/null
+++ b/source3/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/source3/torture/torture.c b/source3/torture/torture.c
index 11cea53188..8ad567f177 100644
--- a/source3/torture/torture.c
+++ b/source3/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/source3/torture/vfstest.c b/source3/torture/vfstest.c
index 69acd01c1a..b5ccf930bc 100644
--- a/source3/torture/vfstest.c
+++ b/source3/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;