docs: insert function name "we_are_a_wins_server" into wins support parameter
[Samba.git] / lib / compression / testsuite.c
blobd897c88a192d6dc6d3ece3d6177170b0a7bce967
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for the compression functions
5 Copyright (C) Jelmer Vernooij 2007
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "torture/torture.h"
23 #include "talloc.h"
24 #include "lzxpress.h"
27 test lzxpress
29 static bool test_lzxpress(struct torture_context *test)
31 TALLOC_CTX *tmp_ctx = talloc_new(test);
32 const char *fixed_data = "this is a test. and this is a test too";
33 const uint8_t fixed_out[] = { 0x00, 0x20, 0x00, 0x04, 0x74, 0x68, 0x69, 0x73,
34 0x20, 0x10, 0x00, 0x61, 0x20, 0x74, 0x65, 0x73,
35 0x74, 0x2E, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x9F,
36 0x00, 0x04, 0x20, 0x74, 0x6F, 0x6F, 0x00, 0x00,
37 0x00, 0x00 };
38 ssize_t c_size;
39 uint8_t *out, *out2;
41 out = talloc_size(tmp_ctx, 2048);
42 memset(out, 0x42, talloc_get_size(out));
44 torture_comment(test, "lzxpress fixed compression\n");
45 c_size = lzxpress_compress((const uint8_t *)fixed_data,
46 strlen(fixed_data),
47 out,
48 talloc_get_size(out));
50 torture_assert_int_equal(test, c_size, sizeof(fixed_out), "fixed lzxpress_compress size");
51 torture_assert_mem_equal(test, out, fixed_out, c_size, "fixed lzxpress_compress data");
53 torture_comment(test, "lzxpress fixed decompression\n");
54 out2 = talloc_size(tmp_ctx, strlen(fixed_data));
55 c_size = lzxpress_decompress(out,
56 sizeof(fixed_out),
57 out2,
58 talloc_get_size(out2));
60 torture_assert_int_equal(test, c_size, strlen(fixed_data), "fixed lzxpress_decompress size");
61 torture_assert_mem_equal(test, out2, fixed_data, c_size, "fixed lzxpress_decompress data");
63 return true;
67 struct torture_suite *torture_local_compression(TALLOC_CTX *mem_ctx)
69 struct torture_suite *suite = torture_suite_create(mem_ctx, "compression");
71 torture_suite_add_simple_test(suite, "lzxpress", test_lzxpress);
73 return suite;