]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/encoding/check-generated: test sorted json dumps for nondeterministic objects 5576/head
authorSage Weil <sage@redhat.com>
Thu, 13 Aug 2015 18:49:40 +0000 (14:49 -0400)
committerSage Weil <sage@redhat.com>
Thu, 13 Aug 2015 18:49:40 +0000 (14:49 -0400)
Nondeterministic objects dump nondeterministically (usually due
to unordered_map or _set).  Compare their sorted output.  This
is a weaker test but is better than nothing.

Signed-off-by: Sage Weil <sage@redhat.com>
src/test/encoding/check-generated.sh

index f539b2bcb8380c668231e5c48d19174572613b52..7c33e54306488b2a6ea02c759d40620f41682d77 100755 (executable)
@@ -29,6 +29,18 @@ for type in `./ceph-dencoder list_types`; do
        ./ceph-dencoder type $type select_test $n copy dump_json > $tmp3
        ./ceph-dencoder type $type select_test $n copy_ctor dump_json > $tmp4
 
+       # nondeterministic classes may dump nondeterministically.  compare
+       # the sorted json output.  this is a weaker test, but is better
+       # than nothing.
+       if ! ./ceph-dencoder type $type is_deterministic
+       then
+           echo "  sorting json output for nondeterministic object"
+           for f in $tmp1 $tmp2 $tmp3 $tmp4; do
+               sort $f | sed 's/,$//' > $f.new
+               mv $f.new $f
+           done
+       fi
+
        if ! cmp $tmp1 $tmp2; then
            echo "**** $type test $n dump_json check failed ****"
            echo "   ./ceph-dencoder type $type select_test $n dump_json > $tmp1"