#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "mojo/public/c/system/data_pipe.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/numerics/safe_conversions.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/test/mojo_test_base.h"
#include "mojo/public/c/system/functions.h"
#include "mojo/public/c/system/message_pipe.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "mojo/public/cpp/system/simple_watcher.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace mojo {
namespace core {
namespace {
const uint32_t kSizeOfOptions = …;
const size_t kMaxPoll = …;
const size_t kMultiprocessCapacity = …;
const char kMultiprocessTestData[] = …;
const int kMultiprocessMaxIter = …;
constexpr size_t kOversizedCapacity = …;
base::TimeDelta EpsilonDeadline() { … }
class DataPipeTest : public test::MojoTestBase { … };
TEST_F(DataPipeTest, Basic) { … }
TEST_F(DataPipeTest, CreateAndMaybeTransfer) { … }
TEST_F(DataPipeTest, SimpleReadWrite) { … }
TEST_F(DataPipeTest, BasicProducerWaiting) { … }
TEST_F(DataPipeTest, PeerClosedProducerWaiting) { … }
TEST_F(DataPipeTest, PeerClosedConsumerWaiting) { … }
TEST_F(DataPipeTest, BasicConsumerWaiting) { … }
TEST_F(DataPipeTest, ConsumerNewDataReadable) { … }
TEST_F(DataPipeTest, ConsumerWaitingTwoPhase) { … }
TEST_F(DataPipeTest, BasicTwoPhaseWaiting) { … }
void Seq(int32_t start, size_t count, int32_t* out) { … }
TEST_F(DataPipeTest, AllOrNone) { … }
TEST_F(DataPipeTest, WrapAround) { … }
TEST_F(DataPipeTest, WriteCloseProducerRead) { … }
TEST_F(DataPipeTest, TwoPhaseWriteReadCloseConsumer) { … }
TEST_F(DataPipeTest, TwoPhaseWriteCloseBoth) { … }
TEST_F(DataPipeTest, WriteCloseProducerReadNoData) { … }
TEST_F(DataPipeTest, TwoPhaseReadMemoryStable) { … }
TEST_F(DataPipeTest, TwoPhaseMoreInvalidArguments) { … }
TEST_F(DataPipeTest, SendProducer) { … }
TEST_F(DataPipeTest, ConsumerWithClosedProducerSent) { … }
bool WriteAllData(MojoHandle producer,
const void* elements,
uint32_t num_bytes) { … }
bool ReadAllData(MojoHandle consumer,
void* elements,
uint32_t num_bytes,
bool expect_empty) { … }
TEST_F(DataPipeTest, CreateOversized) { … }
#if BUILDFLAG(USE_BLINK)
constexpr size_t kNoSpuriousEvents_NumIterations = …;
TEST_F(DataPipeTest, NoSpuriousEvents) { … }
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(NoSpuriousEventsHost, DataPipeTest, parent) { … }
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(NoSpuriousEventsClient,
DataPipeTest,
parent) { … }
TEST_F(DataPipeTest, Multiprocess) { … }
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(MultiprocessClient, DataPipeTest, client_mp) { … }
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(WriteAndCloseProducer, DataPipeTest, h) { … }
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(ReadAndCloseConsumer, DataPipeTest, h) { … }
TEST_F(DataPipeTest, SendConsumerAndCloseProducer) { … }
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(CreateAndWrite, DataPipeTest, h) { … }
TEST_F(DataPipeTest, CreateInChild) { … }
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(DataPipeStatusChangeInTransitClient,
DataPipeTest,
parent) { … }
TEST_F(DataPipeTest, StatusChangeInTransit) { … }
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(CreateOversizedChild, DataPipeTest, h) { … }
TEST_F(DataPipeTest, CreateOversizedInChild) { … }
class TestDataProducer { … };
class TestDataDrain { … };
constexpr uint32_t kStressTestDataSize = …;
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(StressTestRacyTrapsClient, DataPipeTest, h) { … }
TEST_F(DataPipeTest, DISABLED_StressTestRacyTraps) { … }
#endif
}
}
}