Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / glibc_syscall_wrappers / test_stat.c
1 /*
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 be
4  * found in the LICENSE file.
5  */
6
7 #include <assert.h>
8 #include <errno.h>
9 #include <stdio.h>
10 #include <sys/stat.h>
11
12 #pragma GCC diagnostic ignored "-Wnonnull"
13
14 #define KNOWN_FILE_SIZE 30
15
16 int main(int argc, char** argv) {
17   struct stat st;
18
19   if (2 != argc) {
20     printf("Usage: sel_ldr test_stat.nexe test_stat_data\n");
21     return 1;
22   }
23   st.st_size = 0;
24
25   assert(-1 == stat(NULL, &st));
26   assert(EFAULT == errno);
27   assert(-1 == stat(".", NULL));
28   assert(EFAULT == errno);
29   errno = 0;
30   assert(0 == stat(argv[1], &st));
31   assert(0 == errno);
32   assert(KNOWN_FILE_SIZE == st.st_size);
33
34   return 0;
35 }