summaryrefslogtreecommitdiff
path: root/main/lzo/tests
diff options
context:
space:
mode:
Diffstat (limited to 'main/lzo/tests')
-rw-r--r--main/lzo/tests/align.c196
-rw-r--r--main/lzo/tests/chksum.c89
-rw-r--r--main/lzo/tests/promote.c64
-rw-r--r--main/lzo/tests/sizes.c138
4 files changed, 0 insertions, 487 deletions
diff --git a/main/lzo/tests/align.c b/main/lzo/tests/align.c
deleted file mode 100644
index e159bf0e..00000000
--- a/main/lzo/tests/align.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/* align.c -- test alignment (important for 16-bit systems)
-
- This file is part of the LZO real-time data compression library.
-
- Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
- All Rights Reserved.
-
- The LZO library is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- The LZO library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with the LZO library; see the file COPYING.
- If not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- Markus F.X.J. Oberhumer
- <markus@oberhumer.com>
- http://www.oberhumer.com/opensource/lzo/
- */
-
-
-#if 0
-#include "src/lzo_conf.h"
-#include "src/lzo_ptr.h"
-#endif
-#include <lzo/lzoconf.h>
-
-/* utility layer */
-#define WANT_LZO_MALLOC 1
-#include "examples/portab.h"
-
-
-static int opt_verbose = 0;
-
-
-/*************************************************************************
-//
-**************************************************************************/
-
-static unsigned long align_test(lzo_bytep block, lzo_uint len, lzo_uint step)
-{
- lzo_bytep b1 = block;
- lzo_bytep b2 = block;
- lzo_bytep k1 = NULL;
- lzo_bytep k2 = NULL;
- lzo_bytep k;
- lzo_bytep x;
- lzo_uint offset = 0;
- unsigned long i = 0;
-
- assert(step > 0);
- assert(step <= 65536ul);
- assert((step & (step - 1)) == 0);
-
- for (offset = step; offset < len; offset += step)
- {
- k1 = LZO_PTR_ALIGN_UP(b1 + 1, step);
- k2 = b2 + offset;
- if (k1 != k2)
- {
- printf("error 1: i %lu step %ld offset %ld: "
- "%p (%ld) %p (%ld)\n",
- i, (long) step, (long) offset,
- k1, (long) (k1 - block),
- k2, (long) (k2 - block));
- return 0;
- }
- if (k1 - step != b1)
- {
- printf("error 2: i %lu step %ld offset %ld: "
- "%p (%ld) %p (%ld)\n",
- i, (long) step, (long) offset,
- b1, (long) (b1 - block),
- k1, (long) (k1 - block));
- return 0;
- }
-
- assert(k1 > b1);
- assert(k2 > b2);
- assert((lzo_uint)(k2 - b2) == offset);
- assert(k1 - offset == b2);
-#if defined(PTR_ALIGNED_4)
- if (step == 4)
- {
- assert(PTR_ALIGNED_4(k1));
- assert(PTR_ALIGNED_4(k2));
- assert(PTR_ALIGNED2_4(k1,k2));
- }
-#endif
-#if defined(PTR_ALIGNED_8)
- if (step == 8)
- {
- assert(PTR_ALIGNED_8(k1));
- assert(PTR_ALIGNED_8(k2));
- assert(PTR_ALIGNED2_8(k1,k2));
- }
-#endif
-#if defined(PTR_LINEAR)
- assert((PTR_LINEAR(k1) & (step-1)) == 0);
- assert((PTR_LINEAR(k2) & (step-1)) == 0);
-#endif
-
- for (k = b1 + 1; k <= k1; k++)
- {
- x = LZO_PTR_ALIGN_UP(k, step);
- if (x != k1)
- {
- printf("error 3: base: %p %p %p i %lu step %ld offset %ld: "
- "%p (%ld) %p (%ld) %p (%ld)\n",
- block, b1, b2,
- i, (long) step, (long) offset,
- k1, (long) (k1 - block),
- k, (long) (k - block),
- x, (long) (x - block));
- return 0;
- }
- }
-
- b1 = k1;
- i++;
- }
-
- return i;
-}
-
-
-/*************************************************************************
-//
-**************************************************************************/
-
-#define BLOCK_SIZE (128*1024ul)
-
-int main(int argc, char *argv[])
-{
- lzo_bytep buf;
- lzo_uint step;
-
- if (argc >= 2 && strcmp(argv[1],"-v") == 0)
- opt_verbose = 1;
-
- if (lzo_init() != LZO_E_OK)
- {
- printf("lzo_init() failed !!!\n");
- return 3;
- }
- buf = (lzo_bytep) lzo_malloc(2*BLOCK_SIZE + 256);
- if (buf == NULL)
- {
- printf("out of memory\n");
- return 2;
- }
-
-#if defined(lzo_uintptr_t)
- printf("Align init: %p ( 0x%lx )\n", buf, (unsigned long) (lzo_uintptr_t) buf);
-#elif defined(__LZO_MMODEL_HUGE)
- printf("Align init: %p ( 0x%lx )\n", buf, (unsigned long) buf);
-#else
- printf("Align init: %p ( 0x%lx )\n", buf, (unsigned long) (size_t) buf);
-#endif
-
- for (step = 1; step <= 65536ul; step *= 2)
- {
- lzo_bytep block = buf;
- unsigned long n;
- unsigned gap;
-
- gap = __lzo_align_gap(block, step);
- block = LZO_PTR_ALIGN_UP(block, step);
- if (opt_verbose >= 1)
- printf("STEP %5lu: GAP: %5lu %p %p %5lu\n",
- (unsigned long) step, (unsigned long) gap, buf, block,
- (unsigned long) (block - buf));
- n = align_test(block, BLOCK_SIZE, step);
- if (n == 0)
- return 1;
- if ((n + 1) * step != BLOCK_SIZE)
- {
- printf("error 4: %ld %lu\n", (long)step, n);
- return 1;
- }
- }
-
- lzo_free(buf);
- printf("Alignment test passed.\n");
- return 0;
-}
-
-
-/* vim:set ts=4 sw=4 et: */
diff --git a/main/lzo/tests/chksum.c b/main/lzo/tests/chksum.c
deleted file mode 100644
index fc492da2..00000000
--- a/main/lzo/tests/chksum.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* chksum.c -- compute a checksum
-
- This file is part of the LZO real-time data compression library.
-
- Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
- All Rights Reserved.
-
- The LZO library is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- The LZO library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with the LZO library; see the file COPYING.
- If not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- Markus F.X.J. Oberhumer
- <markus@oberhumer.com>
- http://www.oberhumer.com/opensource/lzo/
- */
-
-
-#include <lzo/lzoconf.h>
-
-/* utility layer */
-#define WANT_LZO_MALLOC 1
-#include "examples/portab.h"
-
-
-/*************************************************************************
-//
-**************************************************************************/
-
-int main(int argc, char *argv[])
-{
- lzo_bytep block;
- lzo_uint block_size;
- lzo_uint32_t adler, crc;
-
- if (argc < 0 && argv == NULL) /* avoid warning about unused args */
- return 0;
-
- if (lzo_init() != LZO_E_OK)
- {
- printf("lzo_init() failed !!!\n");
- return 4;
- }
-
-/* prepare the block */
- block_size = 128 * 1024L;
- block = (lzo_bytep) lzo_malloc(block_size);
- if (block == NULL)
- {
- printf("out of memory\n");
- return 3;
- }
- lzo_memset(block, 0, block_size);
-
-/* adler32 checksum */
- adler = lzo_adler32(0, NULL, 0);
- adler = lzo_adler32(adler, block, block_size);
- if (adler != 0x001e0001UL)
- {
- printf("adler32 checksum error !!! (0x%08lx)\n", (long) adler);
- return 2;
- }
-
-/* crc32 checksum */
- crc = lzo_crc32(0, NULL, 0);
- crc = lzo_crc32(crc, block, block_size);
- if (crc != 0x7ee8cdcdUL)
- {
- printf("crc32 checksum error !!! (0x%08lx)\n", (long) crc);
- return 1;
- }
-
- lzo_free(block);
- printf("Checksum test passed.\n");
- return 0;
-}
-
-
-/* vim:set ts=4 sw=4 et: */
diff --git a/main/lzo/tests/promote.c b/main/lzo/tests/promote.c
deleted file mode 100644
index f516f28a..00000000
--- a/main/lzo/tests/promote.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* promote.c -- test intergral promotion
-
- This file is part of the LZO real-time data compression library.
-
- Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
- All Rights Reserved.
-
- The LZO library is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- The LZO library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with the LZO library; see the file COPYING.
- If not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- Markus F.X.J. Oberhumer
- <markus@oberhumer.com>
- http://www.oberhumer.com/opensource/lzo/
- */
-
-#include <stdio.h>
-
-#if defined(_MSC_VER) && (_MSC_VER+0 >= 1000)
- /* disable "unreachable code" warnings */
-# pragma warning(disable: 4702)
-#endif
-
-int main(int argc, char *argv[])
-{
- unsigned char c;
- int s;
-
- if (argc < 0 && argv == NULL) /* avoid warning about unused args */
- return 0;
-
- c = (unsigned char) (1 << (8 * sizeof(char) - 1));
- s = 8 * (int) (sizeof(int) - sizeof(char));
-
- printf("Integral promotion: ");
- {
- const int u = (c << s) > 0;
- if (u)
- {
- printf("Classic C (unsigned-preserving)\n");
- printf("%d %d %uU\n", c, s, (unsigned)c << s);
- return 1;
- }
- else
- {
- printf("ANSI C (value-preserving)\n");
- printf("%d %d %d\n", c, s, c << s);
- return 0;
- }
- }
-}
-
-/* vim:set ts=4 sw=4 et: */
diff --git a/main/lzo/tests/sizes.c b/main/lzo/tests/sizes.c
deleted file mode 100644
index 18a81b04..00000000
--- a/main/lzo/tests/sizes.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/* sizes.c -- print sizes of various types
-
- This file is part of the LZO real-time data compression library.
-
- Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
- All Rights Reserved.
-
- The LZO library is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- The LZO library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with the LZO library; see the file COPYING.
- If not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- Markus F.X.J. Oberhumer
- <markus@oberhumer.com>
- http://www.oberhumer.com/opensource/lzo/
- */
-
-
-#if (defined(_WIN32) || defined(_WIN64)) && defined(_MSC_VER)
-#ifndef _CRT_NONSTDC_NO_DEPRECATE
-#define _CRT_NONSTDC_NO_DEPRECATE 1
-#endif
-#ifndef _CRT_NONSTDC_NO_WARNINGS
-#define _CRT_NONSTDC_NO_WARNINGS 1
-#endif
-#ifndef _CRT_SECURE_NO_DEPRECATE
-#define _CRT_SECURE_NO_DEPRECATE 1
-#endif
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS 1
-#endif
-#endif
-
-#include <lzo/lzoconf.h>
-#include <stdio.h>
-
-#if (LZO_CC_MSC && (_MSC_VER >= 1300))
- /* disable warning C4310: cast truncates constant value */
-# pragma warning(disable: 4310)
-#endif
-
-
-union _lzo_align1_t
-{
- char a_char;
-};
-
-struct _lzo_align2_t
-{
- char a_char;
-};
-
-struct _lzo_align3_t
-{
- char a_char;
- long a_long;
-};
-
-struct _lzo_align4_t
-{
- char a_char;
- char * a_char_p;
-};
-
-struct _lzo_align5_t
-{
- char a_char1;
- long a_long;
- char a_char2;
- char * a_char_p;
-};
-
-union _lzo_align6_t
-{
- char a_char;
- long a_long;
- char * a_char_p;
- lzo_bytep a_lzobytep;
-};
-
-
-#define print_size(type) \
- sprintf(s,"sizeof(%s)",#type); \
- printf("%-30s %2ld\n", s, (long)sizeof(type));
-
-#define print_ssize(type,m) \
- sprintf(s,"sizeof(%s)",#type); \
- printf("%-30s %2ld %20ld\n", s, (long)sizeof(type), (long)(m));
-
-#define print_usize(type,m) \
- sprintf(s,"sizeof(%s)",#type); \
- printf("%-30s %2ld %20lu\n", s, (long)sizeof(type), (unsigned long)(m));
-
-
-int main(int argc, char *argv[])
-{
- char s[80];
-
- print_ssize(char,CHAR_MAX);
- print_usize(unsigned char,UCHAR_MAX);
- print_ssize(short,SHRT_MAX);
- print_usize(unsigned short,USHRT_MAX);
- print_ssize(int,INT_MAX);
- print_usize(unsigned int,UINT_MAX);
- print_ssize(long,LONG_MAX);
- print_usize(unsigned long,ULONG_MAX);
- printf("\n");
- print_size(char *);
- print_size(void (*)(void));
- printf("\n");
- print_ssize(lzo_int,LZO_INT_MAX);
- print_usize(lzo_uint,LZO_UINT_MAX);
- print_size(lzo_bytep);
- printf("\n");
- print_size(union _lzo_align1_t);
- print_size(struct _lzo_align2_t);
- print_size(struct _lzo_align3_t);
- print_size(struct _lzo_align4_t);
- print_size(struct _lzo_align5_t);
- print_size(union _lzo_align6_t);
-
- if (argc < 0 && argv == NULL) /* avoid warning about unused args */
- return 0;
- return 0;
-}
-
-
-/* vim:set ts=4 sw=4 et: */