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

Side by Side Diff: tests/glibc_syscall_wrappers/test_stat.c

Issue 6018003: Add fxstat check to glibc_syscall_wrappers test. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 10 years 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 | « no previous file | 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 2010 The Native Client Authors. All rights reserved. 2 * Copyright 2010 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 #include <assert.h> 7 #include <assert.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
11 11
12 #pragma GCC diagnostic ignored "-Wnonnull" 12 #pragma GCC diagnostic ignored "-Wnonnull"
13 13
14 #define KNOWN_FILE_SIZE 30 14 #define KNOWN_FILE_SIZE 30
15 15
16 int main(int argc, char** argv) { 16 int main(int argc, char** argv) {
17 struct stat st; 17 struct stat st;
18 struct stat64 st64; 18 struct stat64 st64;
19 FILE* file;
20 int fileDesc;
pasko-google - do not use 2010/12/21 12:00:41 s/fileDesc/fd/
19 21
20 if (2 != argc) { 22 if (2 != argc) {
21 printf("Usage: sel_ldr test_stat.nexe test_stat_data\n"); 23 printf("Usage: sel_ldr test_stat.nexe test_stat_data\n");
22 return 1; 24 return 1;
23 } 25 }
24 st.st_size = 0; 26 st.st_size = 0;
25 st64.st_size = 0; 27 st64.st_size = 0;
26 28
27 assert(-1 == stat(NULL, &st)); 29 assert(-1 == stat(NULL, &st));
28 assert(EFAULT == errno); 30 assert(EFAULT == errno);
29 assert(-1 == stat(".", NULL)); 31 assert(-1 == stat(".", NULL));
30 assert(EFAULT == errno); 32 assert(EFAULT == errno);
31 errno = 0; 33 errno = 0;
32 assert(0 == stat(argv[1], &st)); 34 assert(0 == stat(argv[1], &st));
33 assert(0 == errno); 35 assert(0 == errno);
34 assert(KNOWN_FILE_SIZE == st.st_size); 36 assert(KNOWN_FILE_SIZE == st.st_size);
35 37
36 assert(-1 == stat64(NULL, &st64)); 38 assert(-1 == stat64(NULL, &st64));
37 assert(EFAULT == errno); 39 assert(EFAULT == errno);
38 assert(-1 == stat64(".", NULL)); 40 assert(-1 == stat64(".", NULL));
39 assert(EFAULT == errno); 41 assert(EFAULT == errno);
40 errno = 0; 42 errno = 0;
41 assert(0 == stat64(argv[1], &st64)); 43 assert(0 == stat64(argv[1], &st64));
42 assert(0 == errno); 44 assert(0 == errno);
43 assert(KNOWN_FILE_SIZE == st64.st_size); 45 assert(KNOWN_FILE_SIZE == st64.st_size);
44 46
47 file = fopen(argv[1], "r");
pasko-google - do not use 2010/12/21 12:00:41 please, make a separate test_fstat.c
48 assert (NULL != file);
49 fileDesc = fileno(file);
50 assert (0 == fstat(fileDesc, &st));
51 assert (KNOWN_FILE_SIZE == st.st_size);
pasko-google - do not use 2010/12/21 12:00:41 also check for errno
52 assert (0 == fstat64(fileDesc, &st64));
53 assert (KNOWN_FILE_SIZE == st64.st_size);
54 assert (0 == fclose(file));
55 errno = 0;
56 assert (-1 == fstat(-1, &st));
57 assert (EBADF == errno);
58 errno = 0;
59 assert (-1 == fstat64(-1, &st64));
60 assert (EBADF == errno);
61
45 return 0; 62 return 0;
46 } 63 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698