From 245acbfc16252b701424fcb206a998cdcf8c780b Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 20 Nov 2024 14:42:30 -0800 Subject: [PATCH] Make fuzz test check round-trip correctness of upb encoder/decoder. Prior to this CL, the fuzz tests only checked that the code does not crash, but it was not checking any correctness properties. This CL adds correctness checking, verifying that we can round trip through the wire format without losing or corrupting data. This highlighted a minor bug in the encoder where the depth limit check was off by one (too strict). This CL makes the encoder more accepting when checking the depth limit. PiperOrigin-RevId: 698527429 --- upb/message/BUILD | 1 + upb/message/test.cc | 3 +++ 2 files changed, 4 insertions(+) diff --git a/upb/message/BUILD b/upb/message/BUILD index d7b83a10c6..0089596af5 100644 --- a/upb/message/BUILD +++ b/upb/message/BUILD @@ -381,6 +381,7 @@ cc_test( "//upb:eps_copy_input_stream", "//upb:json", "//upb:mem", + "//upb:message_compare", "//upb:mini_table", "//upb:reflection", "//upb:wire", diff --git a/upb/message/test.cc b/upb/message/test.cc index 7ee644248a..041a82d374 100644 --- a/upb/message/test.cc +++ b/upb/message/test.cc @@ -7,8 +7,10 @@ #include #include +#include #include #include +#include #include #include @@ -22,6 +24,7 @@ #include "upb/mem/arena.h" #include "upb/mem/arena.hpp" #include "upb/message/array.h" +#include "upb/message/compare.h" #include "upb/message/map.h" #include "upb/message/message.h" #include "upb/message/test.upb.h"