The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) https://grpc.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.8 KiB

// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/core/lib/promise/latch.h"
#include <tuple>
#include <utility>
#include "absl/status/status.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "src/core/lib/promise/activity.h"
#include "src/core/lib/promise/detail/basic_join.h"
#include "src/core/lib/promise/join.h"
#include "src/core/lib/promise/seq.h"
#include "test/core/promise/test_wakeup_schedulers.h"
using testing::MockFunction;
using testing::StrictMock;
namespace grpc_core {
TEST(LatchTest, Works) {
Latch<int> latch;
StrictMock<MockFunction<void(absl::Status)>> on_done;
EXPECT_CALL(on_done, Call(absl::OkStatus()));
MakeActivity(
[&latch] {
return Seq(Join(latch.Wait(),
[&latch]() {
latch.Set(42);
return true;
}),
[promises] Server call (#31448) * add experiment * allow instantiation * scratchings * scratchings * sniffly * Automated change: Fix sanity tests * fix * fix * fix * Automated change: Fix sanity tests * progress * change pipe labels to enable server code to be written * better api * Automated change: Fix sanity tests * progress * [promises] Implementation of deadline for server-based-calls * compression filter compiles again * Automated change: Fix sanity tests * fix * server tracing fixes * get client initial metadata * progress * progress * server call surface progress * Automated change: Fix sanity tests * move payload * server-progress * recv-message-server-connchan * logging * fix context-gate * recv fix@top * Automated change: Fix sanity tests * recv close on server * top termination start * [promises] Move Empty to be first class * fixes * fix * flow control fix * got to orphan! * orphan * call orphan * spam cleanup * fix * new cancelation semantics * progress * large metadata fixes * fix * fix * log * better logs * fix-chanz * logging, necessaryness * fix typo * fixes * fix * fix * fix-pipe * cleanup logging * fix * build-fix * fix * Automated change: Fix sanity tests * logging * Automated change: Fix sanity tests * Automated change: Fix sanity tests * better primitive * Revert "better primitive" This reverts commit 119b5ee244763a88d2318bc5145065f4940a2295. * fix * fix * trrracing * Automated change: Fix sanity tests * get-trailing-metadata * cancellation * Automated change: Fix sanity tests * add transform pipeline to pipe * add transform pipeline to pipe * interceptor lists * new server initial md api into filters * convert connected_channel * convert call * initial promise based filter conversion * convert promise based filter * build fixes * compile fix * fixes * fix ordering * fixes * check-metadata * revert later: debug code * better debug * fix metadata ordering with messages in promise based filter * fix ordering problem between batch completion and promise completion * properly handle failure on receive message path on client * more debug, fix a repoll bug in pbf * Automated change: Fix sanity tests * fixes * Automated change: Fix sanity tests * cleanup logging * fixes * missing file * fixes * logging * Automated change: Fix sanity tests * fixes * convert logging filter * fix * Automated change: Fix sanity tests * fix bad server response test * Revert "Disable logging test (#32049)" This reverts commit 5fc92eaeae6f668ba7c2df1024f18ef8c798a319. * fix * Automated change: Fix sanity tests * fix memory leaks, logging * Automated change: Fix sanity tests * slice refcount debugging * asan-canaries * leak-fix * leak-fix * Automated change: Fix sanity tests * fix * fix * fix * fix * fix * Automated change: Fix sanity tests * fix * remove mistaken line * add-comment * fix refcounting bug * Automated change: Fix sanity tests * rename variable * renames * bleh * carry pipe close status from bottom of pipe to top to appease recv-close-on-server * backport cancellation * Revert "carry pipe close status from bottom of pipe to top to appease" This reverts commit fa33301dcddd01aff52d3bee77b16ffef9466de5. * fix * Automated change: Fix sanity tests * review-feedback * comment-ordering * monostate * renames * undo-review-feedback * fix * review-feedback * review-feedback * fix * review-feedback * drop debugloc constructor * interceptor-list-rev-feedback * interceptor-list-rev-feedback * pipe test * review-feedback * undo-mistaken-change * Automated change: Fix sanity tests * pipe error state * detect send/recv failures and report * iwyu, build * fix submodules * fix * warning * cleanup * Automated change: Fix sanity tests * fix * fix for windows * fix * null pointer fix * iwyu * gen projex --------- Co-authored-by: ctiller <ctiller@users.noreply.github.com>
2 years ago
[](std::tuple<int, bool> result) {
EXPECT_EQ(std::get<0>(result), 42);
return absl::OkStatus();
});
},
NoWakeupScheduler(),
[&on_done](absl::Status status) { on_done.Call(std::move(status)); });
}
} // namespace grpc_core
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}