Skip to content

Commit

Permalink
test: Adjust Arena comparison test for older protobuf versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tradias committed Dec 9, 2024
1 parent 7c823b6 commit d9e41a1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test/src/test_server_rpc_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ TEST_CASE_FIXTURE(ServerRPCTest<test::UnaryServerRPC>, "Unary ServerRPC with pro
test::ArenaRequestMessageFactory& factory)
{
CHECK_EQ(42, request.integer());
CHECK_EQ(&factory.arena, request.GetArena());
CHECK(test::has_arena(request, factory.arena));
rpc.finish({}, grpc::Status::OK, yield);
CHECK_FALSE(factory.is_destroy_invoked);
}},
Expand Down Expand Up @@ -716,7 +716,7 @@ TEST_CASE_FIXTURE(ServerRPCTest<test::UnaryServerRPC>, "Unary ServerRPCPtr with
{
CHECK_EQ(42, request.integer());
CHECK_EQ(&ptr.request(), &request);
CHECK_EQ(&factory.arena, request.GetArena());
CHECK(test::has_arena(request, factory.arena));
auto& rpc = *ptr;
rpc.finish({}, grpc::Status::OK,
[ptr = std::move(ptr)](bool ok)
Expand Down
3 changes: 2 additions & 1 deletion test/src/test_unifex_20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "utils/doctest.hpp"
#include "utils/exception.hpp"
#include "utils/execution_test.hpp"
#include "utils/protobuf.hpp"
#include "utils/requestMessageFactory.hpp"
#include "utils/server_rpc.hpp"

Expand Down Expand Up @@ -161,7 +162,7 @@ TEST_CASE_FIXTURE(test::ExecutionRpcHandlerTest, "unifex rpc_handler unary with
[&](test::UnaryServerRPC& rpc, auto& request, test::ArenaRequestMessageFactory& factory)
{
CHECK_EQ(42, request.integer());
CHECK_EQ(&factory.arena, request.GetArena());
CHECK(test::has_arena(request, factory.arena));
return handle_unary_request_sender(rpc, request);
}});
run(make_client_unary_request_sender(test::five_seconds_from_now(),
Expand Down
11 changes: 11 additions & 0 deletions test/utils/utils/protobuf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#define AGRPC_UTILS_PROTOBUF_HPP

#include <doctest/doctest.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/stubs/common.h>
#include <grpcpp/impl/codegen/proto_utils.h>
#include <grpcpp/support/proto_buffer_reader.h>
#include <grpcpp/support/proto_buffer_writer.h>
Expand All @@ -40,6 +42,15 @@ grpc::ByteBuffer message_to_grpc_buffer(const Message& message)
CHECK_MESSAGE(status.ok(), status.error_message());
return buffer;
}

inline bool has_arena(const google::protobuf::MessageLite& message, const google::protobuf::Arena& arena)

Check failure on line 46 in test/utils/utils/protobuf.hpp

View workflow job for this annotation

GitHub Actions / Ubuntu/20.04/Default

unused parameter ‘message’ [-Werror=unused-parameter]

Check failure on line 46 in test/utils/utils/protobuf.hpp

View workflow job for this annotation

GitHub Actions / Ubuntu/20.04/Default

unused parameter ‘arena’ [-Werror=unused-parameter]

Check failure on line 46 in test/utils/utils/protobuf.hpp

View workflow job for this annotation

GitHub Actions / Ubuntu/20.04/Default

unused parameter ‘message’ [-Werror=unused-parameter]

Check failure on line 46 in test/utils/utils/protobuf.hpp

View workflow job for this annotation

GitHub Actions / Ubuntu/20.04/Default

unused parameter ‘arena’ [-Werror=unused-parameter]

Check failure on line 46 in test/utils/utils/protobuf.hpp

View workflow job for this annotation

GitHub Actions / Ubuntu/20.04/Default

unused parameter ‘message’ [-Werror=unused-parameter]

Check failure on line 46 in test/utils/utils/protobuf.hpp

View workflow job for this annotation

GitHub Actions / Ubuntu/20.04/Default

unused parameter ‘arena’ [-Werror=unused-parameter]

Check failure on line 46 in test/utils/utils/protobuf.hpp

View workflow job for this annotation

GitHub Actions / Ubuntu/20.04/Default

unused parameter ‘message’ [-Werror=unused-parameter]

Check failure on line 46 in test/utils/utils/protobuf.hpp

View workflow job for this annotation

GitHub Actions / Ubuntu/20.04/Default

unused parameter ‘arena’ [-Werror=unused-parameter]
{
#if GOOGLE_PROTOBUF_VERSION < 4000000
return true;
#else
return message.GetArena() == &arena;
#endif
}
}

#endif // AGRPC_UTILS_PROTOBUF_HPP

0 comments on commit d9e41a1

Please sign in to comment.