From: gregor herrmann Date: Sun, 27 Jul 2014 20:24:16 +0000 (+0200) Subject: Imported Upstream version 3.001.004 X-Git-Tag: archive/raspbian/4.017+ds-1+rpi1~1^2~3^2~23 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0a6359d7e1e6adde1752c4e0e1dc9c6d2b824179;p=libsereal-encoder-perl.git Imported Upstream version 3.001.004 --- diff --git a/Changes b/Changes index c55ae4a..fca4f6e 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,13 @@ Revision history for Perl extension Sereal-Encoder * Warning: For a seamless upgrade, upgrade to version 3 * of the decoder before upgrading to version 3 of the * encoder! +3.001_004 Sun, July 27 2014 + - Rework bulk tests so that tests are grouped by options and version + - Fixups for non-x86 architectures. + +3.001_003 +3.001_002 + - Attempts to fix builds on sparc, s390x and ARM. 3.001_001 - Patches from Jarkko Hietaniemi to make Sereal pass test diff --git a/MANIFEST b/MANIFEST index 4d9fcb8..e7b1b3a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -47,9 +47,24 @@ t/160_recursion.t t/200_bulk.t t/300_fail.t t/400_evil.t -t/700_roundtrip.t -t/701_roundtrip_v1.t -t/702_roundtrip_v2.t +t/700_roundtrip/v1/plain.t +t/700_roundtrip/v1/snappy.t +t/700_roundtrip/v2/dedudep_strings.t +t/700_roundtrip/v2/freeze_thaw.t +t/700_roundtrip/v2/plain.t +t/700_roundtrip/v2/readonly.t +t/700_roundtrip/v2/snappy.t +t/700_roundtrip/v2/snappy_incr.t +t/700_roundtrip/v2/sort_keys.t +t/700_roundtrip/v3/dedudep_strings.t +t/700_roundtrip/v3/freeze_thaw.t +t/700_roundtrip/v3/plain.t +t/700_roundtrip/v3/readonly.t +t/700_roundtrip/v3/snappy.t +t/700_roundtrip/v3/snappy_incr.t +t/700_roundtrip/v3/sort_keys.t +t/700_roundtrip/v3/zlib.t +t/700_roundtrip/v3/zlib_force.t t/800_threads.t t/900_reentrancy.t t/data/corpus diff --git a/META.json b/META.json index c40b123..73ec5f6 100644 --- a/META.json +++ b/META.json @@ -55,5 +55,5 @@ "url" : "git://github.com/Sereal/Sereal.git" } }, - "version" : "3.001_003" + "version" : "3.001_004" } diff --git a/META.yml b/META.yml index 7923d7e..c70f07d 100644 --- a/META.yml +++ b/META.yml @@ -32,4 +32,4 @@ requires: resources: bugtracker: https://github.com/Sereal/Sereal/issues repository: git://github.com/Sereal/Sereal.git -version: 3.001_003 +version: 3.001_004 diff --git a/Makefile.PL b/Makefile.PL index 6e5d193..0623e0d 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -99,6 +99,9 @@ WriteMakefile1( INC => '-I.', # e.g., '-I. -I/usr/include/other' OPTIMIZE => $OPTIMIZE, OBJECT => '$(O_FILES)', + test => { + RECURSIVE_TEST_FILES => 1 + }, ); $ENV{OPTIMIZE} = $OPTIMIZE; diff --git a/lib/Sereal/Encoder.pm b/lib/Sereal/Encoder.pm index 1874463..fcdf786 100644 --- a/lib/Sereal/Encoder.pm +++ b/lib/Sereal/Encoder.pm @@ -5,7 +5,7 @@ use warnings; use Carp qw/croak/; use XSLoader; -our $VERSION = '3.001_003'; # Don't forget to update the TestCompat set for testing against installed decoders! +our $VERSION = '3.001_004'; # Don't forget to update the TestCompat set for testing against installed decoders! our $XS_VERSION = $VERSION; $VERSION= eval $VERSION; # not for public consumption, just for testing. diff --git a/srl_common.h b/srl_common.h index 6ef6911..b50199a 100644 --- a/srl_common.h +++ b/srl_common.h @@ -15,20 +15,50 @@ /* these defines are somewhat borrowed from miniz.c */ -#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__) -// SRL_X86_OR_X64_CPU is only used to help set the below macros. -#define SRL_X86_OR_X64_CPU 1 +#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__) || defined(__x86_64) +/* SRL_X86_OR_X64_CPU is only used to help set the below macros. */ +#define SRL_X86_OR_X64_CPU #endif -#if SRL_X86_OR_X64_CPU && !defined(SRL_USE_ALIGNED_LOADS_AND_STORES) -// Set SRL_USE_ALIGNED_LOADS_AND_STORES to 0 on CPU's that permit efficient integer loads and stores from unaligned addresses. -#define SRL_USE_ALIGNED_LOADS_AND_STORES 0 -#endif +#ifndef SRL_USE_ALIGNED_LOADS_AND_STORES -/* HP-UX runs on Itanium but has strict alignment. */ #ifdef __hpux -#undef SRL_USE_ALIGNED_LOADS_AND_STORES +/* HP-UX runs on Itanium but has strict alignment so we check it first. */ +#define SRL_USE_ALIGNED_LOADS_AND_STORES 1 +#elif defined(SRL_X86_OR_X64_CPU) +/* Set SRL_USE_ALIGNED_LOADS_AND_STORES to 0 on CPU's that permit efficient integer loads and stores from unaligned addresses. */ +#define SRL_USE_ALIGNED_LOADS_AND_STORES 0 +#else +/* When in doubt use aligned loads and stores */ #define SRL_USE_ALIGNED_LOADS_AND_STORES 1 #endif #endif + + +/* In x86 one can try to enforce strict alignment in runtime. + * + * Setting the CPU flag bit 18 (called "AC", aligment check) in + * the "EFLAGS" (user-settable) causes unaligned access traps but + * only iff the system register CR0 (only system-settable, usually done + * (or not) during kernel boot) has the same bit set (there called "AM", + * alignment mask). If both flags are not set, the strict alignment + * traps (silently) do not happen. + * + * The Linux kernel and the Solarix x86 set the "AM". The Windows and + * OX X do not. The *BSD behavior is unknown, though suspecting they do. + * + * http://en.wikipedia.org/wiki/Control_register + * http://en.wikipedia.org/wiki/FLAGS_register_(computing) + */ +#ifdef SRL_X86_OR_X64_CPU +# if __x86_64__ || __x86_64 +# define SRL_TRY_ENABLE_STRICT_ALIGN() asm("pushf\norl $0x40000, (%rsp)\npopf") +# elif __i386__ || __i386 +# define SRL_TRY_ENABLE_STRICT_ALIGN() asm("pushf\norl $0x40000, (%esp)\npopf") +# endif +#else +# define SRL_TRY_ENABLE_STRICT_ALIGN() (void)0 +#endif + +#endif diff --git a/t/700_roundtrip.t b/t/700_roundtrip.t deleted file mode 100644 index 6c8b03e..0000000 --- a/t/700_roundtrip.t +++ /dev/null @@ -1,38 +0,0 @@ -#!perl -use strict; -use warnings; -use Sereal::Encoder; -use Data::Dumper; -use File::Spec; - -# These tests use an installed Decoder (or respectively Encoder) to do -# round-trip testing. There are two strategies, both with drawbacks: -# - Test::More's is_deeply is waaaay too lenient to catch all the -# subtleties that Sereal is supposed to encode. -# - Serialize - Deserialize - Serialize, then do a string compare. -# This won't catch if the first serialization has bogus output -# but the subsequent de- & serialization work for the already -# bogus output. -# These tests can't replace carefully crafted manual tests, I fear. - -use lib File::Spec->catdir(qw(t lib)); -BEGIN { - lib->import('lib') - if !-d 't'; -} - -use Sereal::TestSet qw(:all); -use Test::More; - -my $ok = have_encoder_and_decoder(); -if (not $ok) { - plan skip_all => 'Did not find right version of decoder'; -} -else { - run_roundtrip_tests(3); # 3 is "run for proto version 3 only" -} - - -pass(); -done_testing(); - diff --git a/t/700_roundtrip/v1/plain.t b/t/700_roundtrip/v1/plain.t new file mode 100644 index 0000000..282424e --- /dev/null +++ b/t/700_roundtrip/v1/plain.t @@ -0,0 +1,39 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $version; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests("plain"); +} + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v1/snappy.t b/t/700_roundtrip/v1/snappy.t new file mode 100644 index 0000000..5e8beb9 --- /dev/null +++ b/t/700_roundtrip/v1/snappy.t @@ -0,0 +1,38 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests('snappy', { snappy => 1 } ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v2/dedudep_strings.t b/t/700_roundtrip/v2/dedudep_strings.t new file mode 100644 index 0000000..83ebd4c --- /dev/null +++ b/t/700_roundtrip/v2/dedudep_strings.t @@ -0,0 +1,40 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'dedupe_strings', { dedupe_strings => 1 } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v2/freeze_thaw.t b/t/700_roundtrip/v2/freeze_thaw.t new file mode 100644 index 0000000..e41cb9e --- /dev/null +++ b/t/700_roundtrip/v2/freeze_thaw.t @@ -0,0 +1,40 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'freeze-thaw', { freeze_callbacks => 1 } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v2/plain.t b/t/700_roundtrip/v2/plain.t new file mode 100644 index 0000000..282424e --- /dev/null +++ b/t/700_roundtrip/v2/plain.t @@ -0,0 +1,39 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $version; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests("plain"); +} + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v2/readonly.t b/t/700_roundtrip/v2/readonly.t new file mode 100644 index 0000000..4f0b1d6 --- /dev/null +++ b/t/700_roundtrip/v2/readonly.t @@ -0,0 +1,40 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'readonly', { set_readonly => 1 } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v2/snappy.t b/t/700_roundtrip/v2/snappy.t new file mode 100644 index 0000000..5e8beb9 --- /dev/null +++ b/t/700_roundtrip/v2/snappy.t @@ -0,0 +1,38 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests('snappy', { snappy => 1 } ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v2/snappy_incr.t b/t/700_roundtrip/v2/snappy_incr.t new file mode 100644 index 0000000..9dfb91f --- /dev/null +++ b/t/700_roundtrip/v2/snappy_incr.t @@ -0,0 +1,40 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'snappy_incr', { snappy_incr => 1 } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v2/sort_keys.t b/t/700_roundtrip/v2/sort_keys.t new file mode 100644 index 0000000..57aa81b --- /dev/null +++ b/t/700_roundtrip/v2/sort_keys.t @@ -0,0 +1,40 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'sort_keys', { sort_keys => 1 } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v3/dedudep_strings.t b/t/700_roundtrip/v3/dedudep_strings.t new file mode 100644 index 0000000..83ebd4c --- /dev/null +++ b/t/700_roundtrip/v3/dedudep_strings.t @@ -0,0 +1,40 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'dedupe_strings', { dedupe_strings => 1 } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v3/freeze_thaw.t b/t/700_roundtrip/v3/freeze_thaw.t new file mode 100644 index 0000000..e41cb9e --- /dev/null +++ b/t/700_roundtrip/v3/freeze_thaw.t @@ -0,0 +1,40 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'freeze-thaw', { freeze_callbacks => 1 } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v3/plain.t b/t/700_roundtrip/v3/plain.t new file mode 100644 index 0000000..282424e --- /dev/null +++ b/t/700_roundtrip/v3/plain.t @@ -0,0 +1,39 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $version; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests("plain"); +} + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v3/readonly.t b/t/700_roundtrip/v3/readonly.t new file mode 100644 index 0000000..4f0b1d6 --- /dev/null +++ b/t/700_roundtrip/v3/readonly.t @@ -0,0 +1,40 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'readonly', { set_readonly => 1 } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v3/snappy.t b/t/700_roundtrip/v3/snappy.t new file mode 100644 index 0000000..5e8beb9 --- /dev/null +++ b/t/700_roundtrip/v3/snappy.t @@ -0,0 +1,38 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests('snappy', { snappy => 1 } ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v3/snappy_incr.t b/t/700_roundtrip/v3/snappy_incr.t new file mode 100644 index 0000000..9dfb91f --- /dev/null +++ b/t/700_roundtrip/v3/snappy_incr.t @@ -0,0 +1,40 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'snappy_incr', { snappy_incr => 1 } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v3/sort_keys.t b/t/700_roundtrip/v3/sort_keys.t new file mode 100644 index 0000000..57aa81b --- /dev/null +++ b/t/700_roundtrip/v3/sort_keys.t @@ -0,0 +1,40 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'sort_keys', { sort_keys => 1 } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v3/zlib.t b/t/700_roundtrip/v3/zlib.t new file mode 100644 index 0000000..6dffeb7 --- /dev/null +++ b/t/700_roundtrip/v3/zlib.t @@ -0,0 +1,43 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'zlib', + { + compress => Sereal::Encoder::SRL_ZLIB(), + } + ); +} + + +pass(); +done_testing(); + diff --git a/t/700_roundtrip/v3/zlib_force.t b/t/700_roundtrip/v3/zlib_force.t new file mode 100644 index 0000000..6556aa8 --- /dev/null +++ b/t/700_roundtrip/v3/zlib_force.t @@ -0,0 +1,44 @@ +#!perl +use strict; +use warnings; +use Sereal::Decoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of encoder'; +} +else { + run_roundtrip_tests( + 'zlib_force', + { + compress => Sereal::Encoder::SRL_ZLIB(), + compress_threshold => 0, + } + ); +} + + +pass(); +done_testing(); + diff --git a/t/701_roundtrip_v1.t b/t/701_roundtrip_v1.t deleted file mode 100644 index 3c065f1..0000000 --- a/t/701_roundtrip_v1.t +++ /dev/null @@ -1,38 +0,0 @@ -#!perl -use strict; -use warnings; -use Sereal::Encoder; -use Data::Dumper; -use File::Spec; - -# These tests use an installed Decoder (or respectively Encoder) to do -# round-trip testing. There are two strategies, both with drawbacks: -# - Test::More's is_deeply is waaaay too lenient to catch all the -# subtleties that Sereal is supposed to encode. -# - Serialize - Deserialize - Serialize, then do a string compare. -# This won't catch if the first serialization has bogus output -# but the subsequent de- & serialization work for the already -# bogus output. -# These tests can't replace carefully crafted manual tests, I fear. - -use lib File::Spec->catdir(qw(t lib)); -BEGIN { - lib->import('lib') - if !-d 't'; -} - -use Sereal::TestSet qw(:all); -use Test::More; - -my $ok = have_encoder_and_decoder(); -if (not $ok) { - plan skip_all => 'Did not find right version of decoder'; -} -else { - run_roundtrip_tests(1); # 1 is "run for proto-version 1 only" -} - - -pass(); -done_testing(); - diff --git a/t/702_roundtrip_v2.t b/t/702_roundtrip_v2.t deleted file mode 100644 index ca864a4..0000000 --- a/t/702_roundtrip_v2.t +++ /dev/null @@ -1,38 +0,0 @@ -#!perl -use strict; -use warnings; -use Sereal::Encoder; -use Data::Dumper; -use File::Spec; - -# These tests use an installed Decoder (or respectively Encoder) to do -# round-trip testing. There are two strategies, both with drawbacks: -# - Test::More's is_deeply is waaaay too lenient to catch all the -# subtleties that Sereal is supposed to encode. -# - Serialize - Deserialize - Serialize, then do a string compare. -# This won't catch if the first serialization has bogus output -# but the subsequent de- & serialization work for the already -# bogus output. -# These tests can't replace carefully crafted manual tests, I fear. - -use lib File::Spec->catdir(qw(t lib)); -BEGIN { - lib->import('lib') - if !-d 't'; -} - -use Sereal::TestSet qw(:all); -use Test::More; - -my $ok = have_encoder_and_decoder(); -if (not $ok) { - plan skip_all => 'Did not find right version of decoder'; -} -else { - run_roundtrip_tests(2); # 2 is "run for proto-version 2 only" -} - - -pass(); -done_testing(); - diff --git a/t/lib/Sereal/TestSet.pm b/t/lib/Sereal/TestSet.pm index 2608baf..1c53ec3 100644 --- a/t/lib/Sereal/TestSet.pm +++ b/t/lib/Sereal/TestSet.pm @@ -176,13 +176,17 @@ sub offseti { } sub debug_checks { - my ($data_ref, $encoded_ref, $decoded_ref) = @_; - if (defined $ENV{DEBUG_SEREAL}) { - note("Original data was: " . Data::Dumper::Dumper($$data_ref)) if defined $data_ref; - note("Encoded data is: " . (defined($$encoded_ref) ? $$encoded_ref : "")) if defined $encoded_ref; - note("Decoded data was: " . Data::Dumper::Dumper($$decoded_ref)) if defined $decoded_ref; + my ($data_ref, $encoded_ref, $decoded_ref, $debug) = @_; + if ($debug or defined $ENV{DEBUG_SEREAL}) { + note("Original data was: " . Data::Dumper::Dumper($$data_ref)) + if defined $data_ref; + note("Encoded data is: " . (defined($$encoded_ref) ? Data::Dumper::qquote($$encoded_ref) : "")) + if defined $encoded_ref; + note("Decoded data was: " . Data::Dumper::Dumper($$decoded_ref)) + if defined $decoded_ref; } if (defined $ENV{DEBUG_DUMP}) { + Dump($$data_ref) if defined $data_ref; Dump($$encoded_ref) if defined $encoded_ref; Dump($$decoded_ref) if defined $decoded_ref; } @@ -702,44 +706,25 @@ if (eval "use Array::RefElem (av_store hv_store); 1") { sub run_roundtrip_tests { - my ($proto_version) = @_; - my @proto_versions = ($proto_version ? ($proto_version) : (1 .. +SRL_PROTOCOL_VERSION)); - - for my $proto_version ($proto_version) { - my $suffix = "_v$proto_version"; - - # name, options, min proto version, max proto version - my @variants = ( - ['plain', { } ], - ['snappy', { snappy => 1 } ], - ['snappy_incr', { snappy_incr => 1 }, 2 ], - ['zlib', { compress => Sereal::Encoder::SRL_ZLIB() }, 3 ], - ['zlib_force', { compress => Sereal::Encoder::SRL_ZLIB(), compress_threshold => 0 }, 3 ], - ['sort_keys', { sort_keys => 1 }, 2 ], - ['dedupe_strings', { dedupe_strings => 1 }, 2 ], - ['freeze/thaw', { freeze_callbacks => 1 }, 2 ], - ['readonly', { set_readonly => 1 }, 2 ], - ); - for my $opt (@variants) { - my ($name, $opts, $min_proto_v, $max_proto_v) = @$opt; - $name .= $suffix; - next if ($min_proto_v && $proto_version < $min_proto_v) - or ($max_proto_v && $proto_version > $max_proto_v); - - if ($proto_version) { - if ($proto_version == 1) { - $opts->{use_protocol_v1} = 1; - } - else { - # v2 ignores this, but will output v2 by default - $opts->{protocol_version} = $proto_version; - } - } - $PROTO_VERSION= $proto_version; - setup_tests(); - run_roundtrip_tests_internal($name, $opts); - } + my ($name, $opts) = @_; + + my $proto_version; + if ( $0 =~ m![\\/]v(\d+)[\\/]!) { + $proto_version= $1; + } else { + die "Failed to detect version\n"; + } + + my $suffix = "_v$proto_version"; + if ($proto_version == 1) { + $opts->{use_protocol_v1} = 1; + } + else { + # v2 ignores this, but will output v2 by default + $opts->{protocol_version} = $proto_version; } + setup_tests($proto_version); + run_roundtrip_tests_internal($name . $suffix, $opts); } sub run_roundtrip_tests_internal { @@ -818,15 +803,15 @@ sub run_roundtrip_tests_internal { or next; is_deeply($decoded, $data, "$name ($ename, $mname, decoded vs data)") or do { - debug_checks(\$data, \$encoded2, \$decoded2); + debug_checks(\$data, undef, \$decoded, "debug"); }; is_deeply($decoded2, $data, "$name ($ename, $mname, decoded2 vs data)") or do { - debug_checks(\$data, \$encoded2, \$decoded2); + debug_checks(\$data, undef, \$decoded2, "debug"); }; - is_deeply($decoded, $decoded2, "$name ($ename, $mname, decoded vs decoded2)") + is_deeply($decoded2, $decoded, "$name ($ename, $mname, decoded vs decoded2)") or do { - debug_checks(\$data, \$encoded2, \$decoded2); + debug_checks(\$decoded, undef, \$decoded2, "debug"); }; if (0) {