From a674c55bd924b8d0a4cd8087aadac115afd294ad Mon Sep 17 00:00:00 2001 From: Takayuki MATSUOKA Date: Wed, 16 Apr 2014 22:25:18 +0900 Subject: Add .travis.yml .travis.yml in this commit means (1) Language is C. (2) Compiler is 'gcc' (3) Before testing, Travis-CI VM install 'gcc-multilib' for 32bit executables. (4) Travis-CI invokes 'make test'. See also : Getting started http://docs.travis-ci.com/user/getting-started/ Configuring your build http://docs.travis-ci.com/user/build-configuration/ Building a C Project http://docs.travis-ci.com/user/build-configuration/ --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..695c19f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: c +compiler: gcc +script: make test +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq gcc-multilib -- cgit v0.12 From 0390c7dd9d9885b7b629ff97863a2ffb1e6607e9 Mon Sep 17 00:00:00 2001 From: Takayuki MATSUOKA Date: Wed, 16 Apr 2014 23:25:56 +0900 Subject: Add command-line switch to support Travis-CI Add command-line switch '--no-prompt' to fullbench and fuzzer. '--no-prompt' enables : - Throtting stdout to satisfy Travis-CI's stdout limit (10MB). - Prevent Travis-CI's build timeouts and ignore pause by getchar(). http://docs.travis-ci.com/user/build-configuration/#Build-Timeouts --- programs/fullbench.c | 16 ++++++++++++---- programs/fuzzer.c | 25 ++++++++++++++++++------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/programs/fullbench.c b/programs/fullbench.c index 19d10ba..6304029 100644 --- a/programs/fullbench.c +++ b/programs/fullbench.c @@ -50,6 +50,7 @@ #include // fprintf, fopen, ftello64 #include // stat64 #include // stat64 +#include // strcmp // Use ftime() if gettimeofday() is not available on your target #if defined(BMK_LEGACY_TIMER) @@ -138,6 +139,7 @@ struct chunkParameters // MACRO //************************************** #define DISPLAY(...) fprintf(stderr, __VA_ARGS__) +#define PROGRESS(...) no_prompt ? 0 : DISPLAY(__VA_ARGS__) @@ -151,6 +153,7 @@ static int compressionTest = 1; static int decompressionTest = 1; static int compressionAlgo = ALL_COMPRESSORS; static int decompressionAlgo = ALL_DECOMPRESSORS; +static int no_prompt = 0; void BMK_SetBlocksize(int bsize) { @@ -478,7 +481,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles) double averageTime; int milliTime; - DISPLAY("%1i-%-19.19s : %9i ->\r", loopNb, cName, (int)benchedSize); + PROGRESS("%1i-%-19.19s : %9i ->\r", loopNb, cName, (int)benchedSize); { size_t i; for (i=0; i %9i (%5.2f%%),%7.1f MB/s\r", loopNb, cName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000.); + PROGRESS("%1i-%-19.19s : %9i -> %9i (%5.2f%%),%7.1f MB/s\r", loopNb, cName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000.); } if (ratio<100.) @@ -547,7 +550,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles) int milliTime; U32 crcDecoded; - DISPLAY("%1i-%-24.24s :%10i ->\r", loopNb, dName, (int)benchedSize); + PROGRESS("%1i-%-24.24s :%10i ->\r", loopNb, dName, (int)benchedSize); nb_loops = 0; milliTime = BMK_GetMilliStart(); @@ -567,7 +570,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles) averageTime = (double)milliTime / nb_loops; if (averageTime < bestTime) bestTime = averageTime; - DISPLAY("%1i-%-24.24s :%10i -> %7.1f MB/s\r", loopNb, dName, (int)benchedSize, (double)benchedSize / bestTime / 1000.); + PROGRESS("%1i-%-24.24s :%10i -> %7.1f MB/s\r", loopNb, dName, (int)benchedSize, (double)benchedSize / bestTime / 1000.); // CRC Checking crcDecoded = XXH32(orig_buff, (int)benchedSize, 0); @@ -658,6 +661,11 @@ int main(int argc, char** argv) char* argument = argv[i]; if(!argument) continue; // Protection if argument empty + if (!strcmp(argument, "--no-prompt")) + { + no_prompt = 1; + continue; + } // Decode command (note : aggregated commands are allowed) if (argument[0]=='-') diff --git a/programs/fuzzer.c b/programs/fuzzer.c index a2bd33a..ba4f960 100644 --- a/programs/fuzzer.c +++ b/programs/fuzzer.c @@ -34,6 +34,7 @@ #include #include // fgets, sscanf #include // timeb +#include // strcmp #include "lz4.h" #include "lz4hc.h" @@ -121,8 +122,8 @@ int FUZ_SecurityTest() } -//int main(int argc, char *argv[]) { -int main() { +int main(int argc, char** argv) { + const int no_prompt = (argc > 1) && (!strcmp(argv[1], "--no-prompt")); unsigned long long bytes = 0; unsigned long long cbytes = 0; unsigned long long hcbytes = 0; @@ -136,14 +137,14 @@ int main() { int i, j, k, ret, len, lenHC, attemptNb; char userInput[30] = {0}; # define FUZ_CHECKTEST(cond, message) if (cond) { printf("Test %i : %s : seed %u, cycle %i \n", testNb, message, seed, attemptNb); goto _output_error; } -# define FUZ_DISPLAYTEST testNb++; printf("%2i\b\b", testNb); +# define FUZ_DISPLAYTEST testNb++; no_prompt ? 0 : printf("%2i\b\b", testNb); void* stateLZ4 = malloc(LZ4_sizeofState()); void* stateLZ4HC = malloc(LZ4_sizeofStateHC()); printf("starting LZ4 fuzzer (%s)\n", LZ4_VERSION); printf("Select an Initialisation number (default : random) : "); fflush(stdout); - if ( fgets(userInput, sizeof userInput, stdin) ) + if ( no_prompt || fgets(userInput, sizeof userInput, stdin) ) { if ( sscanf(userInput, "%u", &seed) == 1 ) {} else seed = FUZ_GetMilliSpan(timestamp); @@ -160,7 +161,17 @@ int main() { { int testNb = 0; - printf("\r%7i /%7i - ", attemptNb, NB_ATTEMPTS); + // note : promptThrottle is throtting stdout to prevent + // Travis-CI's output limit (10MB) and false hangup detection. + const int promptThrottle = (attemptNb % (NB_ATTEMPTS / 100) == 0); + if (!no_prompt || attemptNb == 0 || promptThrottle) + { + printf("\r%7i /%7i - ", attemptNb, NB_ATTEMPTS); + if (no_prompt) + { + fflush(stdout); + } + } for (j = 0; j < NUM_SEQ; j++) { seeds[j] = FUZ_rand(&randState) << 8; @@ -293,10 +304,10 @@ int main() { printf("all tests completed successfully \n"); printf("compression ratio: %0.3f%%\n", (double)cbytes/bytes*100); printf("HC compression ratio: %0.3f%%\n", (double)hcbytes/bytes*100); - getchar(); + if(!no_prompt) getchar(); return 0; _output_error: - getchar(); + if(!no_prompt) getchar(); return 1; } -- cgit v0.12 From a41790a75934b110eb6a94987b97620a5f5825bf Mon Sep 17 00:00:00 2001 From: Takayuki MATSUOKA Date: Wed, 16 Apr 2014 23:26:15 +0900 Subject: Add build target 'test' --- Makefile | 3 +++ programs/Makefile | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Makefile b/Makefile index 2b09687..e5797c7 100644 --- a/Makefile +++ b/Makefile @@ -145,4 +145,7 @@ dist: clean @sha1sum $(DISTRIBNAME) > $(DISTRIBNAME).sha1 @echo Distribution $(DISTRIBNAME) built +test: lz4programs + @cd $(PRGDIR); $(MAKE) -e $@ + endif diff --git a/programs/Makefile b/programs/Makefile index a1814b6..8ec0b85 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -41,6 +41,7 @@ BINDIR=$(PREFIX)/bin MANDIR=$(PREFIX)/share/man/man1 LZ4DIR=.. +TEST_FILES = COPYING # Define *.exe as extension for Windows systems ifneq (,$(filter Windows%,$(OS))) @@ -103,4 +104,24 @@ uninstall: [ -f $(DESTDIR)$(MANDIR)/lz4.1 ] && rm -f $(DESTDIR)$(MANDIR)/lz4.1 @echo lz4 successfully uninstalled +test: test-lz4 test-lz4c test-lz4c32 test-fuzzer test-fuzzer32 test-fullbench test-fullbench32 + +test-lz4: + +test-lz4c: + +test-lz4c32: + +test-fuzzer: fuzzer + ./fuzzer --no-prompt + +test-fuzzer32: fuzzer32 + ./fuzzer32 --no-prompt + +test-fullbench: fullbench + ./fullbench --no-prompt $(TEST_FILES) + +test-fullbench32: fullbench32 + ./fullbench32 --no-prompt $(TEST_FILES) + endif -- cgit v0.12