/* Run multiple compression tests on data stored in a file */ int test_compress_file(char *file_name) { int ret = IGZIP_COMP_OK; uint32_t in_size; uint8_t *in_buf = NULL; FILE *in_file = NULL; in_file = fopen(file_name, "rb"); if (!in_file) return FILE_READ_FAILED; in_size = get_filesize(in_file); if (in_size != 0) { in_buf = malloc(in_size); if (in_buf == NULL) return MALLOC_FAILED; fread(in_buf, 1, in_size, in_file); } ret |= test_compress_stateless(in_buf, in_size); ret |= test_compress(in_buf, in_size, NO_FLUSH); ret |= test_compress(in_buf, in_size, SYNC_FLUSH); ret |= test_flush(in_buf, in_size); if (ret) printf("Failed on file %s\n", file_name); if (in_buf != NULL) free(in_buf); return ret; }
static int test_packet_table(hid_t fid) { if( test_create_close(fid) < 0 ) return -1; if( test_open(fid) < 0 ) return -1; /* test_append must be run before test_count and test_read, as it */ /* creates the packet table they use. */ if( test_append(fid) < 0 ) return -1; /* These tests will not necessarily cause failures in each other, so we don't abort the other tests if one fails. */ test_read(fid); test_get_next(fid); test_big_table(fid); test_rw_nonnative_dt(fid); #ifdef VLPT_REMOVED test_varlen(fid); #endif /* VLPT_REMOVED */ test_opaque(fid); test_compress(); test_error(fid); return 0; }
int main(int argc, char** argv) { char inpFilename[256] = { 0 }; char lz4Filename[256] = { 0 }; char decFilename[256] = { 0 }; if(argc < 2) { printf("Please specify input filename\n"); return 0; } snprintf(inpFilename, 256, "%s", argv[1]); snprintf(lz4Filename, 256, "%s.lz4s-%d", argv[1], 0); snprintf(decFilename, 256, "%s.lz4s-%d.dec", argv[1], 0); printf("inp = [%s]\n", inpFilename); printf("lz4 = [%s]\n", lz4Filename); printf("dec = [%s]\n", decFilename); // compress { FILE* inpFp = fopen(inpFilename, "rb"); FILE* outFp = fopen(lz4Filename, "wb"); test_compress(outFp, inpFp); fclose(outFp); fclose(inpFp); } // decompress { FILE* inpFp = fopen(lz4Filename, "rb"); FILE* outFp = fopen(decFilename, "wb"); test_decompress(outFp, inpFp); fclose(outFp); fclose(inpFp); } // verify { FILE* inpFp = fopen(inpFilename, "rb"); FILE* decFp = fopen(decFilename, "rb"); const int cmp = compare(inpFp, decFp); if(0 == cmp) { printf("Verify : OK\n"); } else { printf("Verify : NG\n"); } fclose(decFp); fclose(inpFp); } return 0; }
int main ( void ) { test_compress(gps_csv, sizeof(gps_csv)); test_compress(gps_delta_csv, sizeof(gps_delta_csv)); test_compress(HVAC_csv, sizeof(HVAC_csv)); test_compress(route_csv, sizeof(route_csv)); test_compress(sensordata_csv, sizeof(sensordata_csv)); test_compress(walk_csv, sizeof(walk_csv)); test_compress(weather_csv, sizeof(weather_csv)); }
int main(int argc, char** argv) { FILE *fl = fopen("testdata.txt", "r"); char *data = (char*)malloc(1024*1024); size_t len = fread(data, 1, 1024*1024, fl); test_compress(data, len); fclose(fl); getchar(); }
int main (int argc, const char * argv[]) { if (1) { test_database(); } if (1) { test_compress(); } return 0; }
int main( int argc, char *argv[]) { Byte *compr, *uncompr; uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; static const char* myVersion = ZLIB_VERSION; if (zlibVersion()[0] != myVersion[0]) { fprintf(stderr, "incompatible zlib version\n"); exit(1); } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { fprintf(stderr, "warning: different zlib version\n"); } printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); compr = (Byte*)calloc((uInt)comprLen, 1); uncompr = (Byte*)calloc((uInt)uncomprLen, 1); /* compr and uncompr are cleared to avoid reading uninitialized * data and to ensure that uncompr compresses well. */ if (compr == Z_NULL || uncompr == Z_NULL) { printf("out of memory\n"); exit(1); } test_compress(compr, comprLen, uncompr, uncomprLen); test_gzio((argc > 1 ? argv[1] : TESTFILE), uncompr, uncomprLen); test_deflate(compr, comprLen); test_inflate(compr, comprLen, uncompr, uncomprLen); test_large_deflate(compr, comprLen, uncompr, uncomprLen); test_large_inflate(compr, comprLen, uncompr, uncomprLen); test_flush(compr, &comprLen); test_sync(compr, comprLen, uncompr, uncomprLen); comprLen = uncomprLen; test_dict_deflate(compr, comprLen); test_dict_inflate(compr, comprLen, uncompr, uncomprLen); free(compr); free(uncompr); return 0; }
int main() { gsl_rng *r = gsl_rng_alloc(gsl_rng_default); test_memcpy(10, 10, r); test_memcpy(10, 15, r); test_memcpy(53, 213, r); test_memcpy(920, 2, r); test_memcpy(2, 920, r); test_getset(20, 20, r); test_getset(30, 20, r); test_getset(15, 210, r); test_ops(20, 20, r); test_ops(50, 20, r); test_ops(20, 50, r); test_ops(76, 43, r); /** Test compresion (spcompress.c) with duplicates and transposition (spswap.c) */ test_compress(15, 5, 0.2, r); /** Test manipulation (spmanip.c)*/ test_manip(5, 8, 0.2, r); /** Test tests (spprop.c) */ test_prop(5, 5, 0.5, 0.5, r); /** Test Input/Output */ //fprintf(stdout, "Testing Input/Output:\nInput matrix (summing duplicate):\n"); //test_io(stdin, stdout); gsl_rng_free(r); exit (gsl_test_summary()); } /* main() */
int main(int argc, char** argv) { char inpfilename[256] = { 0 }; char lz4filename[256] = { 0 }; char decfilename[256] = { 0 }; unsigned fileid = 1; unsigned pause = 0; if(argc < 2) { printf("please specify input filename\n"); return 0; } if (!strcmp(argv[1], "-p")) pause = 1, fileid = 2; snprintf(inpfilename, 256, "%s", argv[fileid]); snprintf(lz4filename, 256, "%s.lz4s-%d", argv[fileid], 9); snprintf(decfilename, 256, "%s.lz4s-%d.dec", argv[fileid], 9); printf("input = [%s]\n", inpfilename); printf("lz4 = [%s]\n", lz4filename); printf("decoded = [%s]\n", decfilename); // compress { file* inpfp = fopen(inpfilename, "rb"); file* outfp = fopen(lz4filename, "wb"); test_compress(outfp, inpfp); fclose(outfp); fclose(inpfp); } // decompress { file* inpfp = fopen(lz4filename, "rb"); file* outfp = fopen(decfilename, "wb"); test_decompress(outfp, inpfp); fclose(outfp); fclose(inpfp); } // verify { file* inpfp = fopen(inpfilename, "rb"); file* decfp = fopen(decfilename, "rb"); const size_t cmp = compare(inpfp, decfp); if(0 == cmp) { printf("verify : ok\n"); } else { printf("verify : ng : error at pos %u\n", (unsigned)cmp-1); } fclose(decfp); fclose(inpfp); } if (pause) { printf("press enter to continue ...\n"); getchar(); } return 0; }
void file_compressto(FILE* infp, FILE* outfp, size_t* insz, size_t* outsz) { test_compress(outfp, infp, outsz, insz); }
int main(int argc, char* argv[]) { enum { MESSAGE_MAX_BYTES = 1024, RING_BUFFER_BYTES = 1024 * 256 + MESSAGE_MAX_BYTES, }; char inpFilename[256] = { 0 }; char lz4Filename[256] = { 0 }; char decFilename[256] = { 0 }; if (argc < 2) { printf("Please specify input filename\n"); return 0; } snprintf(inpFilename, 256, "%s", argv[1]); snprintf(lz4Filename, 256, "%s.lz4s", argv[1]); snprintf(decFilename, 256, "%s.lz4s.dec", argv[1]); printf("inp = [%s]\n", inpFilename); printf("lz4 = [%s]\n", lz4Filename); printf("dec = [%s]\n", decFilename); // compress { FILE* inpFp = fopen(inpFilename, "rb"); FILE* outFp = fopen(lz4Filename, "wb"); test_compress(outFp, inpFp, MESSAGE_MAX_BYTES, RING_BUFFER_BYTES); fclose(outFp); fclose(inpFp); } // decompress { FILE* inpFp = fopen(lz4Filename, "rb"); FILE* outFp = fopen(decFilename, "wb"); test_decompress(outFp, inpFp, MESSAGE_MAX_BYTES, RING_BUFFER_BYTES); fclose(outFp); fclose(inpFp); } // verify { FILE* inpFp = fopen(inpFilename, "rb"); FILE* decFp = fopen(decFilename, "rb"); const int cmp = compare(inpFp, decFp); if (0 == cmp) printf("Verify : OK\n"); else printf("Verify : NG\n"); fclose(decFp); fclose(inpFp); } return 0; }
int main(int argc, char *argv[]) { int i = 0, ret = 0, fin_ret = 0; uint32_t in_size = 0, offset = 0; uint8_t *in_buf; #ifndef VERBOSE setbuf(stdout, NULL); #endif printf("Window Size: %d K\n", HIST_SIZE); printf("Test Seed : %d\n", TEST_SEED); printf("Randoms : %d\n", RANDOMS); srand(TEST_SEED); in_buf = malloc(IBUF_SIZE); if (in_buf == NULL) { fprintf(stderr, "Can't allocate in_buf memory\n"); return -1; } if (argc > 1) { printf("igzip_rand_test files: "); for (i = 1; i < argc; i++) { ret |= test_compress_file(argv[i]); if (ret) return ret; } printf("................"); printf("%s\n", ret ? "Fail" : "Pass"); fin_ret |= ret; } printf("igzip_rand_test stateless: "); ret = test_compress_stateless((uint8_t *) str1, sizeof(str1)); if (ret) return ret; ret |= test_compress_stateless((uint8_t *) str2, sizeof(str2)); if (ret) return ret; for (i = 0; i < RANDOMS; i++) { in_size = rand() % (IBUF_SIZE + 1); offset = rand() % (IBUF_SIZE + 1 - in_size); in_buf += offset; create_rand_repeat_data(in_buf, in_size); ret |= test_compress_stateless(in_buf, in_size); in_buf -= offset; if (i % (RANDOMS / 16) == 0) printf("."); if (ret) return ret; } fin_ret |= ret; printf("%s\n", ret ? "Fail" : "Pass"); printf("igzip_rand_test NO_FLUSH: "); ret = test_compress((uint8_t *) str1, sizeof(str1), NO_FLUSH); if (ret) return ret; ret |= test_compress((uint8_t *) str2, sizeof(str2), NO_FLUSH); if (ret) return ret; for (i = 0; i < RANDOMS; i++) { in_size = rand() % (IBUF_SIZE + 1); offset = rand() % (IBUF_SIZE + 1 - in_size); in_buf += offset; create_rand_repeat_data(in_buf, in_size); ret |= test_compress(in_buf, in_size, NO_FLUSH); in_buf -= offset; if (i % (RANDOMS / 16) == 0) printf("."); if (ret) return ret; } fin_ret |= ret; printf("%s\n", ret ? "Fail" : "Pass"); printf("igzip_rand_test SYNC_FLUSH: "); ret = test_compress((uint8_t *) str1, sizeof(str1), SYNC_FLUSH); if (ret) return ret; ret |= test_compress((uint8_t *) str2, sizeof(str2), SYNC_FLUSH); if (ret) return ret; for (i = 0; i < RANDOMS; i++) { in_size = rand() % (IBUF_SIZE + 1); offset = rand() % (IBUF_SIZE + 1 - in_size); in_buf += offset; create_rand_repeat_data(in_buf, in_size); ret |= test_compress(in_buf, in_size, SYNC_FLUSH); in_buf -= offset; if (i % (RANDOMS / 16) == 0) printf("."); if (ret) return ret; } fin_ret |= ret; printf("%s\n", ret ? "Fail" : "Pass"); printf("igzip rand test finished: %s\n", fin_ret ? "Some tests failed" : "All tests passed"); return fin_ret != IGZIP_COMP_OK; }
int _tmain(int argc, _TCHAR* argv[]) { test_GzipByMem(); test_compress(); return 0; }