diff options
author | Lukas Larsson <[email protected]> | 2016-08-26 15:53:51 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2016-08-26 15:53:51 +0200 |
commit | 85234b4069c9b75e3ae5ddf643b981d7428fb81f (patch) | |
tree | aa52443a80eecf23664cf56ed74cb395cab5a96c /lib | |
parent | d017ade88b8fa39f57aee722dd2e2c5d82e8b262 (diff) | |
parent | 6fe89e38d40132e6acac2233d45ea44da49d1021 (diff) | |
download | otp-85234b4069c9b75e3ae5ddf643b981d7428fb81f.tar.gz otp-85234b4069c9b75e3ae5ddf643b981d7428fb81f.tar.bz2 otp-85234b4069c9b75e3ae5ddf643b981d7428fb81f.zip |
Merge branch 'g-andrade/kernel/fetch_ztream_dictionary/PR-1139/OTP-13842'
* g-andrade/kernel/fetch_ztream_dictionary/PR-1139/OTP-13842:
Update preloaded modules
Specify min zlib ver on inflateGetDictionary doc
Skip inflateGetDictionary test case if unsupported
zlib: Only link inflateGetDictionary if available
zlib: Add test case for inflateGetDictionary
zlib: support extraction of inflation dictionary
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kernel/test/zlib_SUITE.erl | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/kernel/test/zlib_SUITE.erl b/lib/kernel/test/zlib_SUITE.erl index f8257bd20c..4b67fce9a8 100644 --- a/lib/kernel/test/zlib_SUITE.erl +++ b/lib/kernel/test/zlib_SUITE.erl @@ -83,7 +83,7 @@ groups() -> [api_open_close, api_deflateInit, api_deflateSetDictionary, api_deflateReset, api_deflateParams, api_deflate, api_deflateEnd, - api_inflateInit, api_inflateSetDictionary, + api_inflateInit, api_inflateSetDictionary, api_inflateGetDictionary, api_inflateSync, api_inflateReset, api_inflate, api_inflateChunk, api_inflateEnd, api_setBufsz, api_getBufsz, api_crc32, api_adler32, api_getQSize, api_un_compress, api_un_zip, @@ -288,6 +288,42 @@ api_inflateSetDictionary(Config) when is_list(Config) -> ?m({'EXIT',{stream_error,_}}, zlib:inflateSetDictionary(Z1,Dict)), ?m(ok, zlib:close(Z1)). +%% Test inflateGetDictionary. +api_inflateGetDictionary(Config) when is_list(Config) -> + Z1 = zlib:open(), + IsOperationSupported = + case catch zlib:inflateGetDictionary(Z1) of + {'EXIT',{einval,_}} -> true; + {'EXIT',{enotsup,_}} -> false + end, + _ = zlib:close(Z1), + api_inflateGetDictionary_if_supported(IsOperationSupported). + +api_inflateGetDictionary_if_supported(false) -> + {skip, "inflateGetDictionary/1 unsupported in current setup"}; +api_inflateGetDictionary_if_supported(true) -> + % Compress payload using custom dictionary + Z1 = zlib:open(), + ?m(ok, zlib:deflateInit(Z1)), + Dict = <<"foobar barfoo foo bar far boo">>, + ?m(_, zlib:deflateSetDictionary(Z1, Dict)), + Payload = <<"foobarbarbar">>, + Compressed = zlib:deflate(Z1, Payload, finish), + ?m(ok, zlib:close(Z1)), + + % Decompress and test dictionary extraction + Z2 = zlib:open(), + ?m(ok, zlib:inflateInit(Z2)), + ?m(<<>>, iolist_to_binary(zlib:inflateGetDictionary(Z2))), + ?m({'EXIT',{stream_error,_}}, zlib:inflateSetDictionary(Z2, Dict)), + ?m({'EXIT',{{need_dictionary,_},_}}, zlib:inflate(Z2, Compressed)), + ?m(ok, zlib:inflateSetDictionary(Z2, Dict)), + ?m(Dict, iolist_to_binary(zlib:inflateGetDictionary(Z2))), + ?m(Payload, iolist_to_binary(zlib:inflate(Z2, Compressed))), + ?m(ok, zlib:close(Z2)), + ?m(?BARG, zlib:inflateSetDictionary(Z2, Dict)), + ok. + %% Test inflateSync. api_inflateSync(Config) when is_list(Config) -> {skip,"inflateSync/1 sucks"}. |