ruby_memprofiler_pprof 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/ruby_memprofiler_pprof/backtrace.c +429 -0
- data/ext/ruby_memprofiler_pprof/collector.c +1055 -0
- data/ext/ruby_memprofiler_pprof/compat.c +182 -0
- data/ext/ruby_memprofiler_pprof/extconf.rb +72 -0
- data/ext/ruby_memprofiler_pprof/pprof.upb.c +170 -0
- data/ext/ruby_memprofiler_pprof/pprof.upb.h +848 -0
- data/ext/ruby_memprofiler_pprof/pprof_out.c +285 -0
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.c +11 -0
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.h +301 -0
- data/ext/ruby_memprofiler_pprof/strtab.c +391 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/BUILD +719 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/CONTRIBUTING.md +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/DESIGN.md +201 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/LICENSE +26 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/README.md +78 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/WORKSPACE +58 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/BUILD +53 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/amalgamate.py +129 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/build_defs.bzl +160 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/lua.BUILD +127 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/protobuf.patch +54 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/py_proto_library.bzl +137 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/python_downloads.bzl +84 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/system_python.bzl +101 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/upb_proto_library.bzl +388 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/workspace_deps.bzl +89 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD +252 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD.googleapis +54 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/benchmark.cc +333 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/build_defs.bzl +88 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/compare.py +118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor.proto +888 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor_sv.proto +890 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/empty.proto +6 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_protobuf_binary_cc.py +64 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_synthetic_protos.py +118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_upb_binary_c.py +65 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/BUILD.bazel +102 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/README.md +23 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/build_defs.bzl +73 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/make_cmakelists.py +340 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test.py +57 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test_lib.py +186 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/render.py +43 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/style-guide.md +65 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/vs-cpp-protos.md +255 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/wrapping-upb.md +444 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/BUILD +216 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.c +394 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.h +63 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.c +1694 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.h +80 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.c +704 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.h +114 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.c +650 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.h +48 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/BUILD.bazel +193 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/dist.bzl +190 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.c +247 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.h +39 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.c +522 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.h +66 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.c +1909 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.h +101 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/minimal_test.py +183 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/BUILD +70 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/README.md +11 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_database_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_pool_test_wrapper.py +45 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_test_wrapper.py +46 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/generator_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/json_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/keywords_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_factory_test_wrapper.py +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_test_wrapper.py +52 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/proto_builder_test_wrapper.py +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/pyproto_test_wrapper.bzl +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/reflection_test_wrapper.py +45 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/service_reflection_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/symbol_database_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_encoding_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/unknown_fields_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/well_known_types_test_wrapper.py +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/wire_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.c +350 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.h +230 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/py_extension.bzl +55 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/python_api.h +61 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.c +828 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.h +69 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.c +404 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.h +39 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/version_script.lds +6 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/LICENSE +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/README.google +9 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/console.lua +156 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/lunit.lua +725 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/BUILD +19 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/LICENSE +21 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/naive.c +92 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-neon.c +157 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-sse.c +170 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/utf8_range.h +9 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/BUILD.bazel +129 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/README.md +8 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/def.c +939 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/lua_proto_library.bzl +138 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/main.c +83 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/msg.c +1118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test.proto +69 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test_upb.lua +846 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.c +258 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.h +132 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.lua +58 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upbc.cc +134 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.c +192 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.h +174 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb.c +346 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb_failures.txt +1 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.c +1221 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.h +94 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.c +1055 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.h +153 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_internal.h +211 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.c +3262 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.h +414 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.hpp +438 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/empty.proto +1 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.c +604 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.h +71 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/BUILD +13 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/file_descriptor_parsenew_fuzzer.cc +43 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.c +1509 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.h +47 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.c +776 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.h +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.c +1147 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.h +189 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.hpp +112 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.c +363 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.h +263 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_internal.h +59 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_test.cc +425 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_test.cc +230 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.c +428 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.h +114 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_internal.h +836 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.cc +491 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.proto +195 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_def.inc +261 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_undef.inc +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.c +323 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.h +109 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.hpp +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table.c +926 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table_internal.h +385 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test.proto +74 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.cc +186 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.proto +12 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_generated_code.cc +977 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_table.cc +580 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.c +472 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.h +64 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.c +362 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.h +378 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.hpp +115 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb_internal.h +68 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/BUILD +121 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/README.md +7 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.c +300 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.h +66 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare_test.cc +236 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.c +572 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.h +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_public_import_test.proto +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_regular_import_test.proto +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.cc +143 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.proto +119 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_weak_import_test.proto +28 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_wweak_import_test.proto +28 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.c +311 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.h +94 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.cc +202 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.proto +48 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/BUILD +78 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.cc +77 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.h +112 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upb.cc +1997 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upbdefs.cc +193 -0
- data/lib/ruby_memprofiler_pprof/atfork.rb +77 -0
- data/lib/ruby_memprofiler_pprof/block_flusher.rb +61 -0
- data/lib/ruby_memprofiler_pprof/file_flusher.rb +45 -0
- data/lib/ruby_memprofiler_pprof/profile_app.rb +30 -0
- data/lib/ruby_memprofiler_pprof/profile_data.rb +18 -0
- data/lib/ruby_memprofiler_pprof/version.rb +5 -0
- data/lib/ruby_memprofiler_pprof.rb +8 -0
- data/libexec/ruby_memprofiler_pprof_profile +16 -0
- metadata +257 -0
@@ -0,0 +1,346 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2009-2021, Google LLC
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions are met:
|
7
|
+
* * Redistributions of source code must retain the above copyright
|
8
|
+
* notice, this list of conditions and the following disclaimer.
|
9
|
+
* * Redistributions in binary form must reproduce the above copyright
|
10
|
+
* notice, this list of conditions and the following disclaimer in the
|
11
|
+
* documentation and/or other materials provided with the distribution.
|
12
|
+
* * Neither the name of Google LLC nor the
|
13
|
+
* names of its contributors may be used to endorse or promote products
|
14
|
+
* derived from this software without specific prior written permission.
|
15
|
+
*
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
|
20
|
+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
21
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
22
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
23
|
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
25
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
*/
|
27
|
+
|
28
|
+
/* This is a upb implementation of the upb conformance tests, see:
|
29
|
+
* https://github.com/google/protobuf/tree/master/conformance
|
30
|
+
*/
|
31
|
+
|
32
|
+
#include <errno.h>
|
33
|
+
#include <stdarg.h>
|
34
|
+
#include <stdio.h>
|
35
|
+
#include <stdlib.h>
|
36
|
+
#include <unistd.h>
|
37
|
+
|
38
|
+
#include "conformance/conformance.upb.h"
|
39
|
+
#include "conformance/conformance.upbdefs.h"
|
40
|
+
#include "google/protobuf/test_messages_proto2.upbdefs.h"
|
41
|
+
#include "google/protobuf/test_messages_proto3.upbdefs.h"
|
42
|
+
#include "upb/decode.h"
|
43
|
+
#include "upb/encode.h"
|
44
|
+
#include "upb/json_decode.h"
|
45
|
+
#include "upb/json_encode.h"
|
46
|
+
#include "upb/reflection.h"
|
47
|
+
#include "upb/text_encode.h"
|
48
|
+
|
49
|
+
// Must be last.
|
50
|
+
#include "upb/port_def.inc"
|
51
|
+
|
52
|
+
int test_count = 0;
|
53
|
+
bool verbose = false; /* Set to true to get req/resp printed on stderr. */
|
54
|
+
|
55
|
+
bool CheckedRead(int fd, void* buf, size_t len) {
|
56
|
+
size_t ofs = 0;
|
57
|
+
while (len > 0) {
|
58
|
+
ssize_t bytes_read = read(fd, (char*)buf + ofs, len);
|
59
|
+
|
60
|
+
if (bytes_read == 0) return false;
|
61
|
+
|
62
|
+
if (bytes_read < 0) {
|
63
|
+
perror("reading from test runner");
|
64
|
+
exit(1);
|
65
|
+
}
|
66
|
+
|
67
|
+
len -= bytes_read;
|
68
|
+
ofs += bytes_read;
|
69
|
+
}
|
70
|
+
|
71
|
+
return true;
|
72
|
+
}
|
73
|
+
|
74
|
+
void CheckedWrite(int fd, const void* buf, size_t len) {
|
75
|
+
if ((size_t)write(fd, buf, len) != len) {
|
76
|
+
perror("writing to test runner");
|
77
|
+
exit(1);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
typedef struct {
|
82
|
+
const conformance_ConformanceRequest* request;
|
83
|
+
conformance_ConformanceResponse* response;
|
84
|
+
upb_Arena* arena;
|
85
|
+
const upb_DefPool* symtab;
|
86
|
+
} ctx;
|
87
|
+
|
88
|
+
bool parse_proto(upb_Message* msg, const upb_MessageDef* m, const ctx* c) {
|
89
|
+
upb_StringView proto =
|
90
|
+
conformance_ConformanceRequest_protobuf_payload(c->request);
|
91
|
+
if (upb_Decode(proto.data, proto.size, msg, upb_MessageDef_MiniTable(m), NULL,
|
92
|
+
0, c->arena) == kUpb_DecodeStatus_Ok) {
|
93
|
+
return true;
|
94
|
+
} else {
|
95
|
+
static const char msg[] = "Parse error";
|
96
|
+
conformance_ConformanceResponse_set_parse_error(
|
97
|
+
c->response, upb_StringView_FromString(msg));
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
void serialize_proto(const upb_Message* msg, const upb_MessageDef* m,
|
103
|
+
const ctx* c) {
|
104
|
+
size_t len;
|
105
|
+
char* data = upb_Encode(msg, upb_MessageDef_MiniTable(m), 0, c->arena, &len);
|
106
|
+
if (data) {
|
107
|
+
conformance_ConformanceResponse_set_protobuf_payload(
|
108
|
+
c->response, upb_StringView_FromDataAndSize(data, len));
|
109
|
+
} else {
|
110
|
+
static const char msg[] = "Error serializing.";
|
111
|
+
conformance_ConformanceResponse_set_serialize_error(
|
112
|
+
c->response, upb_StringView_FromString(msg));
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
void serialize_text(const upb_Message* msg, const upb_MessageDef* m,
|
117
|
+
const ctx* c) {
|
118
|
+
size_t len;
|
119
|
+
size_t len2;
|
120
|
+
int opts = 0;
|
121
|
+
char* data;
|
122
|
+
|
123
|
+
if (!conformance_ConformanceRequest_print_unknown_fields(c->request)) {
|
124
|
+
opts |= UPB_TXTENC_SKIPUNKNOWN;
|
125
|
+
}
|
126
|
+
|
127
|
+
len = upb_TextEncode(msg, m, c->symtab, opts, NULL, 0);
|
128
|
+
data = upb_Arena_Malloc(c->arena, len + 1);
|
129
|
+
len2 = upb_TextEncode(msg, m, c->symtab, opts, data, len + 1);
|
130
|
+
UPB_ASSERT(len == len2);
|
131
|
+
conformance_ConformanceResponse_set_text_payload(
|
132
|
+
c->response, upb_StringView_FromDataAndSize(data, len));
|
133
|
+
}
|
134
|
+
|
135
|
+
bool parse_json(upb_Message* msg, const upb_MessageDef* m, const ctx* c) {
|
136
|
+
upb_StringView json = conformance_ConformanceRequest_json_payload(c->request);
|
137
|
+
upb_Status status;
|
138
|
+
int opts = 0;
|
139
|
+
|
140
|
+
if (conformance_ConformanceRequest_test_category(c->request) ==
|
141
|
+
conformance_JSON_IGNORE_UNKNOWN_PARSING_TEST) {
|
142
|
+
opts |= upb_JsonDecode_IgnoreUnknown;
|
143
|
+
}
|
144
|
+
|
145
|
+
upb_Status_Clear(&status);
|
146
|
+
if (upb_JsonDecode(json.data, json.size, msg, m, c->symtab, opts, c->arena,
|
147
|
+
&status)) {
|
148
|
+
return true;
|
149
|
+
} else {
|
150
|
+
const char* inerr = upb_Status_ErrorMessage(&status);
|
151
|
+
size_t len = strlen(inerr);
|
152
|
+
char* err = upb_Arena_Malloc(c->arena, len + 1);
|
153
|
+
memcpy(err, inerr, strlen(inerr));
|
154
|
+
err[len] = '\0';
|
155
|
+
conformance_ConformanceResponse_set_parse_error(
|
156
|
+
c->response, upb_StringView_FromString(err));
|
157
|
+
return false;
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
void serialize_json(const upb_Message* msg, const upb_MessageDef* m,
|
162
|
+
const ctx* c) {
|
163
|
+
size_t len;
|
164
|
+
size_t len2;
|
165
|
+
int opts = 0;
|
166
|
+
char* data;
|
167
|
+
upb_Status status;
|
168
|
+
|
169
|
+
upb_Status_Clear(&status);
|
170
|
+
len = upb_JsonEncode(msg, m, c->symtab, opts, NULL, 0, &status);
|
171
|
+
|
172
|
+
if (len == (size_t)-1) {
|
173
|
+
const char* inerr = upb_Status_ErrorMessage(&status);
|
174
|
+
size_t len = strlen(inerr);
|
175
|
+
char* err = upb_Arena_Malloc(c->arena, len + 1);
|
176
|
+
memcpy(err, inerr, strlen(inerr));
|
177
|
+
err[len] = '\0';
|
178
|
+
conformance_ConformanceResponse_set_serialize_error(
|
179
|
+
c->response, upb_StringView_FromString(err));
|
180
|
+
return;
|
181
|
+
}
|
182
|
+
|
183
|
+
data = upb_Arena_Malloc(c->arena, len + 1);
|
184
|
+
len2 = upb_JsonEncode(msg, m, c->symtab, opts, data, len + 1, &status);
|
185
|
+
UPB_ASSERT(len == len2);
|
186
|
+
conformance_ConformanceResponse_set_json_payload(
|
187
|
+
c->response, upb_StringView_FromDataAndSize(data, len));
|
188
|
+
}
|
189
|
+
|
190
|
+
bool parse_input(upb_Message* msg, const upb_MessageDef* m, const ctx* c) {
|
191
|
+
switch (conformance_ConformanceRequest_payload_case(c->request)) {
|
192
|
+
case conformance_ConformanceRequest_payload_protobuf_payload:
|
193
|
+
return parse_proto(msg, m, c);
|
194
|
+
case conformance_ConformanceRequest_payload_json_payload:
|
195
|
+
return parse_json(msg, m, c);
|
196
|
+
case conformance_ConformanceRequest_payload_NOT_SET:
|
197
|
+
fprintf(stderr, "conformance_upb: Request didn't have payload.\n");
|
198
|
+
return false;
|
199
|
+
default: {
|
200
|
+
static const char msg[] = "Unsupported input format.";
|
201
|
+
conformance_ConformanceResponse_set_skipped(
|
202
|
+
c->response, upb_StringView_FromString(msg));
|
203
|
+
return false;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
void write_output(const upb_Message* msg, const upb_MessageDef* m,
|
209
|
+
const ctx* c) {
|
210
|
+
switch (conformance_ConformanceRequest_requested_output_format(c->request)) {
|
211
|
+
case conformance_UNSPECIFIED:
|
212
|
+
fprintf(stderr, "conformance_upb: Unspecified output format.\n");
|
213
|
+
exit(1);
|
214
|
+
case conformance_PROTOBUF:
|
215
|
+
serialize_proto(msg, m, c);
|
216
|
+
break;
|
217
|
+
case conformance_TEXT_FORMAT:
|
218
|
+
serialize_text(msg, m, c);
|
219
|
+
break;
|
220
|
+
case conformance_JSON:
|
221
|
+
serialize_json(msg, m, c);
|
222
|
+
break;
|
223
|
+
default: {
|
224
|
+
static const char msg[] = "Unsupported output format.";
|
225
|
+
conformance_ConformanceResponse_set_skipped(
|
226
|
+
c->response, upb_StringView_FromString(msg));
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
void DoTest(const ctx* c) {
|
233
|
+
upb_Message* msg;
|
234
|
+
upb_StringView name = conformance_ConformanceRequest_message_type(c->request);
|
235
|
+
const upb_MessageDef* m =
|
236
|
+
upb_DefPool_FindMessageByNameWithSize(c->symtab, name.data, name.size);
|
237
|
+
#if 0
|
238
|
+
// Handy code for limiting conformance tests to a single input payload.
|
239
|
+
// This is a hack since the conformance runner doesn't give an easy way to
|
240
|
+
// specify what test should be run.
|
241
|
+
const char skip[] = "\343>\010\301\002\344>\230?\001\230?\002\230?\003";
|
242
|
+
upb_StringView skip_str = upb_StringView_FromDataAndSize(skip, sizeof(skip) - 1);
|
243
|
+
upb_StringView pb_payload =
|
244
|
+
conformance_ConformanceRequest_protobuf_payload(c->request);
|
245
|
+
if (!upb_StringView_IsEqual(pb_payload, skip_str)) m = NULL;
|
246
|
+
#endif
|
247
|
+
|
248
|
+
if (!m) {
|
249
|
+
static const char msg[] = "Unknown message type.";
|
250
|
+
conformance_ConformanceResponse_set_skipped(c->response,
|
251
|
+
upb_StringView_FromString(msg));
|
252
|
+
return;
|
253
|
+
}
|
254
|
+
|
255
|
+
msg = upb_Message_New(m, c->arena);
|
256
|
+
|
257
|
+
if (parse_input(msg, m, c)) {
|
258
|
+
write_output(msg, m, c);
|
259
|
+
}
|
260
|
+
}
|
261
|
+
|
262
|
+
void debug_print(const char* label, const upb_Message* msg,
|
263
|
+
const upb_MessageDef* m, const ctx* c) {
|
264
|
+
char buf[512];
|
265
|
+
upb_TextEncode(msg, m, c->symtab, UPB_TXTENC_SINGLELINE, buf, sizeof(buf));
|
266
|
+
fprintf(stderr, "%s: %s\n", label, buf);
|
267
|
+
}
|
268
|
+
|
269
|
+
bool DoTestIo(upb_DefPool* symtab) {
|
270
|
+
upb_Status status;
|
271
|
+
char* input;
|
272
|
+
char* output;
|
273
|
+
uint32_t input_size;
|
274
|
+
size_t output_size;
|
275
|
+
ctx c;
|
276
|
+
|
277
|
+
if (!CheckedRead(STDIN_FILENO, &input_size, sizeof(uint32_t))) {
|
278
|
+
/* EOF. */
|
279
|
+
return false;
|
280
|
+
}
|
281
|
+
|
282
|
+
c.symtab = symtab;
|
283
|
+
c.arena = upb_Arena_New();
|
284
|
+
input = upb_Arena_Malloc(c.arena, input_size);
|
285
|
+
|
286
|
+
if (!CheckedRead(STDIN_FILENO, input, input_size)) {
|
287
|
+
fprintf(stderr, "conformance_upb: unexpected EOF on stdin.\n");
|
288
|
+
exit(1);
|
289
|
+
}
|
290
|
+
|
291
|
+
c.request = conformance_ConformanceRequest_parse(input, input_size, c.arena);
|
292
|
+
c.response = conformance_ConformanceResponse_new(c.arena);
|
293
|
+
|
294
|
+
if (c.request) {
|
295
|
+
DoTest(&c);
|
296
|
+
} else {
|
297
|
+
fprintf(stderr, "conformance_upb: parse of ConformanceRequest failed: %s\n",
|
298
|
+
upb_Status_ErrorMessage(&status));
|
299
|
+
}
|
300
|
+
|
301
|
+
output = conformance_ConformanceResponse_serialize(c.response, c.arena,
|
302
|
+
&output_size);
|
303
|
+
|
304
|
+
uint32_t network_out = (uint32_t)output_size;
|
305
|
+
CheckedWrite(STDOUT_FILENO, &network_out, sizeof(uint32_t));
|
306
|
+
CheckedWrite(STDOUT_FILENO, output, output_size);
|
307
|
+
|
308
|
+
test_count++;
|
309
|
+
|
310
|
+
if (verbose) {
|
311
|
+
debug_print("Request", c.request,
|
312
|
+
conformance_ConformanceRequest_getmsgdef(symtab), &c);
|
313
|
+
debug_print("Response", c.response,
|
314
|
+
conformance_ConformanceResponse_getmsgdef(symtab), &c);
|
315
|
+
fprintf(stderr, "\n");
|
316
|
+
}
|
317
|
+
|
318
|
+
upb_Arena_Free(c.arena);
|
319
|
+
|
320
|
+
return true;
|
321
|
+
}
|
322
|
+
|
323
|
+
int main(void) {
|
324
|
+
upb_DefPool* symtab = upb_DefPool_New();
|
325
|
+
|
326
|
+
#ifdef REBUILD_MINITABLES
|
327
|
+
_upb_DefPool_LoadDefInitEx(
|
328
|
+
symtab, &google_protobuf_test_messages_proto2_proto_upbdefinit, true);
|
329
|
+
_upb_DefPool_LoadDefInitEx(
|
330
|
+
symtab, &google_protobuf_test_messages_proto3_proto_upbdefinit, true);
|
331
|
+
#else
|
332
|
+
protobuf_test_messages_proto2_TestAllTypesProto2_getmsgdef(symtab);
|
333
|
+
protobuf_test_messages_proto3_TestAllTypesProto3_getmsgdef(symtab);
|
334
|
+
#endif
|
335
|
+
|
336
|
+
while (1) {
|
337
|
+
if (!DoTestIo(symtab)) {
|
338
|
+
fprintf(stderr,
|
339
|
+
"conformance_upb: received EOF from test runner "
|
340
|
+
"after %d tests, exiting\n",
|
341
|
+
test_count);
|
342
|
+
upb_DefPool_Free(symtab);
|
343
|
+
return 0;
|
344
|
+
}
|
345
|
+
}
|
346
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
# No conformance tests are failing, thus the failure list is empty.
|