From ff9c0c18426669914d5d645ce87dadd514407283 Mon Sep 17 00:00:00 2001 From: Hailiang Wang Date: Fri, 5 May 2017 10:39:56 +0800 Subject: [PATCH] igzip:change the default max file size for 32-bit builds. Change-Id: Ifab108250cfd06211843b5eccb1f1f0482669426 Signed-off-by: Hailiang Wang --- igzip/Makefile.am | 4 ++-- igzip/igzip_inflate_test.c | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/igzip/Makefile.am b/igzip/Makefile.am index 7b70ad6..22d4ffd 100644 --- a/igzip/Makefile.am +++ b/igzip/Makefile.am @@ -115,9 +115,9 @@ other_src += igzip/crc_inflate.h igzip_inflate_perf: LDLIBS += -lz igzip_igzip_inflate_perf_LDADD = libisal.la igzip_igzip_inflate_perf_LDFLAGS = -lz -igzip_inflate_test: LDLIBS += -lz +igzip_inflate_test: LDLIBS += -lz -D_FILE_OFFSET_BITS=64 igzip_igzip_inflate_test_LDADD = libisal.la -igzip_igzip_inflate_test_LDFLAGS = -lz +igzip_igzip_inflate_test_LDFLAGS = -lz -D_FILE_OFFSET_BITS=64 igzip_igzip_hist_perf_LDADD = libisal.la igzip_fuzz_inflate: LDLIBS += -lz igzip_igzip_fuzz_inflate_LDADD = libisal.la diff --git a/igzip/igzip_inflate_test.c b/igzip/igzip_inflate_test.c index a1f9b9a..5bb71f6 100644 --- a/igzip/igzip_inflate_test.c +++ b/igzip/igzip_inflate_test.c @@ -35,7 +35,11 @@ /*Don't use file larger memory can support because compression and decompression * are done in a stateless manner. */ +# if __WORDSIZE == 64 #define MAX_INPUT_FILE_SIZE 2L*1024L*1024L*1024L +# else +#define MAX_INPUT_FILE_SIZE 512L*1024L*1024L +#endif int inflate_multi_pass(uint8_t * compress_buf, uint64_t compress_len, uint8_t * uncompress_buf, uint32_t * uncompress_len) @@ -149,7 +153,7 @@ int test(uint8_t * compressed_stream, { int ret; ret = - compress2(compressed_stream, compressed_length, + compress2(compressed_stream, (uLongf *) compressed_length, uncompressed_stream, uncompressed_length, 6); if (ret) { printf("Failed compressing input with exit code %d", ret); @@ -235,7 +239,9 @@ int main(int argc, char **argv) fseek(file, 0, SEEK_SET); file_length -= ftell(file); if (file_length > MAX_INPUT_FILE_SIZE) { - printf("File too large to run on this test\n"); + printf("\nFile too large to run on this test," + " Max 512MB for 32bit OS, 2GB for 64bit OS.\n"); + printf(" ... Fail\n"); fclose(file); continue; } @@ -247,17 +253,17 @@ int main(int argc, char **argv) } compressed_stream = malloc(compressed_length); if (uncompressed_stream == NULL && file_length != 0) { - printf("Failed to allocate memory\n"); + printf("\nFailed to allocate memory\n"); exit(0); } if (compressed_stream == NULL) { - printf("Failed to allocate memory\n"); + printf("\nFailed to allocate memory\n"); exit(0); } if (uncompressed_test_stream == NULL) { - printf("Failed to allocate memory\n"); + printf("\nFailed to allocate memory\n"); exit(0); }