From 260ff2f6b7d590345bde6825a1ad0dc7b9aac9b1 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 6 Jan 2019 23:42:24 +0700 Subject: [PATCH] tests/legagy.c: More fixes --- tests/legacy.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/legacy.c b/tests/legacy.c index 4234e8fb..b749567f 100644 --- a/tests/legacy.c +++ b/tests/legacy.c @@ -74,6 +74,7 @@ static int testSimpleAPI(void) static int testStreamingAPI(void) { + int error_code = 0; size_t const outBuffSize = ZSTD_DStreamOutSize(); char* const outBuff = malloc(outBuffSize); ZSTD_DStream* const stream = ZSTD_createDStream(); @@ -97,13 +98,15 @@ static int testStreamingAPI(void) size_t const ret = ZSTD_initDStream(stream); if (ZSTD_isError(ret)) { DISPLAY("ERROR: ZSTD_initDStream: %s\n", ZSTD_getErrorName(ret)); - return 1; + error_code = 1; + break; } } { size_t const ret = ZSTD_decompressStream(stream, &output, &input); if (ZSTD_isError(ret)) { DISPLAY("ERROR: ZSTD_decompressStream: %s\n", ZSTD_getErrorName(ret)); - return 1; + error_code = 1; + break; } if (ret == 0) { @@ -112,7 +115,8 @@ static int testStreamingAPI(void) if (memcmp(outBuff, EXPECTED + outputPos, output.pos) != 0) { DISPLAY("ERROR: Wrong decoded output produced\n"); - return 1; + error_code = 1; + break; } outputPos += output.pos; if (input.pos == input.size && output.pos < output.size) { @@ -122,8 +126,8 @@ static int testStreamingAPI(void) free(outBuff); ZSTD_freeDStream(stream); - DISPLAY("Streaming API OK\n"); - return 0; + if (error_code == 0) DISPLAY("Streaming API OK\n"); + return error_code; } int main(void)