Exemplo n.º 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)
Exemplo n.º 2
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])