2 * Tests for mdssvc packets (un)marshalling
4 * Copyright Ralph Boehme <slow@samba.org> 2019
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "libcli/util/ntstatus.h"
23 #include "lib/util/samba_util.h"
24 #include "lib/torture/torture.h"
25 #include "lib/util/data_blob.h"
26 #include "torture/local/proto.h"
27 #include "mdssvc/marshalling.h"
29 static const unsigned char mdspkt_empty_cnid_fm
[] = {
30 0x34, 0x33, 0x32, 0x31, 0x33, 0x30, 0x64, 0x6d,
31 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
32 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00,
33 0x02, 0x00, 0x00, 0x84, 0x01, 0x00, 0x00, 0x00,
34 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00,
36 0x01, 0x00, 0x00, 0x87, 0x08, 0x00, 0x00, 0x00,
37 0x01, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00,
38 0x01, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x00,
39 0x04, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00,
40 0x02, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x00, 0x00,
41 0x05, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00,
42 0x07, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00
45 static const char *mdspkt_empty_cnid_fm_dump
=
47 " sl_array_t(#3): {\n"
49 " CNIDs: unkn1: 0x0, unkn2: 0x0\n"
50 " DALLOC_CTX(#0): {\n"
52 " sl_filemeta_t(#0): {\n"
57 static bool test_mdspkt_empty_cnid_fm(struct torture_context
*tctx
)
60 sl_cnids_t
*cnids
= NULL
;
66 torture_assert_not_null_goto(tctx
, d
, ret
, done
,
67 "dalloc_new failed\n");
70 (const char *)mdspkt_empty_cnid_fm
,
71 sizeof(mdspkt_empty_cnid_fm
));
72 torture_assert_goto(tctx
, ret
, ret
, done
, "sl_unpack failed\n");
74 cnids
= dalloc_get(d
, "DALLOC_CTX", 0, "sl_cnids_t", 1);
75 torture_assert_not_null_goto(tctx
, cnids
, ret
, done
,
76 "dalloc_get cnids failed\n");
78 ncnids
= dalloc_size(cnids
->ca_cnids
);
79 torture_assert_int_equal_goto(tctx
, ncnids
, 0, ret
, done
,
80 "Wrong number of CNIDs\n");
82 dstr
= dalloc_dump(d
, 0);
83 torture_assert_not_null_goto(tctx
, dstr
, ret
, done
,
84 "dalloc_dump failed\n");
86 torture_assert_str_equal_goto(tctx
, dstr
, mdspkt_empty_cnid_fm_dump
,
87 ret
, done
, "Bad dump\n");
94 struct torture_suite
*torture_local_mdspkt(TALLOC_CTX
*mem_ctx
)
96 struct torture_suite
*suite
=
97 torture_suite_create(mem_ctx
, "mdspkt");
99 torture_suite_add_simple_test(suite
,
101 test_mdspkt_empty_cnid_fm
);