Line data Source code
1 : /*
2 : Unix SMB/CIFS implementation.
3 :
4 : anonymous_shared testing
5 :
6 : Copyright (C) Stefan Metzmacher 2011
7 :
8 : This program is free software; you can redistribute it and/or modify
9 : it under the terms of the GNU General Public License as published by
10 : the Free Software Foundation; either version 3 of the License, or
11 : (at your option) any later version.
12 :
13 : This program is distributed in the hope that it will be useful,
14 : but WITHOUT ANY WARRANTY; without even the implied warranty of
15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 : GNU General Public License for more details.
17 :
18 : You should have received a copy of the GNU General Public License
19 : along with this program. If not, see <http://www.gnu.org/licenses/>.
20 : */
21 :
22 : #include "includes.h"
23 : #include "torture/torture.h"
24 : #include "torture/local/proto.h"
25 :
26 0 : static bool test_anonymous_shared_simple(struct torture_context *tctx)
27 : {
28 : void *ptr;
29 : size_t len;
30 :
31 0 : torture_comment(tctx, "anonymous_shared_free(NULL)\n");
32 0 : anonymous_shared_free(NULL);
33 :
34 0 : len = 500;
35 0 : torture_comment(tctx, "anonymous_shared_allocate(%llu)\n",
36 : (unsigned long long)len);
37 0 : ptr = anonymous_shared_allocate(len);
38 0 : torture_assert(tctx, ptr, "valid pointer");
39 0 : memset(ptr, 0xfe, len);
40 0 : torture_comment(tctx, "anonymous_shared_free(ptr)\n");
41 0 : anonymous_shared_free(ptr);
42 :
43 0 : len = 50000;
44 0 : torture_comment(tctx, "anonymous_shared_allocate(%llu)\n",
45 : (unsigned long long)len);
46 0 : ptr = anonymous_shared_allocate(len);
47 0 : torture_assert(tctx, ptr, "valid pointer");
48 0 : memset(ptr, 0xfe, len);
49 0 : torture_comment(tctx, "anonymous_shared_free(ptr)\n");
50 0 : anonymous_shared_free(ptr);
51 :
52 0 : memset(&len, 0xFF, sizeof(len));
53 0 : torture_comment(tctx, "anonymous_shared_allocate(%llu)\n",
54 : (unsigned long long)len);
55 0 : ptr = anonymous_shared_allocate(len);
56 0 : torture_assert(tctx, ptr == NULL, "null pointer");
57 :
58 0 : return true;
59 : }
60 :
61 : /* local.anonymous_shared test suite creation */
62 964 : struct torture_suite *torture_local_util_anonymous_shared(TALLOC_CTX *mem_ctx)
63 : {
64 964 : struct torture_suite *suite = torture_suite_create(mem_ctx, "anonymous_shared");
65 :
66 964 : torture_suite_add_simple_test(suite, "simple",
67 : test_anonymous_shared_simple);
68 :
69 964 : return suite;
70 : }
|