CREATE EXTENSION test_cfs;
|
|
-- The CRC-corruption test case intentionally triggers a WARNING from
|
-- CfsVerifyBlockHeader(); suppress client warnings so the regression output
|
-- stays deterministic.
|
SET client_min_messages = error;
|
|
-- Run all CFS codec tests. A "skip" result (codec not compiled in) is
|
-- acceptable, but no test case may report "fail".
|
SELECT count(*) AS failures
|
FROM cfs_run_tests()
|
WHERE result = 'fail';
|
|
-- The core test cases must always pass regardless of build configuration.
|
SELECT count(*) AS core_failures
|
FROM cfs_run_tests()
|
WHERE test_name IN ('codec_max_level',
|
'compress_page_size_rejected',
|
'crc_corruption_detection',
|
'decompress_original_size_rejected',
|
'default_level_for',
|
'default_write_opts_level',
|
'incompressible_raw_fallback',
|
'policy_flags_roundtrip',
|
'raw_codec_roundtrip',
|
'raw_page_roundtrip',
|
'record_padding_zeroed',
|
'scratch_and_alignment')
|
AND result <> 'ok';
|
|
SELECT test_cfs_codec_available('raw') AS raw_available;
|
|
SELECT test_cfs_roundtrip('raw', decode('7b22636673223a747275657d', 'hex'), 1) AS raw_roundtrip;
|
|
SELECT test_cfs_corrupt_crc('raw') AS raw_corrupt_crc;
|
|
-- Extended codec tests are mandatory in the four-codec CFS profile:
|
-- 6 direct contract cases per codec; missing cases and skips both fail.
|
SELECT count(*) = 12 AND bool_and(result = 'ok') AS pglz_zlib_direct_ok
|
FROM cfs_run_tests()
|
WHERE test_name LIKE 'pglz_%' OR test_name LIKE 'zlib_%';
|
|
SELECT test_cfs_codec_available('pglz') AS pglz_available,
|
test_cfs_codec_available('zlib') AS zlib_available;
|
|
SELECT test_cfs_roundtrip('pglz', decode('7b2261223a317d', 'hex'), 1) AS pglz_page_roundtrip,
|
test_cfs_roundtrip('zlib', decode('7b2261223a317d', 'hex'), 1) AS zlib_page_roundtrip;
|
|
SELECT test_cfs_corrupt_crc('pglz') = 'ok' AS pglz_page_crc,
|
test_cfs_corrupt_crc('zlib') = 'ok' AS zlib_page_crc;
|
|
-- Pin the diagnostic contract of the corruption path: the deliberate CRC
|
-- corruption must emit a WARNING naming the CRC mismatch before the
|
-- function reports the detected corruption. The corrupted data_crc is
|
-- covered by the header CRC, so the decompressor trips over the header
|
-- check; the raw codec makes both CRC values deterministic (the payload is
|
-- the verbatim 0x7F-filled page), so the exact hex values are stable across
|
-- runs and builds. Pinning the absolute values is deliberate: they pin
|
-- the on-disk record/header layout itself, so a future format change
|
-- (fields, alignment) is expected to break this output and must be
|
-- acknowledged by recomputing it, not by loosening the check.
|
SET client_min_messages = warning;
|
SELECT test_cfs_corrupt_crc('raw') AS raw_corrupt_crc_diagnostics;
|