summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2016-12-22 10:58:29 (GMT)
committerGitHub <noreply@github.com>2016-12-22 10:58:29 (GMT)
commitb41f9bb132e8207999e89d01925e202da98b7649 (patch)
tree4632c6d377ee39fe9bc5011191824360fe7b3990 /tests
parent7eb16d97d238e2b98f1e6453ed6ad64058cb99c1 (diff)
parentfea95c156761ee10d32a4f12105ebd90c67d4f47 (diff)
downloadlz4-b41f9bb132e8207999e89d01925e202da98b7649.zip
lz4-b41f9bb132e8207999e89d01925e202da98b7649.tar.gz
lz4-b41f9bb132e8207999e89d01925e202da98b7649.tar.bz2
Merge pull request #292 from inikep/dev
improved POSIX
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile4
-rw-r--r--tests/datagencli.c20
-rw-r--r--tests/frametest.c26
-rw-r--r--tests/fullbench.c63
-rw-r--r--tests/fuzzer.c25
5 files changed, 18 insertions, 120 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 01b45bc..b63493d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -43,7 +43,7 @@ CFLAGS += -g -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow -Wswitch-e
-Wdeclaration-after-statement -Wstrict-prototypes \
-Wpointer-arith -Wstrict-aliasing=1
CFLAGS += $(MOREFLAGS)
-CPPFLAGS:= -I$(LIBDIR) -DXXH_NAMESPACE=LZ4_
+CPPFLAGS:= -I$(LIBDIR) -I$(PRGDIR) -DXXH_NAMESPACE=LZ4_
FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
@@ -173,7 +173,7 @@ test-lz4-contentSize: lz4 datagen
$(LZ4) -v --content-size tmp | $(LZ4) -d > tmp2
diff -s tmp tmp2
# test large size [2-4] GB
- @./datagen -g3G -P100 | $(LZ4) --verbose | $(LZ4) --decompress --force --sparse - tmp
+ @./datagen -g3G -P100 | $(LZ4) -vv | $(LZ4) --decompress --force --sparse - tmp
@ls -ls tmp
@./datagen -g3G -P100 | $(LZ4) --quiet --content-size | $(LZ4) --verbose --decompress --force --sparse - tmp2
@ls -ls tmp2
diff --git a/tests/datagencli.c b/tests/datagencli.c
index 0b78d37..c985197 100644
--- a/tests/datagencli.c
+++ b/tests/datagencli.c
@@ -27,31 +27,13 @@
/**************************************
* Includes
**************************************/
+#include "util.h" /* U32 */
#include <stdio.h> /* fprintf, stderr */
#include "datagen.h" /* RDG_generate */
#include "lz4.h" /* LZ4_VERSION_STRING */
/**************************************
-* Basic Types
-**************************************/
-#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */
-# include <stdint.h>
- typedef uint8_t BYTE;
- typedef uint16_t U16;
- typedef uint32_t U32;
- typedef int32_t S32;
- typedef uint64_t U64;
-#else
- typedef unsigned char BYTE;
- typedef unsigned short U16;
- typedef unsigned int U32;
- typedef signed int S32;
- typedef unsigned long long U64;
-#endif
-
-
-/**************************************
* Constants
**************************************/
#define KB *(1 <<10)
diff --git a/tests/frametest.c b/tests/frametest.c
index fd07377..e2e0f86 100644
--- a/tests/frametest.c
+++ b/tests/frametest.c
@@ -35,6 +35,7 @@
/*-************************************
* Includes
**************************************/
+#include "util.h" /* U32 */
#include <stdlib.h> /* malloc, free */
#include <stdio.h> /* fprintf */
#include <string.h> /* strcmp */
@@ -45,25 +46,6 @@
#include "xxhash.h" /* XXH64 */
-/*-************************************
-* Basic Types
-**************************************/
-#if !defined(__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
-# include <stdint.h>
-typedef uint8_t BYTE;
-typedef uint16_t U16;
-typedef uint32_t U32;
-typedef int32_t S32;
-typedef uint64_t U64;
-#else
-typedef unsigned char BYTE;
-typedef unsigned short U16;
-typedef unsigned int U32;
-typedef signed int S32;
-typedef unsigned long long U64;
-#endif
-
-
/* unoptimized version; solves endianess & alignment issues */
static void FUZ_writeLE32 (void* dstVoidPtr, U32 value32)
{
@@ -110,7 +92,7 @@ static clock_t g_clockTime = 0;
*****************************************/
static U32 no_prompt = 0;
static U32 displayLevel = 2;
-static U32 pause = 0;
+static U32 use_pause = 0;
/*-*******************************************************
@@ -730,7 +712,7 @@ _end:
free(compressedBuffer);
free(decodedBuffer);
- if (pause) {
+ if (use_pause) {
DISPLAY("press enter to finish \n");
(void)getchar();
}
@@ -802,7 +784,7 @@ int main(int argc, const char** argv)
break;
case 'p': /* pause at the end */
argument++;
- pause = 1;
+ use_pause = 1;
break;
case 'i':
diff --git a/tests/fullbench.c b/tests/fullbench.c
index 7d54492..f489392 100644
--- a/tests/fullbench.c
+++ b/tests/fullbench.c
@@ -23,20 +23,6 @@
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
*/
-/**************************************
-* Compiler Options
-**************************************/
-/* Disable some Visual warning messages */
-#define _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_DEPRECATE /* VS2005 */
-
-/* Unix Large Files support (>4GB) */
-#if (defined(__sun__) && (!defined(__LP64__))) // Sun Solaris 32-bits requires specific definitions
-# define _LARGEFILE_SOURCE
-# define _FILE_OFFSET_BITS 64
-#elif ! defined(__LP64__) // No point defining Large file for 64 bit
-# define _LARGEFILE64_SOURCE
-#endif
// S_ISREG & gettimeofday() are not supported by MSVC
#if defined(_MSC_VER) || defined(_WIN32)
@@ -47,8 +33,10 @@
/**************************************
* Includes
**************************************/
+#include "platform.h" /* _CRT_SECURE_NO_WARNINGS, Large Files support */
+#include "util.h" /* U32, UTIL_getFileSize */
#include <stdlib.h> /* malloc, free */
-#include <stdio.h> /* fprintf, fopen, ftello64 */
+#include <stdio.h> /* fprintf, fopen, ftello */
#include <sys/types.h> /* stat64 */
#include <sys/stat.h> /* stat64 */
#include <string.h> /* strcmp */
@@ -62,34 +50,6 @@
/**************************************
-* Compiler Options
-**************************************/
-/* S_ISREG & gettimeofday() are not supported by MSVC */
-#if !defined(S_ISREG)
-# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
-#endif
-
-
-/**************************************
-* Basic Types
-**************************************/
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
-# include <stdint.h>
- typedef uint8_t BYTE;
- typedef uint16_t U16;
- typedef uint32_t U32;
- typedef int32_t S32;
- typedef uint64_t U64;
-#else
- typedef unsigned char BYTE;
- typedef unsigned short U16;
- typedef unsigned int U32;
- typedef signed int S32;
- typedef unsigned long long U64;
-#endif
-
-
-/**************************************
* Constants
**************************************/
#define PROGRAM_DESCRIPTION "LZ4 speed analyzer"
@@ -194,21 +154,6 @@ static size_t BMK_findMaxMem(U64 requiredMem)
}
-static U64 BMK_GetFileSize(const char* infilename)
-{
- int r;
-#if defined(_MSC_VER)
- struct _stat64 statbuf;
- r = _stat64(infilename, &statbuf);
-#else
- struct stat statbuf;
- r = stat(infilename, &statbuf);
-#endif
- if (r || !S_ISREG(statbuf.st_mode)) return 0; /* No good... */
- return (U64)statbuf.st_size;
-}
-
-
/*********************************************************
* Benchmark function
*********************************************************/
@@ -398,7 +343,7 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
if (inFile==NULL) { DISPLAY( "Pb opening %s\n", inFileName); return 11; }
/* Memory size adjustments */
- inFileSize = BMK_GetFileSize(inFileName);
+ inFileSize = UTIL_getFileSize(inFileName);
if (inFileSize==0) { DISPLAY( "file is empty\n"); fclose(inFile); return 11; }
benchedSize = BMK_findMaxMem(inFileSize*2) / 2; /* because 2 buffers */
if (benchedSize==0) { DISPLAY( "not enough memory\n"); fclose(inFile); return 11; }
diff --git a/tests/fuzzer.c b/tests/fuzzer.c
index 260208a..ff02e0c 100644
--- a/tests/fuzzer.c
+++ b/tests/fuzzer.c
@@ -27,7 +27,6 @@
* Compiler options
**************************************/
#ifdef _MSC_VER /* Visual Studio */
-# define _CRT_SECURE_NO_WARNINGS /* fgets */
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
# pragma warning(disable : 4146) /* disable: C4146: minus unsigned expression */
# pragma warning(disable : 4310) /* disable: C4310: constant char value > 127 */
@@ -37,6 +36,8 @@
/*-************************************
* Dependencies
**************************************/
+#include "platform.h" /* _CRT_SECURE_NO_WARNINGS */
+#include "util.h" /* U32 */
#include <stdlib.h>
#include <stdio.h> /* fgets, sscanf */
#include <string.h> /* strcmp */
@@ -49,19 +50,7 @@
/*-************************************
* Basic Types
**************************************/
-#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
-# include <stdint.h>
-typedef uint8_t BYTE;
-typedef uint16_t U16;
-typedef uint32_t U32;
-typedef int32_t S32;
-typedef uint64_t U64;
-#else
-typedef unsigned char BYTE;
-typedef unsigned short U16;
-typedef unsigned int U32;
-typedef signed int S32;
-typedef unsigned long long U64;
+#if !defined(__cplusplus) && !(defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
typedef size_t uintptr_t; /* true on most systems, except OpenVMS-64 (which doesn't need address overflow test) */
#endif
@@ -1000,7 +989,7 @@ int main(int argc, const char** argv)
int nbTests = NB_ATTEMPTS;
int testNb = 0;
int proba = FUZ_COMPRESSIBILITY_DEFAULT;
- int pause = 0;
+ int use_pause = 0;
const char* programName = argv[0];
U32 duration = 0;
@@ -1012,7 +1001,7 @@ int main(int argc, const char** argv)
// Decode command (note : aggregated commands are allowed)
if (argument[0]=='-') {
- if (!strcmp(argument, "--no-prompt")) { pause=0; seedset=1; g_displayLevel=1; continue; }
+ if (!strcmp(argument, "--no-prompt")) { use_pause=0; seedset=1; g_displayLevel=1; continue; }
argument++;
while (*argument!=0) {
@@ -1028,7 +1017,7 @@ int main(int argc, const char** argv)
case 'p': /* pause at the end */
argument++;
- pause=1;
+ use_pause=1;
break;
case 'i':
@@ -1118,7 +1107,7 @@ int main(int argc, const char** argv)
if (nbTests<=0) nbTests=1;
{ int const result = FUZ_test(seed, nbTests, testNb, ((double)proba) / 100, duration);
- if (pause) {
+ if (use_pause) {
DISPLAY("press enter ... \n");
(void)getchar();
}