TEST_F(FuseChannelTest, testDestroyWithPendingRequests) { auto channel = createChannel(); auto completeFuture = performInit(channel.get()); // Send several lookup requests auto id1 = fuse_.sendLookup(FUSE_ROOT_ID, "foobar"); auto id2 = fuse_.sendLookup(FUSE_ROOT_ID, "some_file.txt"); auto id3 = fuse_.sendLookup(FUSE_ROOT_ID, "main.c"); auto req1 = dispatcher_.waitForLookup(id1); auto req2 = dispatcher_.waitForLookup(id2); auto req3 = dispatcher_.waitForLookup(id3); // Destroy the channel object channel.reset(); // The completion future still should not be ready, since the lookup // requests are still pending. EXPECT_FALSE(completeFuture.isReady()); auto checkLookupResponse = [](const FakeFuse::Response& response, uint64_t requestID, fuse_entry_out expected) { EXPECT_EQ(requestID, response.header.unique); EXPECT_EQ(0, response.header.error); EXPECT_EQ( sizeof(fuse_out_header) + sizeof(fuse_entry_out), response.header.len); EXPECT_EQ( ByteRange( reinterpret_cast<const uint8_t*>(&expected), sizeof(expected)), ByteRange(response.body.data(), response.body.size())); }; // Respond to the lookup requests auto response1 = genRandomLookupResponse(9); req1.promise.setValue(response1); auto received = fuse_.recvResponse(); checkLookupResponse(received, id1, response1); // We don't have to respond in order; respond to request 3 before 2 auto response3 = genRandomLookupResponse(19); req3.promise.setValue(response3); received = fuse_.recvResponse(); checkLookupResponse(received, id3, response3); // The completion future still shouldn't be ready since there is still 1 // request outstanding. EXPECT_FALSE(completeFuture.isReady()); auto response2 = genRandomLookupResponse(12); req2.promise.setValue(response2); received = fuse_.recvResponse(); checkLookupResponse(received, id2, response2); // The completion future should be ready now that the last request // is done. EXPECT_TRUE(completeFuture.isReady()); std::move(completeFuture).get(kTimeout); }
TEST(Hash, sha1ByteRange) { // clang-format off auto data = folly::make_array<uint8_t>( 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34); // clang-format on EXPECT_EQ( Hash("2a9c28ef61eb536d3bbda64ad95a132554be3d6b"), Hash::sha1(ByteRange(data.data(), data.size()))); }