コード例 #1
0
 def testWaitInvalidArgument(self):
   (res, index, states) = system.WaitMany(
           [(system.Handle(0), system.HANDLE_SIGNAL_WRITABLE),
            (system.Handle(0), system.HANDLE_SIGNAL_WRITABLE)],
           system.DEADLINE_INDEFINITE)
   self.assertEquals(system.RESULT_INVALID_ARGUMENT, res)
   self.assertEquals(0, index)
   self.assertEquals(states, None)
コード例 #2
0
ファイル: system_unittest.py プロジェクト: andycall/mojo
    def testWaitOverManyMessagePipe(self):
        handles = system.MessagePipe()
        handle0 = handles.handle0
        handle1 = handles.handle1

        self.assertEquals(
            0,
            system.WaitMany([(handle0, system.HANDLE_SIGNAL_WRITABLE),
                             (handle1, system.HANDLE_SIGNAL_WRITABLE)],
                            system.DEADLINE_INDEFINITE))
        self.assertEquals(
            system.RESULT_DEADLINE_EXCEEDED,
            system.WaitMany([(handle0, system.HANDLE_SIGNAL_READABLE),
                             (handle1, system.HANDLE_SIGNAL_READABLE)], 0))

        handle0.WriteMessage()

        self.assertEquals(
            1,
            system.WaitMany([(handle0, system.HANDLE_SIGNAL_READABLE),
                             (handle1, system.HANDLE_SIGNAL_READABLE)],
                            system.DEADLINE_INDEFINITE))
コード例 #3
0
  def testWaitOverManyMessagePipe(self):
    handles = system.MessagePipe()
    handle0 = handles.handle0
    handle1 = handles.handle1

    (res, index, states) = system.WaitMany(
            [(handle0, system.HANDLE_SIGNAL_WRITABLE),
             (handle1, system.HANDLE_SIGNAL_WRITABLE)],
            system.DEADLINE_INDEFINITE)
    self.assertEquals(system.RESULT_OK, res)
    self.assertEquals(0, index)
    self.assertEquals(system.HANDLE_SIGNAL_WRITABLE, states[0][0])
    self.assertEquals(CoreTest.HANDLE_SIGNAL_ALL, states[0][1])
    self.assertEquals(system.HANDLE_SIGNAL_WRITABLE, states[1][0])
    self.assertEquals(CoreTest.HANDLE_SIGNAL_ALL, states[1][1])

    (res, index, states) = system.WaitMany(
            [(handle0, system.HANDLE_SIGNAL_READABLE),
             (handle1, system.HANDLE_SIGNAL_READABLE)], 0)
    self.assertEquals(system.RESULT_DEADLINE_EXCEEDED, res)
    self.assertEquals(None, index)
    self.assertEquals(system.HANDLE_SIGNAL_WRITABLE, states[0][0])
    self.assertEquals(CoreTest.HANDLE_SIGNAL_ALL, states[0][1])
    self.assertEquals(system.HANDLE_SIGNAL_WRITABLE, states[1][0])
    self.assertEquals(CoreTest.HANDLE_SIGNAL_ALL, states[1][1])

    handle0.WriteMessage()

    (res, index, states) = system.WaitMany(
            [(handle0, system.HANDLE_SIGNAL_READABLE),
             (handle1, system.HANDLE_SIGNAL_READABLE)],
            system.DEADLINE_INDEFINITE)
    self.assertEquals(system.RESULT_OK, res)
    self.assertEquals(1, index)
    self.assertEquals(system.HANDLE_SIGNAL_WRITABLE, states[0][0])
    self.assertEquals(CoreTest.HANDLE_SIGNAL_ALL, states[0][1])
    self.assertEquals(CoreTest.HANDLE_SIGNAL_READWRITABLE, states[1][0])
    self.assertEquals(CoreTest.HANDLE_SIGNAL_ALL, states[1][1])