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

Unified Diff: third_party/pexpect/tests/platform_checks/check_read.py

Issue 1398903002: Add third_party/pexpect (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@end-to-end-test
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 side-by-side diff with in-line comments
Download patch
Index: third_party/pexpect/tests/platform_checks/check_read.py
diff --git a/third_party/pexpect/tests/platform_checks/check_read.py b/third_party/pexpect/tests/platform_checks/check_read.py
new file mode 100644
index 0000000000000000000000000000000000000000..9598aa765eb4b9d0d69cc47e954f5042f9a9993c
--- /dev/null
+++ b/third_party/pexpect/tests/platform_checks/check_read.py
@@ -0,0 +1,35 @@
+import os
+
+filename = os.tmpnam()
+print 'filename:', filename
+
+fd_out = os.open(filename, os.O_CREAT | os.O_WRONLY)
+print 'fd_out:', fd_out
+os.write (fd_out, 'This is a test.\n')
+os.close(fd_out)
+print
+print 'testing read on good fd...'
+fd_in = os.open (filename, os.O_RDONLY)
+print 'fd_in:', fd_in
+while 1:
+ data_in = os.read(fd_in, 1)
+ print 'data_in:', data_in
+ if data_in == '':
+ print 'data_in was empty'
+ break #sys.exit(1)
+os.close(fd_in)
+print
+print
+print 'testing read on closed fd...'
+fd_in = os.open ('test_read.py', os.O_RDONLY)
+print 'fd_in:', fd_in
+while 1:
+ data_in = os.read(fd_in, 1)
+ print 'data_in:', data_in
+ if data_in == '':
+ print 'data_in was empty'
+ break
+os.close(fd_in)
+d = os.read(fd_in, 1) # fd_in should be closed now...
+if s == '':
+ print 'd is empty. good.'
« no previous file with comments | « third_party/pexpect/tests/platform_checks/check_handler.py ('k') | third_party/pexpect/tests/platform_checks/check_signals.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698