s3: Change sockaddr util function names for consistency
[samba.git] / source3 / torture / torture.c
index d8942e42b9b1b82cc6f5d973208a3cb228ec8b7b..382b3b65ebc4aeaf372ce72b8f7460f6c0571816 100644 (file)
@@ -158,7 +158,7 @@ static struct cli_state *open_nbt_connection(void)
        make_nmb_name(&calling, myname, 0x0);
        make_nmb_name(&called , host, 0x20);
 
-        zero_addr(&ss);
+        zero_sockaddr(&ss);
 
        if (!(c = cli_initialise())) {
                printf("Failed initialize cli_struct to connect with %s\n", host);
@@ -294,15 +294,6 @@ static bool torture_open_connection_share(struct cli_state **c,
        return True;
 }
 
-void torture_open_connection_free_unclist(char **unc_list)
-{
-       if (unc_list!=NULL)
-       {
-               SAFE_FREE(unc_list[0]);
-               SAFE_FREE(unc_list);
-       }
-}
-
 bool torture_open_connection(struct cli_state **c, int conn_index)
 {
        char **unc_list = NULL;
@@ -311,7 +302,7 @@ bool torture_open_connection(struct cli_state **c, int conn_index)
 
        if (use_multishare_conn==True) {
                char *h, *s;
-               unc_list = file_lines_load(multishare_conn_fname, &num_unc_names, 0);
+               unc_list = file_lines_load(multishare_conn_fname, &num_unc_names, 0, NULL);
                if (!unc_list || num_unc_names <= 0) {
                        printf("Failed to load unc names list from '%s'\n", multishare_conn_fname);
                        exit(1);
@@ -321,14 +312,14 @@ bool torture_open_connection(struct cli_state **c, int conn_index)
                                      NULL, &h, &s)) {
                        printf("Failed to parse UNC name %s\n",
                               unc_list[conn_index % num_unc_names]);
-                       torture_open_connection_free_unclist(unc_list);
+                       TALLOC_FREE(unc_list);
                        exit(1);
                }
 
                result = torture_open_connection_share(c, h, s);
 
                /* h, s were copied earlier */
-               torture_open_connection_free_unclist(unc_list);
+               TALLOC_FREE(unc_list);
                return result;
        }
 
@@ -5075,7 +5066,7 @@ static bool run_local_gencache(int dummy)
                return False;
        }
 
-       blob = data_blob_string_const("bar");
+       blob = data_blob_string_const_null("bar");
        tm = time(NULL);
 
        if (!gencache_set_data_blob("foo", &blob, tm)) {
@@ -5300,6 +5291,11 @@ static bool run_local_memcache(int dummy)
        DATA_BLOB d1, d2, d3;
        DATA_BLOB v1, v2, v3;
 
+       TALLOC_CTX *mem_ctx;
+       char *str1, *str2;
+       size_t size1, size2;
+       bool ret = false;
+
        cache = memcache_init(NULL, 100);
 
        if (cache == NULL) {
@@ -5351,7 +5347,33 @@ static bool run_local_memcache(int dummy)
        }
 
        TALLOC_FREE(cache);
-       return true;
+
+       cache = memcache_init(NULL, 0);
+
+       mem_ctx = talloc_init("foo");
+
+       str1 = talloc_strdup(mem_ctx, "string1");
+       str2 = talloc_strdup(mem_ctx, "string2");
+
+       memcache_add_talloc(cache, SINGLETON_CACHE_TALLOC,
+                           data_blob_string_const("torture"), &str1);
+       size1 = talloc_total_size(cache);
+
+       memcache_add_talloc(cache, SINGLETON_CACHE_TALLOC,
+                           data_blob_string_const("torture"), &str2);
+       size2 = talloc_total_size(cache);
+
+       printf("size1=%d, size2=%d\n", (int)size1, (int)size2);
+
+       if (size2 > size1) {
+               printf("memcache leaks memory!\n");
+               goto fail;
+       }
+
+       ret = true;
+ fail:
+       TALLOC_FREE(cache);
+       return ret;
 }
 
 static double create_procs(bool (*fn)(int), bool *result)
@@ -5649,7 +5671,7 @@ static void usage(void)
        *p = 0;
        fstrcpy(share, p+1);
 
-       fstrcpy(myname, get_myname(talloc_tos()));
+       fstrcpy(myname, talloc_get_myname(talloc_tos()));
        if (!*myname) {
                fprintf(stderr, "Failed to get my hostname.\n");
                return 1;