Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: mojo/python/tests/system_unittest.py

Issue 1364463006: Make Python not support "all or none" for two-phase data pipe read/write. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/python/mojo_system.pyx ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import random 5 import random
6 import time 6 import time
7 7
8 import mojo_unittest 8 import mojo_unittest
9 9
10 # pylint: disable=E0611 10 # pylint: disable=E0611
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 self.assertEquals((system.RESULT_OK, DATA_SIZE), 257 self.assertEquals((system.RESULT_OK, DATA_SIZE),
258 pipes.producer_handle.WriteData(data)) 258 pipes.producer_handle.WriteData(data))
259 self.assertEquals((system.RESULT_OK, data), 259 self.assertEquals((system.RESULT_OK, data),
260 pipes.consumer_handle.ReadData( 260 pipes.consumer_handle.ReadData(
261 bytearray(DATA_SIZE), system.READ_DATA_FLAG_PEEK)) 261 bytearray(DATA_SIZE), system.READ_DATA_FLAG_PEEK))
262 self.assertEquals((system.RESULT_OK, data), 262 self.assertEquals((system.RESULT_OK, data),
263 pipes.consumer_handle.ReadData(bytearray(DATA_SIZE))) 263 pipes.consumer_handle.ReadData(bytearray(DATA_SIZE)))
264 264
265 def testTwoPhaseWriteOnDataPipe(self): 265 def testTwoPhaseWriteOnDataPipe(self):
266 pipes = system.DataPipe() 266 pipes = system.DataPipe()
267 (res, buf) = pipes.producer_handle.BeginWriteData(DATA_SIZE) 267 (res, buf) = pipes.producer_handle.BeginWriteData()
268 self.assertEquals(system.RESULT_OK, res) 268 self.assertEquals(system.RESULT_OK, res)
269 self.assertGreaterEqual(len(buf.buffer), DATA_SIZE) 269 self.assertGreaterEqual(len(buf.buffer), DATA_SIZE)
270 data = _GetRandomBuffer(DATA_SIZE) 270 data = _GetRandomBuffer(DATA_SIZE)
271 buf.buffer[0:DATA_SIZE] = data 271 buf.buffer[0:DATA_SIZE] = data
272 self.assertEquals(system.RESULT_OK, buf.End(DATA_SIZE)) 272 self.assertEquals(system.RESULT_OK, buf.End(DATA_SIZE))
273 self.assertEquals((system.RESULT_OK, data), 273 self.assertEquals((system.RESULT_OK, data),
274 pipes.consumer_handle.ReadData(bytearray(DATA_SIZE))) 274 pipes.consumer_handle.ReadData(bytearray(DATA_SIZE)))
275 275
276 def testTwoPhaseReadOnDataPipe(self): 276 def testTwoPhaseReadOnDataPipe(self):
277 pipes = system.DataPipe() 277 pipes = system.DataPipe()
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 self.assertEquals(system.RESULT_OK, res1) 318 self.assertEquals(system.RESULT_OK, res1)
319 self.assertEquals(system.RESULT_OK, res2) 319 self.assertEquals(system.RESULT_OK, res2)
320 self.assertEquals(DATA_SIZE, len(buf1.buffer)) 320 self.assertEquals(DATA_SIZE, len(buf1.buffer))
321 self.assertEquals(DATA_SIZE, len(buf2.buffer)) 321 self.assertEquals(DATA_SIZE, len(buf2.buffer))
322 self.assertEquals(buf1.buffer, buf2.buffer) 322 self.assertEquals(buf1.buffer, buf2.buffer)
323 323
324 buf1.buffer[:] = data 324 buf1.buffer[:] = data
325 self.assertEquals(data, buf1.buffer) 325 self.assertEquals(data, buf1.buffer)
326 self.assertEquals(data, buf2.buffer) 326 self.assertEquals(data, buf2.buffer)
327 self.assertEquals(buf1.buffer, buf2.buffer) 327 self.assertEquals(buf1.buffer, buf2.buffer)
OLDNEW
« no previous file with comments | « mojo/public/python/mojo_system.pyx ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698