@ -38,10 +38,6 @@
# include "upb/wire/decode.h"
# include "upb/wire/encode.h"
// begin:google_only
// #include "testing/fuzzing/fuzztest.h"
// end:google_only
void VerifyMessage ( const upb_test_TestExtensions * ext_msg ) {
EXPECT_TRUE ( upb_test_TestExtensions_has_optional_int32_ext ( ext_msg ) ) ;
// EXPECT_FALSE(upb_test_TestExtensions_Nested_has_optional_int32_ext(ext_msg));
@ -583,196 +579,3 @@ TEST(MessageTest, Freeze) {
ASSERT_TRUE ( upb_Message_IsFrozen ( UPB_UPCAST ( nest ) ) ) ;
}
}
// begin:google_only
//
// static void DecodeEncodeArbitrarySchemaAndPayload(
// const upb::fuzz::MiniTableFuzzInput& input, std::string_view proto_payload,
// int decode_options, int encode_options, bool length_prefixed = false) {
// // Lexan does not have setenv
// #ifndef _MSC_VER
// setenv("FUZZTEST_STACK_LIMIT", "262144", 1);
// #endif
// // The value of 80 used here is empirical and intended to roughly represent
// // the tiny 64K stack size used by the test framework. We still see the
// // occasional stack overflow at 90, so far 80 has worked 100% of the time.
// decode_options = upb_Decode_LimitDepth(decode_options, 80);
// encode_options = upb_Encode_LimitDepth(encode_options, 80);
//
// upb::Arena arena;
// upb_ExtensionRegistry* exts;
// const upb_MiniTable* mini_table =
// upb::fuzz::BuildMiniTable(input, &exts, arena.ptr());
// if (!mini_table) return;
// upb_Message* msg = upb_Message_New(mini_table, arena.ptr());
// if (length_prefixed) {
// size_t num_bytes_read = 0;
// upb_DecodeStatus status = upb_DecodeLengthPrefixed(
// proto_payload.data(), proto_payload.size(), msg, &num_bytes_read,
// mini_table, exts, decode_options, arena.ptr());
// ASSERT_TRUE(status != kUpb_DecodeStatus_Ok ||
// num_bytes_read <= proto_payload.size());
// } else {
// upb_Decode(proto_payload.data(), proto_payload.size(), msg, mini_table,
// exts, decode_options, arena.ptr());
// }
// char* ptr;
// size_t size;
// if (length_prefixed) {
// upb_EncodeLengthPrefixed(msg, mini_table, encode_options, arena.ptr(), &ptr,
// &size);
// } else {
// upb_Encode(msg, mini_table, encode_options, arena.ptr(), &ptr, &size);
// }
// }
// FUZZ_TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayload);
//
// TEST(FuzzTest, DecodeUnknownProto2EnumExtension) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\256\354Rt\216\3271\234", "\243\243\267\207\336gV\366w"},
// {"z"},
// "}\212\304d\371\363\341\2329\325B\264\377?\215\223\201\201\226y\201%"
// "\321\363\255;",
// {}},
// "\010", -724543908, -591643538);
// }
//
// TEST(FuzzTest, DecodeExtensionEnsurePresenceInitialized) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\031", "S", "\364", "", "", "j", "\303", "", "\224", "\277"},
// {},
// "_C-\236$*)C0C>",
// {4041515984, 2147483647, 1929379871, 0, 3715937258, 4294967295}},
// "\010\002", 342248070, -806315555);
// }
//
// TEST(FuzzTest, DecodeExtendMessageSetWithNonMessage) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\n"}, {""}, ".\244", {}}, "\013\032\005\212a#\365\336\020\001\226",
// 14803219, 670718349);
// }
//
// TEST(FuzzTest, DecodeExtendMessageSetWithNonMessage2) {
// DecodeEncodeArbitrarySchemaAndPayload({{"\n", "G", "\n", "\274", ""},
// {"", "\030"},
// "_@",
// {4294967295, 2147483647}},
// std::string("\013\032\000\220", 4),
// 279975758, 1647495141);
// }
//
// TEST(FuzzTest, DecodeExtendMessageSetWithNonMessage3) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\n"}, {"B", ""}, "\212:b", {11141121}},
// "\013\032\004\357;7\363\020\001\346\240\200\201\271", 399842149,
// -452966025);
// }
//
// TEST(FuzzTest, DecodeExtendMessageSetWithNonMessage4) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\n", "3\340", "\354"}, {}, "B}G", {4294967295, 4082331310}},
// "\013\032\004\244B\331\255\020\001\220\224\243\350\t", -561523015,
// 1683327312);
// }
//
// TEST(FuzzTest, DecodeExtendMessageSetWithNonMessage5) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\n"}, {""}, "kB", {0}},
// "x\203\251\006\013\032\002S\376\010\273\'\020\014\365\207\244\234",
// -696925610, -654590577);
// }
//
// TEST(FuzzTest, ExtendMessageSetWithEmptyExtension) {
// DecodeEncodeArbitrarySchemaAndPayload({{"\n"}, {}, "_", {}}, std::string(), 0,
// 0);
// }
//
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegression) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\320", "\320", "\320", "\320", "\320", "%2%%%%%"},
// {"", "", "", "", "", "", "", "", "", "", "", "",
// "", "", "", "", "", "", "", "", "", "", ""},
// "\226\226\226\226\226\226\350\351\350\350\350\350\350\350\350\314",
// {4026531839}},
// std::string("\n\n\n\n\272\n======@@%%%%%%%%%%%%%%%@@@(("
// "qqqqqqqq5555555555qqqqqffq((((((((((((\335@@>"
// "\ru\360ncppppxxxxxxxxx\025\025\025xxxxxppppppp<="
// "\2165\275\275\315\217\361\010\t\000\016\013in\n\n\n\256\263",
// 130),
// 901979906, 65537);
// }
//
// // This test encodes a map field with extra cruft.
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegressionInvalidMap) {
// DecodeEncodeArbitrarySchemaAndPayload({{"%%%%///////"}, {}, "", {}},
// std::string("\035|", 2), 65536, 3);
// }
//
// // This test found a case where presence was unset for a mini table field.
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegressionMsan) {
// DecodeEncodeArbitrarySchemaAndPayload({{"%-#^#"}, {}, "", {}}, std::string(),
// -1960166338, 16809991);
// }
//
// // This test encodes a map containing a msg wrapping another, empty msg.
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegressionMapMap) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"%#G"}, {}, "", {}}, std::string("\022\002\022\000", 4), 0, 0);
// }
//
// TEST(FuzzTest, GroupMap) {
// // Groups should not be allowed as maps, but we previously failed to prevent
// // this.
// DecodeEncodeArbitrarySchemaAndPayload(
// {.mini_descriptors = {"$$FF$", "%-C"},
// .enum_mini_descriptors = {},
// .extensions = "",
// .links = {1}},
// std::string(
// "\023\020\030\233\000\204\330\372#\000`"
// "a\000\000\001\000\000\000ccccccc\030s\273sssssssss\030\030\030\030"
// "\030\030\030\030\215\215\215\215\215\215\215\215\030\030\232\253\253"
// "\232*\334\227\273\231\207\373\t\0051\305\265\335\224\226"),
// 0, 0);
// }
//
// TEST(FuzzTest, MapUnknownFieldSpanBuffers) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"$ 3", "%# "}, {}, "", {1}},
// std::string(
// "\"\002\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000",
// 17),
// 0, 0);
// }
//
// // Another test for mismatched submsg types.
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegression22) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"$2222222222222222222222", "%,&"}, {}, "", {1}},
// std::string("\035\170\170\170\051\263\001\030\000\035\357\357\340\021\035"
// "\025\331\035\035\035\035\035\035\035\035",
// 25),
// 0, 0);
// }
//
// TEST(FuzzTest, ExtensionWithoutExt) {
// DecodeEncodeArbitrarySchemaAndPayload({{"$ 3", "", "%#F"}, {}, "", {2, 1}},
// std::string("\022\002\010\000", 4), 0,
// 0);
// }
//
// TEST(FuzzTest, MapFieldVerify) {
// DecodeEncodeArbitrarySchemaAndPayload({{"% ^!"}, {}, "", {}}, "", 0, 0);
// }
//
// TEST(FuzzTest, TooManyRequiredFields) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"$ N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N "
// "N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N"},
// {},
// "",
// {}},
// "", 0, 4);
// }
//
// end:google_only