* 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
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
"url" : "git://github.com/Sereal/Sereal.git"
}
},
- "version" : "3.001_003"
+ "version" : "3.001_004"
}
resources:
bugtracker: https://github.com/Sereal/Sereal/issues
repository: git://github.com/Sereal/Sereal.git
-version: 3.001_003
+version: 3.001_004
INC => '-I.', # e.g., '-I. -I/usr/include/other'
OPTIMIZE => $OPTIMIZE,
OBJECT => '$(O_FILES)',
+ test => {
+ RECURSIVE_TEST_FILES => 1
+ },
);
$ENV{OPTIMIZE} = $OPTIMIZE;
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.
/* 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
+++ /dev/null
-#!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();
-
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
--- /dev/null
+#!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();
+
+++ /dev/null
-#!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();
-
+++ /dev/null
-#!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();
-
}
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 : "<undef>")) 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) : "<undef>"))
+ 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;
}
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 {
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) {