Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/lib/util/tests
Files:
1 added
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/lib/util/tests/asn1_tests.c

    r740 r988  
    55
    66   Copyright (C) Kamen Mazdrashki <kamen.mazdrashki@postpath.com> 2009
     7   Copyright (C) Volker Lendecke 2004
     8   Copyright (C) Andrew Bartlett 2011
    79
    810   This program is free software; you can redistribute it and/or modify
     
    2224#include "includes.h"
    2325#include "torture/torture.h"
     26#include "torture/local/proto.h"
    2427#include "../asn1.h"
    2528
     
    104107};
    105108
     109static const struct {
     110        DATA_BLOB blob;
     111        int value;
     112} integer_tests[] = {
     113        {
     114                .blob = { discard_const_p(uint8_t, "\x02\x01\x00"), 3},
     115                .value = 0
     116        },
     117        {
     118                .blob = { discard_const_p(uint8_t, "\x02\x01\x7f"), 3},
     119                .value = 127
     120        },
     121        {
     122                .blob = { discard_const_p(uint8_t, "\x02\x02\x00\x80"), 4},
     123                .value = 128
     124        },
     125        {
     126                .blob = { discard_const_p(uint8_t, "\x02\x02\x01\x00"), 4},
     127                .value = 256
     128        },
     129        {
     130                .blob = { discard_const_p(uint8_t, "\x02\x01\x80"), 3},
     131                .value = -128
     132        },
     133        {
     134                .blob = { discard_const_p(uint8_t, "\x02\x02\xff\x7f"), 4},
     135                .value = -129
     136        },
     137        {
     138                .blob = { discard_const_p(uint8_t, "\x02\x01\xff"), 3},
     139                .value = -1
     140        },
     141        {
     142                .blob = { discard_const_p(uint8_t, "\x02\x02\xff\x01"), 4},
     143                .value = -255
     144        },
     145        {
     146                .blob = { discard_const_p(uint8_t, "\x02\x02\x00\xff"), 4},
     147                .value = 255
     148        },
     149        {
     150                .blob = { discard_const_p(uint8_t, "\x02\x04\x80\x00\x00\x00"), 6},
     151                .value = 0x80000000
     152        },
     153        {
     154                .blob = { discard_const_p(uint8_t, "\x02\x04\x7f\xff\xff\xff"), 6},
     155                .value = 0x7fffffff
     156        }
     157};
    106158
    107159/* Testing ber_write_OID_String() function */
     
    261313}
    262314
     315/*
     316 * Testing asn1_read_Integer and asn1_write_Integer functions,
     317 * inspired by Love Hornquist Astrand
     318 */
     319
     320static bool test_asn1_Integer(struct torture_context *tctx)
     321{
     322        int i;
     323        TALLOC_CTX *mem_ctx;
     324        bool ret = false;
     325
     326        mem_ctx = talloc_new(tctx);
     327
     328        for (i = 0; i < ARRAY_SIZE(integer_tests); i++) {
     329                ASN1_DATA *data;
     330                DATA_BLOB blob;
     331                int val;
     332
     333                data = asn1_init(mem_ctx);
     334                if (!data) {
     335                        goto err;
     336                }
     337
     338                if (!asn1_write_Integer(data, integer_tests[i].value)) goto err;
     339
     340                if (!asn1_blob(data, &blob)) {
     341                        goto err;
     342                }
     343
     344                torture_assert_data_blob_equal(tctx, blob, integer_tests[i].blob, "asn1_write_Integer gave incorrect result");
     345
     346                if (!asn1_load(data, blob)) goto err;
     347                torture_assert(tctx, asn1_read_Integer(data, &val), "asn1_write_Integer output could not be read by asn1_read_Integer()");
     348
     349                torture_assert_int_equal(tctx, val, integer_tests[i].value,
     350                        "readback of asn1_write_Integer output by asn1_read_Integer() failed");
     351        }
     352
     353        ret = true;
     354
     355  err:
     356
     357        talloc_free(mem_ctx);
     358        return ret;
     359}
     360
    263361
    264362/* LOCAL-ASN1 test suite creation */
     
    279377                                      test_ber_read_partial_OID_String);
    280378
     379        torture_suite_add_simple_test(suite, "asn1_Integer",
     380                                      test_asn1_Integer);
     381
    281382        return suite;
    282383}
  • vendor/current/lib/util/tests/data_blob.c

    r740 r988  
    2222#include "includes.h"
    2323#include "torture/torture.h"
     24#include "torture/local/proto.h"
    2425
    2526static bool test_string(struct torture_context *tctx)
  • vendor/current/lib/util/tests/dlinklist.c

    r740 r988  
    2222#include "includes.h"
    2323#include "torture/torture.h"
     24#include "torture/local/proto.h"
    2425#include "lib/util/dlinklist.h"
    2526
     
    4344        for (i=0; i<5; i++) {
    4445                el = talloc(mem_ctx, struct listel);
    45                 DLIST_ADD_END(l1, el, NULL);
     46                DLIST_ADD_END(l1, el);
    4647        }
    4748
     
    5758                el = DLIST_TAIL(l1);
    5859                DLIST_REMOVE(l1, el);
    59                 DLIST_ADD_END(l2, el, NULL);
     60                DLIST_ADD_END(l2, el);
    6061        }
    6162
     
    8788
    8889        torture_comment(tctx, "check DLIST_DEMOTE\n");
    89         DLIST_DEMOTE(l1, el, NULL);
     90        DLIST_DEMOTE(l1, el);
    9091        torture_assert(tctx, el->next == NULL, "last in list");
    9192        torture_assert(tctx, el2->prev == el, "backlink from head");
     
    100101
    101102        torture_comment(tctx, "check DLIST_CONCATENATE\n");
    102         DLIST_CONCATENATE(l1, l2, NULL);
     103        DLIST_CONCATENATE(l1, l2);
    103104        torture_comment(tctx, "count forward\n");
    104105        for (i=0,el=l1; el; el=el->next) i++;
  • vendor/current/lib/util/tests/file.c

    r740 r988  
    2323#include "system/filesys.h"
    2424#include "torture/torture.h"
     25#include "torture/local/proto.h"
    2526
    2627#define TEST_FILENAME "utilfile.test"
     
    6667        char *line;
    6768        TALLOC_CTX *mem_ctx = tctx;
     69        bool ret = false;
    6870       
    6971        torture_assert(tctx, file_save(TEST_FILENAME, (const void *)TEST_DATA,
     
    7678
    7779        line = afdgets(fd, mem_ctx, 8);
    78         torture_assert(tctx, strcmp(line, TEST_LINE1) == 0, "line 1 mismatch");
     80        torture_assert_goto(tctx, strcmp(line, TEST_LINE1) == 0, ret, done,
     81                            "line 1 mismatch");
    7982
    8083        line = afdgets(fd, mem_ctx, 8);
    81         torture_assert(tctx, strcmp(line, TEST_LINE2) == 0, "line 2 mismatch");
     84        torture_assert_goto(tctx, strcmp(line, TEST_LINE2) == 0, ret, done,
     85                            "line 2 mismatch");
    8286
    8387        line = afdgets(fd, mem_ctx, 8);
    84         torture_assert(tctx, strcmp(line, TEST_LINE3) == 0, "line 3 mismatch");
    85 
     88        torture_assert_goto(tctx, strcmp(line, TEST_LINE3) == 0, ret, done,
     89                            "line 3 mismatch");
     90        ret = true;
     91done:
    8692        close(fd);
    8793
    8894        unlink(TEST_FILENAME);
    89         return true;
     95        return ret;
    9096}
    9197
  • vendor/current/lib/util/tests/genrand.c

    r740 r988  
    2222#include "includes.h"
    2323#include "torture/torture.h"
    24 
    25 static void dummy_reseed(void *userdata, int *d)
    26 {
    27         *d = 42;
    28 }
    29 
    30 static bool test_reseed_callback(struct torture_context *tctx)
    31 {
    32         set_rand_reseed_callback(dummy_reseed, NULL);
    33         return true;
    34 }
     24#include "torture/local/proto.h"
    3525
    3626static bool test_check_password_quality(struct torture_context *tctx)
     
    4232        torture_assert(tctx, !check_password_quality("123"), "digits only");
    4333        torture_assert(tctx, !check_password_quality("matthiéu"), "not enough high symbols");
    44         torture_assert(tctx, check_password_quality("abcdééàçÚ"), "valid");
     34        torture_assert(tctx, !check_password_quality("abcdééàçÚ"), "only lower case");
     35        torture_assert(tctx, !check_password_quality("abcdééàçÚ+"), "only lower and symbols");
     36        torture_assert(tctx, check_password_quality("abcdééàçÚ+à€¢"), "valid");
     37        torture_assert(tctx, check_password_quality("ç+à€¢"), "valid");
    4538        torture_assert(tctx, check_password_quality("A2e"), "valid");
    4639        torture_assert(tctx, check_password_quality("BA2eLi443"), "valid");
     
    6154{
    6255        struct torture_suite *suite = torture_suite_create(mem_ctx, "genrand");
    63         torture_suite_add_simple_test(suite, "reseed_callback", test_reseed_callback);
    6456        torture_suite_add_simple_test(suite, "check_password_quality", test_check_password_quality);
    6557        torture_suite_add_simple_test(suite, "generate_random_str", test_generate_random_str);
  • vendor/current/lib/util/tests/idtree.c

    r740 r988  
    2222#include "includes.h"
    2323#include "torture/torture.h"
     24#include "torture/local/proto.h"
    2425
    2526static bool torture_local_idtree_simple(struct torture_context *tctx)
  • vendor/current/lib/util/tests/str.c

    r740 r988  
    2222#include "includes.h"
    2323#include "torture/torture.h"
     24#include "torture/local/proto.h"
    2425
    2526static bool test_string_sub_simple(struct torture_context *tctx)
    2627{
    2728        char tmp[100];
    28         safe_strcpy(tmp, "foobar", sizeof(tmp));
     29        strlcpy(tmp, "foobar", sizeof(tmp));
    2930        string_sub(tmp, "foo", "bar", sizeof(tmp));
    3031        torture_assert_str_equal(tctx, tmp, "barbar", "invalid sub");
     
    3536{
    3637        char tmp[100];
    37         safe_strcpy(tmp, "fooblafoo", sizeof(tmp));
     38        strlcpy(tmp, "fooblafoo", sizeof(tmp));
    3839        string_sub(tmp, "foo", "bar", sizeof(tmp));
    3940        torture_assert_str_equal(tctx, tmp, "barblabar", "invalid sub");
     
    4445{
    4546        char tmp[100];
    46         safe_strcpy(tmp, "foobla", sizeof(tmp));
     47        strlcpy(tmp, "foobla", sizeof(tmp));
    4748        string_sub(tmp, "foo", "blie", sizeof(tmp));
    4849        torture_assert_str_equal(tctx, tmp, "bliebla", "invalid sub");
     
    5354{
    5455        char tmp[100];
    55         safe_strcpy(tmp, "foobla", sizeof(tmp));
     56        strlcpy(tmp, "foobla", sizeof(tmp));
    5657        string_sub(tmp, "foo", "bl", sizeof(tmp));
    5758        torture_assert_str_equal(tctx, tmp, "blbla", "invalid sub");
     
    6263{
    6364        char tmp[100];
    64         safe_strcpy(tmp, "foobla", sizeof(tmp));
     65        strlcpy(tmp, "foobla", sizeof(tmp));
    6566        string_sub(tmp, "foo", "%b;l", sizeof(tmp));
    6667        torture_assert_str_equal(tctx, tmp, "_b_lbla", "invalid sub");
  • vendor/current/lib/util/tests/strlist.c

    r740 r988  
    2323#include "includes.h"
    2424#include "torture/torture.h"
     25#include "torture/local/proto.h"
    2526#include "param/param.h"
    2627
     
    111112       
    112113        torture_assert(tctx, ret1, "str_list_make_shell() must not return NULL");
    113         tmp = str_list_join_shell(mem_ctx, (const char **) ret1, element->separators ? *element->separators : ' ');
     114        tmp = str_list_join_shell(mem_ctx, discard_const_p(const char *, ret1),
     115                                  element->separators ? *element->separators : ' ');
    114116        ret2 = str_list_make_shell(mem_ctx, tmp, element->separators);
    115117
     
    161163        const char *empty_list[] = { NULL };
    162164        const char **null_list = NULL;
    163 
    164         result = (const char **)str_list_copy(tctx, list);
     165        char **l;
     166
     167        l = str_list_copy(tctx, list);
     168        result = discard_const_p(const char *, l);
    165169        torture_assert_int_equal(tctx, str_list_length(result), 2, "list length");
    166170        torture_assert_str_equal(tctx, result[0], "foo", "element 0");
     
    168172        torture_assert_str_equal(tctx, result[2], NULL, "element 2");
    169173
    170         result = (const char **)str_list_copy(tctx, empty_list);
     174        l = str_list_copy(tctx, empty_list);
     175        result = discard_const_p(const char *, l);
    171176        torture_assert_int_equal(tctx, str_list_length(result), 0, "list length");
    172177        torture_assert_str_equal(tctx, result[0], NULL, "element 0");
    173178
    174         result = (const char **)str_list_copy(tctx, null_list);
     179        l = str_list_copy(tctx, null_list);
     180        result = discard_const_p(const char *, l);
    175181        torture_assert(tctx, result == NULL, "result NULL");
    176182       
     
    262268                NULL
    263269        };
    264         result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL);
     270        char **l;
     271
     272        l = str_list_make(tctx, "element_0, element_1, element_2", NULL);
     273        result = discard_const_p(const char *, l);
    265274        torture_assert(tctx, result, "str_list_make() must not return NULL");
    266         result2 = str_list_add((const char **) result, "element_3");
     275        result2 = str_list_add(result, "element_3");
    267276        torture_assert(tctx, result2, "str_list_add() must not return NULL");
    268277        torture_assert(tctx, str_list_equal(result2, list),
     
    282291                NULL
    283292        };
    284         result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL);
     293        char **l;
     294
     295        l = str_list_make(tctx, "element_0, element_1, element_2", NULL);
     296        result = discard_const_p(const char *, l);
    285297        torture_assert(tctx, result, "str_list_make() must not return NULL");
    286298        result2 = str_list_add_const(result, "element_3");
     
    301313                NULL
    302314        };
    303         result = (const char **) str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);
     315        char **l;
     316
     317        l = str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);
     318        result = discard_const_p(const char *, l);
    304319        torture_assert(tctx, result, "str_list_make() must not return NULL");
    305320        str_list_remove(result, "element_2");
     
    358373                NULL
    359374        };
    360         result = (const char **) str_list_copy(tctx, list_dup);
     375        char **l;
     376
     377        l = str_list_copy(tctx, list_dup);
     378        result = discard_const_p(const char *, l);
    361379        /* We must copy the list, as str_list_unique does a talloc_realloc() on it's parameter */
    362380        result = str_list_unique(result);
     
    374392        int count, num_dups;
    375393        const char **result;
    376         const char **list = (const char **)str_list_make_empty(tctx);
    377         const char **list_dup = (const char **)str_list_make_empty(tctx);
     394        char **l1 = str_list_make_empty(tctx);
     395        char **l2 = str_list_make_empty(tctx);
     396        const char **list = discard_const_p(const char *, l1);
     397        const char **list_dup = discard_const_p(const char *, l2);
     398        char **l;
    378399
    379400        count = lpcfg_parm_int(tctx->lp_ctx, NULL, "list_unique", "count", 9);
     
    389410        }
    390411
    391         result = (const char **)str_list_copy(tctx, list_dup);
     412        l = str_list_copy(tctx, list_dup);
     413        result = discard_const_p(const char *, l);
    392414        /* We must copy the list, as str_list_unique does a talloc_realloc() on it's parameter */
    393415        result = str_list_unique(result);
     
    424446                NULL
    425447        };
    426         result = (const char **) str_list_copy(tctx, list);
     448        char **l;
     449        l = str_list_copy(tctx, list);
     450        result = discard_const_p(const char *, l);
    427451        torture_assert(tctx, result, "str_list_copy() must not return NULL");
    428452        result = str_list_append(result, list2);
     
    458482                NULL
    459483        };
    460         result = (const char **) str_list_copy(tctx, list);
     484        char **l;
     485        l = str_list_copy(tctx, list);
     486        result = discard_const_p(const char *, l);
    461487        torture_assert(tctx, result, "str_list_copy() must not return NULL");
    462488        result = str_list_append_const(result, list2);
  • vendor/current/lib/util/tests/time.c

    r740 r988  
    2222#include "includes.h"
    2323#include "torture/torture.h"
     24#include "torture/local/proto.h"
    2425
    2526static bool test_null_time(struct torture_context *tctx)
     
    8283}
    8384
    84 static bool test_get_time_zone(struct torture_context *tctx)
    85 {
    86         time_t t = time(NULL);
    87         int old_extra_time_offset = extra_time_offset;
    88         int old_offset, new_offset;
    89         /* test that extra_time_offset works */
    90 
    91         old_offset = get_time_zone(t);
    92         extra_time_offset = 42;
    93         new_offset = get_time_zone(t);
    94         extra_time_offset = old_extra_time_offset;
    95         torture_assert_int_equal(tctx, old_offset+60*42, new_offset,
    96                                  "time offset not used");
    97         return true;
    98 }
    99 
    100 
    10185struct torture_suite *torture_local_util_time(TALLOC_CTX *mem_ctx)
    10286{
     
    10488
    10589        torture_suite_add_simple_test(suite, "null_time", test_null_time);
    106         torture_suite_add_simple_test(suite, "get_time_zone", test_get_time_zone);
    10790        torture_suite_add_simple_test(suite, "null_nttime", test_null_nttime);
    10891        torture_suite_add_simple_test(suite, "http_timestring",
Note: See TracChangeset for help on using the changeset viewer.