Commit 1be72ed0 authored by Nika Layzell's avatar Nika Layzell
Browse files

Bug 1845146 - Check numberOfBytes{Read,Written} in TestManyHandles,...

Bug 1845146 - Check numberOfBytes{Read,Written} in TestManyHandles, r=ipc-reviewers,handyman a=test-only

When running GTests on Windows 7, the TestManyHandles test crashes due
to the lpNumberOfBytesWritten argument to WriteFile not being passed.
This argument is required on earlier versions of Windows like Windows 7.

While we no longer support Windows 7 on Nightly, we still support it on
ESR, and are trying to run GTests on Windows 7 there. It also doesn't
hurt to add extra assertions that the full amount of data is
read/written, so checking this could be valuable on m-c as well.

Differential Revision: https://phabricator.services.mozilla.com/D184393
parent f9d918e6
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -25,7 +25,10 @@ class TestManyHandlesChild : public PTestManyHandlesChild {
      int value;
      int value;
      const int size = sizeof(value);
      const int size = sizeof(value);
#ifdef XP_WIN
#ifdef XP_WIN
      EXPECT_TRUE(::ReadFile(handle.get(), &value, size, nullptr, nullptr));
      DWORD numberOfBytesRead;
      EXPECT_TRUE(
          ::ReadFile(handle.get(), &value, size, &numberOfBytesRead, nullptr));
      EXPECT_EQ(numberOfBytesRead, (DWORD)size);
#else
#else
      EXPECT_EQ(read(handle.get(), &value, size), size);
      EXPECT_EQ(read(handle.get(), &value, size), size);
#endif
#endif
@@ -55,7 +58,10 @@ IPDL_TEST(TestManyHandles) {
#ifdef XP_WIN
#ifdef XP_WIN
    ASSERT_TRUE(::CreatePipe(getter_Transfers(readPipe),
    ASSERT_TRUE(::CreatePipe(getter_Transfers(readPipe),
                             getter_Transfers(writePipe), nullptr, size));
                             getter_Transfers(writePipe), nullptr, size));
    ASSERT_TRUE(::WriteFile(writePipe.get(), &i, size, nullptr, nullptr));
    DWORD numberOfBytesWritten;
    ASSERT_TRUE(
        ::WriteFile(writePipe.get(), &i, size, &numberOfBytesWritten, nullptr));
    ASSERT_EQ(numberOfBytesWritten, (DWORD)size);
#else
#else
    int fds[2];
    int fds[2];
    ASSERT_EQ(pipe(fds), 0);
    ASSERT_EQ(pipe(fds), 0);