Example #1
0
void
TestDataStructuresChild::Test1()
{
    InfallibleTArray<int> ia;

    for (int i = 0; i < 5; ++i)
        ia.AppendElement(i);

    InfallibleTArray<int> oa;
    if (!SendTest1(ia, &oa))
        fail("can't send Test1");

    assert_arrays_equal(ia, oa);

    printf("  passed %s\n", __FUNCTION__);
}
bool
TestUrgencyChild::RecvStart()
{
  uint32_t result;
  
  // Send a synchronous message, expect to get an urgent message while
  // blocked.
  test_ = kFirstTestBegin;
  if (!SendTest1(&result))
    fail("calling SendTest1");
  if (result != 99)
    fail("bad result in RecvStart");
  if (test_ != kFirstTestGotReply)
    fail("never received urgent message");

  // Initiate the next test by sending an asynchronous message, then becoming
  // blocked. This tests that the urgent message is still delivered properly,
  // and that the parent does not try to service the sync 
  test_ = kSecondTestBegin;
  if (!SendTest2())
    fail("calling SendTest2");
  if (!SendTest3(&result))
    fail("calling SendTest3");
  if (test_ != kSecondTestGotReply)
    fail("never received urgent message #2");
  if (result != 1000)
    fail("wrong value from test3");

  if (!SendTest4_Begin())
    fail("calling SendTest4_Begin");

  // This must be the last test, since the child process may die.
  if (SendFinalTest_Begin())
    fail("Final test should not have succeeded");

  Close();

  return true;
}