예제 #1
0
 def testCreateDataPipeWithIncorrectParameters(self):
     options = system.CreateDataPipeOptions()
     options.element_num_bytes = 5
     options.capacity_num_bytes = DATA_SIZE
     with self.assertRaises(system.MojoException) as cm:
         self._TestDataHandleCreation(system.DataPipe(options))
     self.assertEquals(system.RESULT_INVALID_ARGUMENT,
                       cm.exception.mojo_result)
예제 #2
0
 def testTwoPhaseReadOnDataPipe(self):
     pipes = system.DataPipe()
     data = _GetRandomBuffer(DATA_SIZE)
     self.assertEquals((system.RESULT_OK, DATA_SIZE),
                       pipes.producer_handle.WriteData(data))
     (res, buf) = pipes.consumer_handle.BeginReadData()
     self.assertEquals(system.RESULT_OK, res)
     self.assertEquals(DATA_SIZE, len(buf.buffer))
     self.assertEquals(data, buf.buffer)
     self.assertEquals(system.RESULT_OK, buf.End(DATA_SIZE))
예제 #3
0
 def testTwoPhaseWriteOnDataPipe(self):
     pipes = system.DataPipe()
     (res, buf) = pipes.producer_handle.BeginWriteData(DATA_SIZE)
     self.assertEquals(system.RESULT_OK, res)
     self.assertGreaterEqual(len(buf.buffer), DATA_SIZE)
     data = _GetRandomBuffer(DATA_SIZE)
     buf.buffer[0:DATA_SIZE] = data
     self.assertEquals(system.RESULT_OK, buf.End(DATA_SIZE))
     self.assertEquals((system.RESULT_OK, data),
                       pipes.consumer_handle.ReadData(bytearray(DATA_SIZE)))
예제 #4
0
 def testSendDataOverDataPipe(self):
   pipes = system.DataPipe()
   data = _GetRandomBuffer(DATA_SIZE)
   self.assertEquals((system.RESULT_OK, DATA_SIZE),
                     pipes.producer_handle.WriteData(data))
   self.assertEquals((system.RESULT_OK, data),
                     pipes.consumer_handle.ReadData(
                         bytearray(DATA_SIZE), system.READ_DATA_FLAG_PEEK))
   self.assertEquals((system.RESULT_OK, data),
                     pipes.consumer_handle.ReadData(bytearray(DATA_SIZE)))
예제 #5
0
 def testSendEmptyDataOverDataPipe(self):
     pipes = system.DataPipe()
     self.assertEquals((system.RESULT_OK, 0),
                       pipes.producer_handle.WriteData())
     self.assertEquals((system.RESULT_OK, None),
                       pipes.consumer_handle.ReadData())
예제 #6
0
 def testCreateDataPipeWithCapacity(self):
     options = system.CreateDataPipeOptions()
     options.element_capacity_num_bytes = DATA_SIZE
     self._TestDataHandleCreation(system.DataPipe(options))
예제 #7
0
 def testCreateDataPipeWithElementSize(self):
     options = system.CreateDataPipeOptions()
     options.element_num_bytes = 5
     self._TestDataHandleCreation(system.DataPipe(options))
예제 #8
0
 def testCreateDataPipeWithDefaultOptions(self):
     self._TestDataHandleCreation(
         system.DataPipe(system.CreateDataPipeOptions()))
예제 #9
0
 def testCreateDataPipeWithNoneOptions(self):
     self._TestDataHandleCreation(system.DataPipe(None))
예제 #10
0
 def testCreateDataPipe(self):
     self._TestDataHandleCreation(system.DataPipe())
예제 #11
0
 def testCreateDataPipeWithDiscardFlag(self):
     options = system.CreateDataPipeOptions()
     options.flags = system.CreateDataPipeOptions.FLAG_MAY_DISCARD
     self._TestDataHandleCreation(system.DataPipe(options))
 def setUp(self):
     super(DataPipeCopyTest, self).setUp()
     self.handles = system.DataPipe()
     self.error = None