diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-08-08 13:54:43 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:38:35 -0500 |
commit | 21da07ba1fdbef9d8fadfb9bf9fa23afc0a665d1 (patch) | |
tree | a865f0c7630a42d0c565a73da8b483a18210a0d2 /source3/torture/torture.c | |
parent | 72c605b4fc518b498688ec032004fded0d2250d7 (diff) | |
download | samba-21da07ba1fdbef9d8fadfb9bf9fa23afc0a665d1.tar.gz samba-21da07ba1fdbef9d8fadfb9bf9fa23afc0a665d1.tar.bz2 samba-21da07ba1fdbef9d8fadfb9bf9fa23afc0a665d1.zip |
r17457: Add a test to do some operations on group mapping.
Volker
(This used to be commit 68db058fdf508d5b4d38731ece21f5d92feca00c)
Diffstat (limited to 'source3/torture/torture.c')
-rw-r--r-- | source3/torture/torture.c | 169 |
1 files changed, 5 insertions, 164 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 009eb84787..67d13068bb 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -4797,169 +4797,6 @@ static BOOL run_local_substitute(int dummy) return (diff == 0); } -static char **key_fn(TALLOC_CTX *mem_ctx, TDB_DATA data, - void *private_data) -{ - fstring key, value; - char **result; - - result = TALLOC_ARRAY(mem_ctx, char *, 3); - if (result == NULL) { - return NULL; - } - - if (tdb_unpack(data.dptr, data.dsize, "ff", key, value) < 0) { - d_fprintf(stderr, "tdb_unpack failed\n"); - TALLOC_FREE(result); - return NULL; - } - result[0] = talloc_strdup(result, key); - result[1] = talloc_strdup(result, value); - result[2] = NULL; - - if ((result[0] == NULL) || (result[1] == NULL)) { - d_fprintf(stderr, "talloc_strdup failed\n"); - TALLOC_FREE(result); - return NULL; - } - - return result; -} - -static NTSTATUS multikey_add(struct tdb_context *tdb, const char *key, - const char *value) -{ - NTSTATUS status; - TDB_DATA data; - - data.dptr = NULL; - data.dsize = 0; - - if (!tdb_pack_append(NULL, &data.dptr, &data.dsize, - "ff", key, value)) { - return NT_STATUS_NO_MEMORY; - } - - status = tdb_add_keyed(tdb, key_fn, data, NULL); - TALLOC_FREE(data.dptr); - return status; -} - -#define CHECK_STATUS(_status, _expected) do { \ - if (!NT_STATUS_EQUAL(_status, _expected)) { \ - printf("(%d) Incorrect status %s - should be %s\n", \ - __LINE__, nt_errstr(status), nt_errstr(_expected)); \ - ret = False; \ - goto fail; \ - }} while (0) - -static BOOL run_local_multikey(int dummy) -{ - TALLOC_CTX *mem_ctx; - char *prim; - const char *tdbname = "multi_key_test.tdb"; - struct tdb_context *tdb = NULL; - NTSTATUS status; - BOOL ret = False; - TDB_DATA data; - int i; - fstring key,value; - - unlink(tdbname); - - mem_ctx = talloc_init("run_local_multikey"); - if (mem_ctx == NULL) { - d_fprintf(stderr, "talloc_init failed\n"); - return False; - } - - tdb = tdb_open(tdbname, 0, 0, O_CREAT|O_RDWR, 0644); - if (tdb == NULL) { - d_fprintf(stderr, "tdb_open failed: %s\n", strerror(errno)); - goto fail; - } - - for (i=0; i<200; i++) { - fstr_sprintf(key, "KEY%d", i); - fstr_sprintf(value, "VAL%d", i); - - status = multikey_add(tdb, key, value); - if (!NT_STATUS_IS_OK(status)) { - d_fprintf(stderr, "tdb_add_keyed failed: %s\n", - nt_errstr(status)); - goto fail; - } - } - - status = multikey_add(tdb, "KEY35", "FOOO"); - CHECK_STATUS(status, NT_STATUS_OBJECTID_EXISTS); - status = multikey_add(tdb, "KEY42", "VAL45"); - CHECK_STATUS(status, NT_STATUS_OBJECTID_EXISTS); - status = multikey_add(tdb, "FOO", "VAL45"); - CHECK_STATUS(status, NT_STATUS_OBJECTID_EXISTS); - - for (i=0; i<200; i++) { - fstr_sprintf(key, "KEY%d", i); - fstr_sprintf(value, "VAL%d", i); - - status = tdb_find_keyed(mem_ctx, tdb, 0, key, &data, &prim); - CHECK_STATUS(status, NT_STATUS_OK); - status = tdb_find_keyed(mem_ctx, tdb, 1, value, &data, &prim); - CHECK_STATUS(status, NT_STATUS_OK); - status = tdb_find_keyed(mem_ctx, tdb, 1, key, &data, &prim); - CHECK_STATUS(status, NT_STATUS_NOT_FOUND); - status = tdb_find_keyed(mem_ctx, tdb, 0, value, &data, &prim); - CHECK_STATUS(status, NT_STATUS_NOT_FOUND); - } - - status = tdb_find_keyed(mem_ctx, tdb, 0, "FOO", &data, &prim); - CHECK_STATUS(status, NT_STATUS_NOT_FOUND); - status = tdb_find_keyed(mem_ctx, tdb, 1, "BAR", &data, &prim); - CHECK_STATUS(status, NT_STATUS_NOT_FOUND); - - status = tdb_find_keyed(mem_ctx, tdb, 0, "KEY0", &data, &prim); - CHECK_STATUS(status, NT_STATUS_OK); - - ZERO_STRUCT(data); - if (tdb_pack_append(mem_ctx, &data.dptr, &data.dsize, "ff", - "NEWKEY", "NEWVAL") < 0) { - d_printf("tdb_pack_alloc failed\n"); - goto fail; - } - - status = tdb_update_keyed(tdb, prim, key_fn, data, NULL); - CHECK_STATUS(status, NT_STATUS_OK); - - status = tdb_find_keyed(mem_ctx, tdb, 0, "KEY0", &data, &prim); - CHECK_STATUS(status, NT_STATUS_NOT_FOUND); - status = tdb_find_keyed(mem_ctx, tdb, 1, "VAL0", &data, &prim); - CHECK_STATUS(status, NT_STATUS_NOT_FOUND); - status = tdb_find_keyed(mem_ctx, tdb, 0, "NEWKEY", &data, &prim); - CHECK_STATUS(status, NT_STATUS_OK); - status = tdb_find_keyed(mem_ctx, tdb, 1, "NEWVAL", &data, &prim); - CHECK_STATUS(status, NT_STATUS_OK); - - status = tdb_del_keyed(tdb, key_fn, prim, NULL); - CHECK_STATUS(status, NT_STATUS_OK); - - for (i=1; i<200; i++) { - fstr_sprintf(key, "KEY%d", i); - status = tdb_find_keyed(mem_ctx, tdb, 0, key, &data, &prim); - CHECK_STATUS(status, NT_STATUS_OK); - status = tdb_del_keyed(tdb, key_fn, prim, NULL); - CHECK_STATUS(status, NT_STATUS_OK); - } - - ret = True; - fail: - if (tdb != NULL) { - tdb_close(tdb); - } - unlink(tdbname); - TALLOC_FREE(mem_ctx); - return ret; -} - static double create_procs(BOOL (*fn)(int), BOOL *result) { int i, status; @@ -5112,6 +4949,7 @@ static struct { { "EATEST", run_eatest, 0}, { "LOCAL-SUBSTITUTE", run_local_substitute, 0}, { "LOCAL-MULTIKEY", run_local_multikey, 0}, + { "LOCAL-GROUPMAP", run_local_groupmap, 0}, {NULL, NULL, 0}}; @@ -5260,7 +5098,7 @@ static void usage(void) fstrcpy(workgroup, lp_workgroup()); - while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:m:Ld:Ac:ks:b:")) != EOF) { + while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:m:Ld:Ac:ks:b:S:")) != EOF) { switch (opt) { case 'p': port_to_use = atoi(optarg); @@ -5268,6 +5106,9 @@ static void usage(void) case 's': srandom(atoi(optarg)); break; + case 'S': + lp_load(optarg,True,False,False,True); + break; case 'W': fstrcpy(workgroup,optarg); break; |