|
|
|
@ -53,17 +53,6 @@ |
|
|
|
|
#define PRINT_FAILURE(expr) \ |
|
|
|
|
fprintf(stderr, "Assertion failed: %s:%d\n", __FILE__, __LINE__); \
|
|
|
|
|
fprintf(stderr, "expr: %s\n", #expr); \
|
|
|
|
|
if (testhash) { \
|
|
|
|
|
fprintf(stderr, "assertion failed running test %x.\n", testhash); \
|
|
|
|
|
if (!filter_hash) { \
|
|
|
|
|
fprintf(stderr, \
|
|
|
|
|
"Run with the arg %x to run only this test. " \
|
|
|
|
|
"(This will also turn on extra debugging output)\n", \
|
|
|
|
|
testhash); \
|
|
|
|
|
} \
|
|
|
|
|
fprintf(stderr, "Failed at %02.2f%% through tests.\n", \
|
|
|
|
|
(float)completed * 100 / total); \
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#define MAX_NESTING 64 |
|
|
|
|
|
|
|
|
@ -445,17 +434,6 @@ upb::pb::DecoderPtr CreateDecoder(upb::Arena* arena, |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint32_t Hash(const string& proto, const string* expected_output, size_t seam1, |
|
|
|
|
size_t seam2, bool may_skip) { |
|
|
|
|
uint32_t hash = upb_murmur_hash2(proto.c_str(), proto.size(), 0); |
|
|
|
|
if (expected_output) |
|
|
|
|
hash = upb_murmur_hash2(expected_output->c_str(), expected_output->size(), hash); |
|
|
|
|
hash = upb_murmur_hash2(&seam1, sizeof(seam1), hash); |
|
|
|
|
hash = upb_murmur_hash2(&seam2, sizeof(seam2), hash); |
|
|
|
|
hash = upb_murmur_hash2(&may_skip, sizeof(may_skip), hash); |
|
|
|
|
return hash; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CheckBytesParsed(upb::pb::DecoderPtr decoder, size_t ofs) { |
|
|
|
|
// We can't have parsed more data than the decoder callback is telling us it
|
|
|
|
|
// parsed.
|
|
|
|
@ -484,13 +462,11 @@ void do_run_decoder(VerboseParserEnvironment* env, upb::pb::DecoderPtr decoder, |
|
|
|
|
env->Reset(proto.c_str(), proto.size(), may_skip, expected_output == NULL); |
|
|
|
|
decoder.Reset(); |
|
|
|
|
|
|
|
|
|
testhash = Hash(proto, expected_output, i, j, may_skip); |
|
|
|
|
if (filter_hash && testhash != filter_hash) return; |
|
|
|
|
if (test_mode != COUNT_ONLY) { |
|
|
|
|
output.clear(); |
|
|
|
|
|
|
|
|
|
if (filter_hash) { |
|
|
|
|
fprintf(stderr, "RUNNING TEST CASE, hash=%x\n", testhash); |
|
|
|
|
fprintf(stderr, "RUNNING TEST CASE\n"); |
|
|
|
|
fprintf(stderr, "Input (len=%u): ", (unsigned)proto.size()); |
|
|
|
|
PrintBinary(proto); |
|
|
|
|
fprintf(stderr, "\n"); |
|
|
|
@ -549,7 +525,6 @@ void run_decoder(const string& proto, const string* expected_output) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
testhash = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const static string thirty_byte_nop = cat( |
|
|
|
@ -849,23 +824,17 @@ void test_valid() { |
|
|
|
|
// Empty protobuf where we never call PutString between
|
|
|
|
|
// StartString/EndString.
|
|
|
|
|
|
|
|
|
|
// Randomly generated hash for this test, hope it doesn't conflict with others
|
|
|
|
|
// by chance.
|
|
|
|
|
const uint32_t emptyhash = 0x5709be8e; |
|
|
|
|
if (!filter_hash || filter_hash == testhash) { |
|
|
|
|
testhash = emptyhash; |
|
|
|
|
upb::Status status; |
|
|
|
|
upb::Arena arena; |
|
|
|
|
upb::Sink sink(global_handlers, &closures[0]); |
|
|
|
|
upb::pb::DecoderPtr decoder = |
|
|
|
|
CreateDecoder(&arena, global_method, sink, &status); |
|
|
|
|
output.clear(); |
|
|
|
|
bool ok = upb::PutBuffer(std::string(), decoder.input()); |
|
|
|
|
ASSERT(ok); |
|
|
|
|
ASSERT(status.ok()); |
|
|
|
|
if (test_mode == ALL_HANDLERS) { |
|
|
|
|
ASSERT(output == string("<\n>\n")); |
|
|
|
|
} |
|
|
|
|
upb::Status status; |
|
|
|
|
upb::Arena arena; |
|
|
|
|
upb::Sink sink(global_handlers, &closures[0]); |
|
|
|
|
upb::pb::DecoderPtr decoder = |
|
|
|
|
CreateDecoder(&arena, global_method, sink, &status); |
|
|
|
|
output.clear(); |
|
|
|
|
bool ok = upb::PutBuffer(std::string(), decoder.input()); |
|
|
|
|
ASSERT(ok); |
|
|
|
|
ASSERT(status.ok()); |
|
|
|
|
if (test_mode == ALL_HANDLERS) { |
|
|
|
|
ASSERT(output == string("<\n>\n")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
test_valid_data_for_signed_type(UPB_DESCRIPTOR_TYPE_DOUBLE, |
|
|
|
|