Imported Upstream version 3.001.004
authorgregor herrmann <gregoa@debian.org>
Sun, 27 Jul 2014 20:24:16 +0000 (22:24 +0200)
committergregor herrmann <gregoa@debian.org>
Sun, 27 Jul 2014 20:24:16 +0000 (22:24 +0200)
29 files changed:
Changes
MANIFEST
META.json
META.yml
Makefile.PL
lib/Sereal/Encoder.pm
srl_common.h
t/700_roundtrip.t [deleted file]
t/700_roundtrip/v1/plain.t [new file with mode: 0644]
t/700_roundtrip/v1/snappy.t [new file with mode: 0644]
t/700_roundtrip/v2/dedudep_strings.t [new file with mode: 0644]
t/700_roundtrip/v2/freeze_thaw.t [new file with mode: 0644]
t/700_roundtrip/v2/plain.t [new file with mode: 0644]
t/700_roundtrip/v2/readonly.t [new file with mode: 0644]
t/700_roundtrip/v2/snappy.t [new file with mode: 0644]
t/700_roundtrip/v2/snappy_incr.t [new file with mode: 0644]
t/700_roundtrip/v2/sort_keys.t [new file with mode: 0644]
t/700_roundtrip/v3/dedudep_strings.t [new file with mode: 0644]
t/700_roundtrip/v3/freeze_thaw.t [new file with mode: 0644]
t/700_roundtrip/v3/plain.t [new file with mode: 0644]
t/700_roundtrip/v3/readonly.t [new file with mode: 0644]
t/700_roundtrip/v3/snappy.t [new file with mode: 0644]
t/700_roundtrip/v3/snappy_incr.t [new file with mode: 0644]
t/700_roundtrip/v3/sort_keys.t [new file with mode: 0644]
t/700_roundtrip/v3/zlib.t [new file with mode: 0644]
t/700_roundtrip/v3/zlib_force.t [new file with mode: 0644]
t/701_roundtrip_v1.t [deleted file]
t/702_roundtrip_v2.t [deleted file]
t/lib/Sereal/TestSet.pm

diff --git a/Changes b/Changes
index c55ae4a164093fe63215b2194b7a7160f19eff53..fca4f6e554584cd95c0bec9d5025b18782057288 100644 (file)
--- 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
index 4d9fcb8c709ca1fb1fe8270d6e1c6bb24eb03575..e7b1b3a883de4869914c7bcd63628c52f2ebb6db 100644 (file)
--- 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
index c40b1231c061cc6802dff8f1d23e6a70317e8f3d..73ec5f691e33e80b9b5eb69df7f79c51766d5e4d 100644 (file)
--- 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"
 }
index 7923d7e3991e517d7652d1ae35d6639b92a935ab..c70f07d7ceb39d935646ff078a3bd5d462937405 100644 (file)
--- 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
index 6e5d193c990f2468f36dba51af6016dbbe27bab7..0623e0d18a2bfe689f1e88d712ced1ee578c6cb4 100644 (file)
@@ -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;
 
index 1874463ecc39ca740d7696735aedb695fdced20b..fcdf786ea6aa85e761fc978405866f27dd5c5f7b 100644 (file)
@@ -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.
index 6ef6911af686931898a96f07e43520807231072e..b50199a330026568adbe1d3a2f3f323914ffad63 100644 (file)
 
 /* 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 (file)
index 6c8b03e..0000000
+++ /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 (file)
index 0000000..282424e
--- /dev/null
@@ -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 (file)
index 0000000..5e8beb9
--- /dev/null
@@ -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 (file)
index 0000000..83ebd4c
--- /dev/null
@@ -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 (file)
index 0000000..e41cb9e
--- /dev/null
@@ -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 (file)
index 0000000..282424e
--- /dev/null
@@ -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 (file)
index 0000000..4f0b1d6
--- /dev/null
@@ -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 (file)
index 0000000..5e8beb9
--- /dev/null
@@ -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 (file)
index 0000000..9dfb91f
--- /dev/null
@@ -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 (file)
index 0000000..57aa81b
--- /dev/null
@@ -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 (file)
index 0000000..83ebd4c
--- /dev/null
@@ -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 (file)
index 0000000..e41cb9e
--- /dev/null
@@ -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 (file)
index 0000000..282424e
--- /dev/null
@@ -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 (file)
index 0000000..4f0b1d6
--- /dev/null
@@ -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 (file)
index 0000000..5e8beb9
--- /dev/null
@@ -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 (file)
index 0000000..9dfb91f
--- /dev/null
@@ -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 (file)
index 0000000..57aa81b
--- /dev/null
@@ -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 (file)
index 0000000..6dffeb7
--- /dev/null
@@ -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 (file)
index 0000000..6556aa8
--- /dev/null
@@ -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 (file)
index 3c065f1..0000000
+++ /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 (file)
index ca864a4..0000000
+++ /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();
-
index 2608baffbff5528293d29e352a1e44e4ee56eeb1..1c53ec39d8ed63af03b83f3e2ee1b6012d24d3a8 100644 (file)
@@ -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 : "<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;
     }
@@ -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) {