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

Side by Side Diff: tests/syscalls/syscalls.cc

Issue 7669024: Diagnose EBADF before EFAULT (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/trusted/service_runtime/nacl_syscall_common.c ('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 /* 1 /*
2 * Copyright 2008 The Native Client Authors. All rights reserved. 2 * Copyright 2008 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * NaCl tests for simple syscalls 8 * NaCl tests for simple syscalls
9 */ 9 */
10 10
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return failed(testname, "read(fd, out_char, -1)"); 230 return failed(testname, "read(fd, out_char, -1)");
231 // bad address 231 // bad address
232 if (EFAULT != errno) 232 if (EFAULT != errno)
233 return failed(testname, "EFAULT != errno"); 233 return failed(testname, "EFAULT != errno");
234 234
235 errno = 0; 235 errno = 0;
236 // fd not OK, buffer OK, count not OK 236 // fd not OK, buffer OK, count not OK
237 ret_val = read(-1, out_char, -1); 237 ret_val = read(-1, out_char, -1);
238 if (ret_val != -1) 238 if (ret_val != -1)
239 return failed(testname, "read(-1, out_char, -1)"); 239 return failed(testname, "read(-1, out_char, -1)");
240 // bad address 240 // bad descriptor
241 if (EFAULT != errno) 241 if (EBADF != errno)
242 return failed(testname, "EFAULT != errno"); 242 return failed(testname, "EBADF != errno");
243 243
244 // fd OK, buffer OK, count 0 244 // fd OK, buffer OK, count 0
245 ret_val = read(fd, out_char, 0); 245 ret_val = read(fd, out_char, 0);
246 if (ret_val != 0) 246 if (ret_val != 0)
247 return failed(testname, "read(fd, out_char, 0)"); 247 return failed(testname, "read(fd, out_char, 0)");
248 248
249 // read 10, but only 3 are left 249 // read 10, but only 3 are left
250 ret_val = read(fd, out_char, 10); 250 ret_val = read(fd, out_char, 10);
251 if (ret_val != 4) 251 if (ret_val != 4)
252 return failed(testname, "read(fd, out_char, 10)"); 252 return failed(testname, "read(fd, out_char, 10)");
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 passed = testSuite(argv[1]); 424 passed = testSuite(argv[1]);
425 425
426 if (passed) { 426 if (passed) {
427 printf("All tests PASSED\n"); 427 printf("All tests PASSED\n");
428 exit(0); 428 exit(0);
429 } else { 429 } else {
430 printf("One or more tests FAILED\n"); 430 printf("One or more tests FAILED\n");
431 exit(-1); 431 exit(-1);
432 } 432 }
433 } 433 }
OLDNEW
« no previous file with comments | « src/trusted/service_runtime/nacl_syscall_common.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698