From 9daa3dc2ba9d0ddab2ddccc82dc5cc0919fa1f79 Mon Sep 17 00:00:00 2001 From: James Sedgwick Date: Fri, 21 Nov 2014 15:23:56 -0800 Subject: [PATCH] fix Makefile.am Summary: also kill duplicated test file Test Plan: run all exp/wangle tests Reviewed By: davejwatson@fb.com Subscribers: fugalh, njormrod, folly-diffs@ FB internal diff: D1698503 Signature: t1:1698503:1416612139:7139c6aa2ca79eabdaec6c33192194df984af348 --- folly/Makefile.am | 5 + .../wangle/channel/ChannelPipelineTest.cpp | 146 ------------------ 2 files changed, 5 insertions(+), 146 deletions(-) delete mode 100644 folly/experimental/wangle/channel/ChannelPipelineTest.cpp diff --git a/folly/Makefile.am b/folly/Makefile.am index 4aca7068..59e45023 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -72,6 +72,11 @@ nobase_follyinclude_HEADERS = \ experimental/io/FsUtil.h \ experimental/Singleton.h \ experimental/TestUtil.h \ + experimental/wangle/channel/AsyncSocketHandler.h \ + experimental/wangle/channel/ChannelHandler.h \ + experimental/wangle/channel/ChannelHandlerContext.h \ + experimental/wangle/channel/ChannelPipeline.h \ + experimental/wangle/channel/OutputBufferingHandler.h \ experimental/wangle/concurrent/BlockingQueue.h \ experimental/wangle/concurrent/Codel.h \ experimental/wangle/concurrent/CPUThreadPoolExecutor.h \ diff --git a/folly/experimental/wangle/channel/ChannelPipelineTest.cpp b/folly/experimental/wangle/channel/ChannelPipelineTest.cpp deleted file mode 100644 index bab898d9..00000000 --- a/folly/experimental/wangle/channel/ChannelPipelineTest.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2014 Facebook, Inc. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace folly; -using namespace folly::wangle; - -class ToString : public ChannelHandler { - public: - virtual ~ToString() {} - void read(Context* ctx, int msg) override { - LOG(INFO) << "ToString read"; - ctx->fireRead(folly::to(msg)); - } - Future write(Context* ctx, std::string msg) override { - LOG(INFO) << "ToString write"; - return ctx->fireWrite(folly::to(msg)); - } -}; - -class KittyPrepender : public ChannelHandlerAdapter { - public: - virtual ~KittyPrepender() {} - void read(Context* ctx, std::string msg) override { - LOG(INFO) << "KittyAppender read"; - ctx->fireRead(folly::to("kitty", msg)); - } - Future write(Context* ctx, std::string msg) override { - LOG(INFO) << "KittyAppender write"; - return ctx->fireWrite(msg.substr(5)); - } -}; - -typedef ChannelHandlerAdapter BytesPassthrough; - -class EchoService : public ChannelHandlerAdapter { - public: - virtual ~EchoService() {} - void read(Context* ctx, std::string str) override { - LOG(INFO) << "ECHO: " << str; - ctx->fireWrite(str).then([](Try&& t) { - LOG(INFO) << "done writing"; - }); - } -}; - -TEST(ChannelTest, PlzCompile) { - ChannelPipeline, - BytesPassthrough> - pipeline(BytesPassthrough(), BytesPassthrough(), BytesPassthrough); - - ChannelPipeline, - KittyPrepender, - KittyPrepender> - kittyPipeline( - std::make_shared(), - KittyPrepender{}, - KittyPrepender{}); - kittyPipeline.addBack(KittyPrepender{}); - kittyPipeline.addBack(EchoService{}); - kittyPipeline.finalize(); - kittyPipeline.read(5); - - auto handler = kittyPipeline.getHandler(2); - CHECK(handler); - - auto p = folly::make_unique(42); - folly::Optional> foo{std::move(p)}; -} - -TEST(ChannelTest, PlzCompile2) { - EchoService echoService; - ChannelPipeline pipeline; - pipeline - .addBack(ToString()) - .addBack(KittyPrepender()) - .addBack(KittyPrepender()) - .addBack(ChannelHandlerPtr(&echoService)) - .finalize(); - pipeline.read(42); -} - -TEST(ChannelTest, RealHandlersCompile) { - EventBase eb; - auto socket = AsyncSocket::newSocket(&eb); - ChannelPipeline> pipeline; - pipeline - .addBack(AsyncSocketHandler(socket)) - .addBack(OutputBufferingHandler()) - .finalize(); -} - -TEST(ChannelTest, MoveOnlyTypesCompile) { - ChannelPipeline, - BytesToBytesHandler, - BytesToBytesHandler> - pipeline(BytesToBytesHandler{}, BytesToBytesHandler{}); - pipeline - .addFront(BytesToBytesHandler{}) - .addBack(BytesToBytesHandler{}) - .finalize(); -} - -typedef StrictMock> IntHandler; - -ACTION(FireRead) { - arg0->fireRead(arg1); -} - -TEST(ChannelTest, Handoffs) { - IntHandler handler1; - IntHandler handler2; - MockChannelHandlerAdapter handler2; - ChannelPipeline, - ChannelHandlerPtr, - ChannelHandlerPtr> - pipeline(IntHandler{}, IntHandler{}); - pipeline.read(1); -} -- 2.34.1