From 2bda5e983fad04283f093f578e948e5b614a6cd8 Mon Sep 17 00:00:00 2001 From: shi-yuan-liu Date: Fri, 10 Dec 2021 11:46:05 +0800 Subject: [PATCH] add test c result print --- huawei-add-test-c-result-print.patch | 477 +++++++++++++++++++++++++++ zstd.spec | 6 +- 2 files changed, 482 insertions(+), 1 deletion(-) create mode 100644 huawei-add-test-c-result-print.patch diff --git a/huawei-add-test-c-result-print.patch b/huawei-add-test-c-result-print.patch new file mode 100644 index 0000000..1a8b064 --- /dev/null +++ b/huawei-add-test-c-result-print.patch @@ -0,0 +1,477 @@ +--- zstd-1.5.0/tests/fuzzer.c 2021-12-09 09:48:15.108283586 +0800 ++++ zstd.bak/tests/fuzzer.c 2021-12-07 16:28:18.676842171 +0800 +@@ -472,8 +472,6 @@ + unsigned testNb=0; + size_t cSize; + +- DISPLAY("==== test/fuzzer/basicUnitTest ====\n"); +- + /* Create compressible noise */ + if (!CNBuffer || !compressedBuffer || !decodedBuffer) { + DISPLAY("Not enough memory, aborting\n"); +@@ -3428,9 +3426,6 @@ + #endif /* ZSTD_MULTITHREAD */ + + _end: +- DISPLAY("==== results: passed: %d/%d, failed: %d/%d, skipped: 0/%d ====\n", +- (testNb-testResult), testNb, testResult, testNb, testNb); +- + free(CNBuffer); + free(compressedBuffer); + free(decodedBuffer); +@@ -3453,8 +3448,6 @@ + unsigned testNb=0; + size_t cSize; + +- DISPLAY("==== test/fuzzer/longUnitTest ====\n"); +- + /* Create compressible noise */ + if (!CNBuffer || !compressedBuffer || !decodedBuffer) { + DISPLAY("Not enough memory, aborting\n"); +@@ -3633,10 +3626,6 @@ + DISPLAYLEVEL(3, "OK \n"); + + _end: +- +- DISPLAY("==== results: passed: %d/%d, failed: %d/%d, skipped: 0/%d ====\n", +- (testNb-testResult), testNb, testResult, testNb, testNb); +- + free(CNBuffer); + free(compressedBuffer); + free(decodedBuffer); +@@ -3722,8 +3711,6 @@ + U64 const maxClockSpan = maxDurationS * SEC_TO_MICRO; + int const cLevelLimiter = bigTests ? 3 : 2; + +- DISPLAY("==== test/fuzzer/fuzzerTests ====\n"); +- + /* allocation */ + cNoiseBuffer[0] = (BYTE*)malloc (srcBufferSize); + cNoiseBuffer[1] = (BYTE*)malloc (srcBufferSize); +@@ -3987,9 +3974,6 @@ + DISPLAY("\r%u fuzzer tests completed \n", testNb-1); + + _cleanup: +- DISPLAY("==== results: passed: %d/1, failed: %d/1, skipped: 0/1 ====\n", +- (1-result), result); +- + ZSTD_freeCCtx(refCtx); + ZSTD_freeCCtx(ctx); + ZSTD_freeDCtx(dctx); +--- zstd-1.5.0/tests/fullbench.c 2021-12-09 16:32:14.897179654 +0800 ++++ zstd.bak/tests/fullbench.c 2021-12-07 16:28:18.676842171 +0800 +@@ -474,7 +474,7 @@ + benchFunction = local_ZSTD_compress_generic_T2_end; benchName = "compress_generic, -T2, end"; + break; + default : +- return -1; ++ return 0; + } + + /* Allocation */ +@@ -672,15 +672,8 @@ + size_t benchedSize, double compressibility, + int cLevel, ZSTD_compressionParameters cparams) + { +- int ret = 0; +- int testOk = 0; +- int testEr = 0; +- + /* Allocation */ + void* const origBuff = malloc(benchedSize); +- +- DISPLAY("==== test/fullbench/benchSample[compressibility:%f] ====\n", compressibility); +- + if (!origBuff) { DISPLAY("\nError: not enough memory!\n"); return 12; } + + /* Fill buffer */ +@@ -690,31 +683,12 @@ + DISPLAY("\r%70s\r", ""); + DISPLAY(" Sample %u bytes : \n", (unsigned)benchedSize); + if (benchNb) { +- ret = benchMem(benchNb, origBuff, benchedSize, cLevel, cparams); +- if ( 0 == ret ) +- { +- testOk++; +- } +- else if ( 1 == ret ) +- { +- testEr++; +- } ++ benchMem(benchNb, origBuff, benchedSize, cLevel, cparams); + } else { /* 0 == run all tests */ + for (benchNb=0; benchNb<100; benchNb++) { +- ret = benchMem(benchNb, origBuff, benchedSize, cLevel, cparams); +- if ( 0 == ret ) +- { +- testOk++; +- } +- else if ( 1 == ret ) +- { +- testEr++; +- } ++ benchMem(benchNb, origBuff, benchedSize, cLevel, cparams); + } } + +- DISPLAY("==== results: passed: %d/%d, failed: %d/%d, skipped: 0/%d ====\n", +- testOk, (testOk+testEr), testEr, (testOk+testEr), (testOk+testEr)); +- + free(origBuff); + return 0; + } +@@ -726,12 +700,6 @@ + { + /* Loop for each file */ + int fileIdx; +- int ret = 0; +- int testOk = 0; +- int testEr = 0; +- +- DISPLAY("==== test/fullbench/benchFiles ====\n"); +- + for (fileIdx=0; fileIdx +-#include + #include "zstd.h" + + static const char invalidRepCode[] = { +@@ -39,32 +38,23 @@ + {NULL, 0}, + }; + +-#define DISPLAY(...) fprintf(stderr, __VA_ARGS__) +- + int main(int argc, const char** argv) { + const dictionary *dict; + for (dict = dictionaries; dict->data != NULL; ++dict) { + ZSTD_CDict *cdict; + ZSTD_DDict *ddict; +- +- DISPLAY("==== test/invalidDictionaries ====\n"); +- + cdict = ZSTD_createCDict(dict->data, dict->size, 1); + if (cdict) { + ZSTD_freeCDict(cdict); +- DISPLAY("==== results: passed: 0/2, failed: 1/2, skipped: 1/2 ====\n"); + return 1; + } + ddict = ZSTD_createDDict(dict->data, dict->size); + if (ddict) { + ZSTD_freeDDict(ddict); +- DISPLAY("==== results: passed: 1/2, failed: 1/2, skipped: 0/2 ====\n"); + return 2; + } + } + +- DISPLAY("==== results: passed: 2/2, failed: 0/2, skipped: 0/2 ====\n"); +- + (void)argc; + (void)argv; + return 0; +--- zstd-1.5.0/tests/legacy.c 2021-12-09 11:05:49.790480128 +0800 ++++ zstd.bak/tests/legacy.c 2021-12-07 16:28:18.676842171 +0800 +@@ -160,18 +160,14 @@ + + int main(void) + { +- DISPLAY ("==== test/legacy ====\n"); +- + { int const ret = testSimpleAPI(); +- if (ret) {DISPLAY("==== results: passed: 0/3, failed: 1/3, skipped: 2/3 ====\n");return ret;} } ++ if (ret) return ret; } + { int const ret = testStreamingAPI(); +- if (ret) {DISPLAY("==== results: passed: 1/3, failed: 1/3, skipped: 1/3 ====\n");return ret;} } ++ if (ret) return ret; } + { int const ret = testFrameDecoding(); +- if (ret) {DISPLAY("==== results: passed: 2/3, failed: 1/3, skipped: 0/3 ====\n");return ret;} } ++ if (ret) return ret; } + + DISPLAY("OK\n"); +- DISPLAY("==== results: passed: 3/3, failed: 0/3, skipped: 0/3 ====\n"); +- + return 0; + } + +--- zstd-1.5.0/tests/decodecorpus.c 2021-12-09 14:36:53.425004688 +0800 ++++ zstd.bak/tests/decodecorpus.c 2021-12-07 16:28:18.676842171 +0800 +@@ -1541,7 +1541,6 @@ + + if (numFiles == 0 && !testDurationS) numFiles = 1; + +- DISPLAY("==== test/decodecorpus/runTestMode ====\n"); + DISPLAY("seed: %u\n", (unsigned)seed); + + for (fnum = 0; fnum < numFiles || UTIL_clockSpanMicro(startClock) < maxClockSpan; fnum++) { +@@ -1553,13 +1552,12 @@ + { int const ret = (genType == gt_frame) ? + runFrameTest(&seed) : + runBlockTest(&seed); +- if (ret) {DISPLAY("==== results: passed: 0/1, failed: 1/1, skipped: 0/1 ====\n");return ret;} ++ if (ret) return ret; + } + } + + DISPLAY("\r%u tests completed: ", fnum); + DISPLAY("OK\n"); +- DISPLAY("==== results: passed: 1/1, failed: 0/1, skipped: 0/1 ====\n"); + + return 0; + } +@@ -1573,7 +1571,6 @@ + { + frame_t fr; + +- DISPLAY("==== test/decodecorpus/gerenateFile ====\n"); + DISPLAY("seed: %u\n", (unsigned)seed); + + { dictInfo const info = initDictInfo(0, 0, NULL, 0); +@@ -1587,7 +1584,6 @@ + if (origPath) { + outputBuffer(fr.srcStart, (BYTE*)fr.src - (BYTE*)fr.srcStart, origPath); + } +- DISPLAY("==== results: passed: 1/1, failed: 0/1, skipped: 0/1 ====\n"); + return 0; + } + +@@ -1597,7 +1593,6 @@ + char outPath[MAX_PATH]; + unsigned fnum; + +- DISPLAY("==== test/decodecorpus/generateCorpus ====\n"); + DISPLAY("seed: %u\n", (unsigned)seed); + + for (fnum = 0; fnum < numFiles; fnum++) { +@@ -1615,7 +1610,6 @@ + + if (snprintf(outPath, MAX_PATH, "%s/z%06u.zst", path, fnum) + 1 > MAX_PATH) { + DISPLAY("Error: path too long\n"); +- DISPLAY("==== results: passed: 0/1, failed: 1/1, skipped: 0/1 ====\n"); + return 1; + } + outputBuffer(fr.dataStart, (BYTE*)fr.data - (BYTE*)fr.dataStart, outPath); +@@ -1623,7 +1617,6 @@ + if (origPath) { + if (snprintf(outPath, MAX_PATH, "%s/z%06u", origPath, fnum) + 1 > MAX_PATH) { + DISPLAY("Error: path too long\n"); +- DISPLAY("==== results: passed: 0/1, failed: 1/1, skipped: 0/1 ====\n"); + return 1; + } + outputBuffer(fr.srcStart, (BYTE*)fr.src - (BYTE*)fr.srcStart, outPath); +@@ -1631,7 +1624,7 @@ + } + + DISPLAY("\r%u/%u \n", fnum, numFiles); +- DISPLAY("==== results: passed: 1/1, failed: 0/1, skipped: 0/1 ====\n"); ++ + return 0; + } + +@@ -1644,11 +1637,8 @@ + U32 const dictID = RAND(&seed); + int errorDetected = 0; + +- DISPLAY("==== test/decodecorpus/generateCorpusWithDict ====\n"); +- + if (snprintf(outPath, MAX_PATH, "%s/dictionary", path) + 1 > MAX_PATH) { + DISPLAY("Error: path too long\n"); +- DISPLAY("==== results: passed: 0/1, failed: 1/1, skipped: 0/1 ====\n"); + return 1; + } + +@@ -1656,7 +1646,6 @@ + fullDict = malloc(dictSize); + if (fullDict == NULL) { + DISPLAY("Error: could not allocate space for full dictionary.\n"); +- DISPLAY("==== results: passed: 0/1, failed: 1/1, skipped: 0/1 ====\n"); + return 1; + } + +@@ -1725,8 +1714,6 @@ + } + + dictCleanup: +- DISPLAY("==== results: passed: %d/1, failed: %d/1, skipped: 0/1 ====\n", +- (1-errorDetected), errorDetected); + free(fullDict); + return errorDetected; + } +--- zstd-1.5.0/tests/poolTests.c 2021-12-09 15:07:25.250876163 +0800 ++++ zstd.bak/tests/poolTests.c 2021-12-07 16:28:18.676842171 +0800 +@@ -24,7 +24,6 @@ + } while (0) + #define ASSERT_FALSE(p) ASSERT_TRUE(!(p)) + #define ASSERT_EQ(lhs, rhs) ASSERT_TRUE((lhs) == (rhs)) +-#define DISPLAY(...) fprintf(stderr, __VA_ARGS__) + + struct data { + ZSTD_pthread_mutex_t mutex; +@@ -226,16 +225,11 @@ + + int main(int argc, const char **argv) { + size_t numThreads; +- unsigned testNb = 0; +- + (void)argc; + (void)argv; + +- DISPLAY("==== test/poolTests ====\n"); +- + if (POOL_create(0, 1)) { /* should not be possible */ + printf("FAIL: should not create POOL with 0 threads\n"); +- DISPLAY("==== results; passed: 0/1, failed: 0/1, skipped: 0/1 ====\n"); + return 1; + } + +@@ -246,42 +240,32 @@ + (unsigned)queueSize, (unsigned)numThreads); + if (testOrder(numThreads, queueSize)) { + printf("FAIL: testOrder\n"); +- DISPLAY("==== results; passed: %d/%d, failed: 1/%d, skipped: 0/%d ====\n", +- testNb, (testNb+1), (testNb+1), (testNb+1)); + return 1; + } +- printf("SUCCESS: testOrder\n");testNb++; ++ printf("SUCCESS: testOrder\n"); + if (testWait(numThreads, queueSize)) { + printf("FAIL: testWait\n"); +- DISPLAY("==== results; passed: %d/%d, failed: 1/%d, skipped: 0/%d ====\n", +- testNb, (testNb+1), (testNb+1), (testNb+1)); + return 1; + } +- printf("SUCCESS: testWait\n");testNb++; ++ printf("SUCCESS: testWait\n"); + } + } + + if (testThreadReduction()) { + printf("FAIL: thread reduction not effective \n"); +- DISPLAY("==== results; passed: %d/%d, failed: 1/%d, skipped: 0/%d ====\n", +- testNb, (testNb+1), (testNb+1), (testNb+1)); + return 1; + } else { +- printf("SUCCESS: thread reduction effective \n");testNb++; ++ printf("SUCCESS: thread reduction effective \n"); + } + + if (testAbruptEnding()) { + printf("FAIL: jobs in queue not completed on early end \n"); +- DISPLAY("==== results; passed: %d/%d, failed: 1/%d, skipped: 0/%d ====\n", +- testNb, (testNb+1), (testNb+1), (testNb+1)); + return 1; + } else { +- printf("SUCCESS: all jobs in queue completed on early end \n");testNb++; ++ printf("SUCCESS: all jobs in queue completed on early end \n"); + } + + printf("PASS: all POOL tests\n"); +- DISPLAY("==== results; passed: %d/%d, failed: 0/%d, skipped: 0/%d ====\n", +- testNb, testNb, testNb, testNb); + + return 0; + } diff --git a/zstd.spec b/zstd.spec index 7513f11..eec5ea8 100644 --- a/zstd.spec +++ b/zstd.spec @@ -2,7 +2,7 @@ Name: zstd Version: 1.5.0 -Release: 11 +Release: 12 Summary: A fast lossless compression algorithm License: BSD and GPLv2 URL: https://github.com/facebook/zstd @@ -16,6 +16,7 @@ Patch5: patch-5-add-test-case-survive-a-list-of-files-which-long-file-n Patch6: backport-zstd-1.5.0-patch-6-fix-a-determinism-bug-with-the-DUBT.patch Patch7: patch-7-add-test-case.patch Patch8: patch-8-fix-extra-newline-gets-printes-out-when-compressing-multiple-files.patch +Patch9: huawei-add-test-c-result-print.patch BuildRequires: gtest-devel gcc-c++ pkg-config @@ -94,6 +95,9 @@ install -D -m644 programs/zstd.1 %{buildroot}%{_mandir}/man1/pzstd.1 %{_mandir}/man1/*.1* %changelog +* Fri Dec 10 2021 liushiyuan - 1.5.0.12 +* add test c result print + * Mon Dec 06 2021 helei - 1.5.0.11 * fix extra newline gets printes out when compressing multiple files -- Gitee