~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/stat/src.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-09-20 22:44:35 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130920224435-apuwj4fsl3fqv1a6
Tags: 1.5.6~20130920~6010666-1
* New snapshot release
* Update the list of supported architectures to the same as libv8
  (Closes: #723129)
* emlibtool has been removed from upstream.
* Fix warning syntax-error-in-dep5-copyright
* Refresh of the patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
Note: Hardcoded st_ino values etc. may change with minor changes to the library impl.
3
 
      In such an event, we will need to update output.txt here.
4
 
*/
5
 
 
6
 
#include <stdio.h>
7
 
#include <string.h>
8
 
#include <errno.h>
9
 
#include <fcntl.h>
10
 
#include <sys/stat.h>
11
 
 
12
 
int main() {
13
 
  struct stat s;
14
 
 
15
 
  printf("--stat FOLDER--\n");
16
 
  printf("ret: %d\n", stat("/test", &s));
17
 
  printf("errno: %d\n", errno);
18
 
  printf("st_dev: %lu\n", s.st_dev);
19
 
  printf("st_ino: %lu\n", s.st_ino);
20
 
  printf("st_mode: 0%o\n", s.st_mode);
21
 
  printf("st_nlink: %d\n", s.st_nlink);
22
 
  printf("st_rdev: %lu\n", s.st_rdev);
23
 
  printf("st_size: %ld\n", s.st_size);
24
 
  printf("st_atime: %ld\n", s.st_atime);
25
 
  printf("st_mtime: %ld\n", s.st_mtime);
26
 
  printf("st_ctime: %ld\n", s.st_ctime);
27
 
  printf("st_blksize: %ld\n", s.st_blksize);
28
 
  printf("st_blocks: %ld\n", s.st_blocks);
29
 
  printf("S_ISBLK: %d\n", S_ISBLK(s.st_mode));
30
 
  printf("S_ISCHR: %d\n", S_ISCHR(s.st_mode));
31
 
  printf("S_ISDIR: %d\n", S_ISDIR(s.st_mode));
32
 
  printf("S_ISFIFO: %d\n", S_ISFIFO(s.st_mode));
33
 
  printf("S_ISREG: %d\n", S_ISREG(s.st_mode));
34
 
  printf("S_ISLNK: %d\n", S_ISLNK(s.st_mode));
35
 
  printf("S_ISSOCK: %d\n", S_ISSOCK(s.st_mode));
36
 
  memset(&s, 0, sizeof s);
37
 
 
38
 
  printf("\n--stat FILE--\n");
39
 
  printf("ret: %d\n", stat("/test/file", &s));
40
 
  printf("errno: %d\n", errno);
41
 
  printf("st_dev: %lu\n", s.st_dev);
42
 
  printf("st_ino: %lu\n", s.st_ino);
43
 
  printf("st_mode: 0%o\n", s.st_mode);
44
 
  printf("st_nlink: %d\n", s.st_nlink);
45
 
  printf("st_rdev: %lu\n", s.st_rdev);
46
 
  printf("st_size: %ld\n", s.st_size);
47
 
  printf("st_atime: %ld\n", s.st_atime);
48
 
  printf("st_mtime: %ld\n", s.st_mtime);
49
 
  printf("st_ctime: %ld\n", s.st_ctime);
50
 
  printf("st_blksize: %ld\n", s.st_blksize);
51
 
  printf("st_blocks: %ld\n", s.st_blocks);
52
 
  printf("S_ISBLK: %d\n", S_ISBLK(s.st_mode));
53
 
  printf("S_ISCHR: %d\n", S_ISCHR(s.st_mode));
54
 
  printf("S_ISDIR: %d\n", S_ISDIR(s.st_mode));
55
 
  printf("S_ISFIFO: %d\n", S_ISFIFO(s.st_mode));
56
 
  printf("S_ISREG: %d\n", S_ISREG(s.st_mode));
57
 
  printf("S_ISLNK: %d\n", S_ISLNK(s.st_mode));
58
 
  printf("S_ISSOCK: %d\n", S_ISSOCK(s.st_mode));
59
 
  memset(&s, 0, sizeof s);
60
 
 
61
 
  printf("\n--stat DEVICE--\n");
62
 
  printf("ret: %d\n", stat("/test/device", &s));
63
 
  printf("errno: %d\n", errno);
64
 
  printf("st_dev: %lu\n", s.st_dev);
65
 
  printf("st_ino: %lu\n", s.st_ino);
66
 
  printf("st_mode: 0%o\n", s.st_mode);
67
 
  printf("st_nlink: %d\n", s.st_nlink);
68
 
  printf("st_rdev: %lu\n", s.st_rdev);
69
 
  printf("st_size: %ld\n", s.st_size);
70
 
  printf("st_atime: %ld\n", s.st_atime);
71
 
  printf("st_mtime: %ld\n", s.st_mtime);
72
 
  printf("st_ctime: %ld\n", s.st_ctime);
73
 
  printf("st_blksize: %ld\n", s.st_blksize);
74
 
  printf("st_blocks: %ld\n", s.st_blocks);
75
 
  printf("S_ISBLK: %d\n", S_ISBLK(s.st_mode));
76
 
  printf("S_ISCHR: %d\n", S_ISCHR(s.st_mode));
77
 
  printf("S_ISDIR: %d\n", S_ISDIR(s.st_mode));
78
 
  printf("S_ISFIFO: %d\n", S_ISFIFO(s.st_mode));
79
 
  printf("S_ISREG: %d\n", S_ISREG(s.st_mode));
80
 
  printf("S_ISLNK: %d\n", S_ISLNK(s.st_mode));
81
 
  printf("S_ISSOCK: %d\n", S_ISSOCK(s.st_mode));
82
 
  memset(&s, 0, sizeof s);
83
 
 
84
 
  printf("\n--stat LINK--\n");
85
 
  printf("ret: %d\n", stat("/test/link", &s));
86
 
  printf("errno: %d\n", errno);
87
 
  printf("st_dev: %lu\n", s.st_dev);
88
 
  printf("st_ino: %lu\n", s.st_ino);
89
 
  printf("st_mode: 0%o\n", s.st_mode);
90
 
  printf("st_nlink: %d\n", s.st_nlink);
91
 
  printf("st_rdev: %lu\n", s.st_rdev);
92
 
  printf("st_size: %ld\n", s.st_size);
93
 
  printf("st_atime: %ld\n", s.st_atime);
94
 
  printf("st_mtime: %ld\n", s.st_mtime);
95
 
  printf("st_ctime: %ld\n", s.st_ctime);
96
 
  printf("st_blksize: %ld\n", s.st_blksize);
97
 
  printf("st_blocks: %ld\n", s.st_blocks);
98
 
  printf("S_ISBLK: %d\n", S_ISBLK(s.st_mode));
99
 
  printf("S_ISCHR: %d\n", S_ISCHR(s.st_mode));
100
 
  printf("S_ISDIR: %d\n", S_ISDIR(s.st_mode));
101
 
  printf("S_ISFIFO: %d\n", S_ISFIFO(s.st_mode));
102
 
  printf("S_ISREG: %d\n", S_ISREG(s.st_mode));
103
 
  printf("S_ISLNK: %d\n", S_ISLNK(s.st_mode));
104
 
  printf("S_ISSOCK: %d\n", S_ISSOCK(s.st_mode));
105
 
  memset(&s, 0, sizeof s);
106
 
 
107
 
  printf("\n--lstat LINK--\n");
108
 
  printf("ret: %d\n", lstat("/test/link", &s));
109
 
  printf("errno: %d\n", errno);
110
 
  printf("st_dev: %lu\n", s.st_dev);
111
 
  printf("st_ino: %lu\n", s.st_ino);
112
 
  printf("st_mode: 0%o\n", s.st_mode);
113
 
  printf("st_nlink: %d\n", s.st_nlink);
114
 
  printf("st_rdev: %lu\n", s.st_rdev);
115
 
  printf("st_size: %ld\n", s.st_size);
116
 
  printf("st_atime: %ld\n", s.st_atime);
117
 
  printf("st_mtime: %ld\n", s.st_mtime);
118
 
  printf("st_ctime: %ld\n", s.st_ctime);
119
 
  printf("st_blksize: %ld\n", s.st_blksize);
120
 
  printf("st_blocks: %ld\n", s.st_blocks);
121
 
  printf("S_ISBLK: %d\n", S_ISBLK(s.st_mode));
122
 
  printf("S_ISCHR: %d\n", S_ISCHR(s.st_mode));
123
 
  printf("S_ISDIR: %d\n", S_ISDIR(s.st_mode));
124
 
  printf("S_ISFIFO: %d\n", S_ISFIFO(s.st_mode));
125
 
  printf("S_ISREG: %d\n", S_ISREG(s.st_mode));
126
 
  printf("S_ISLNK: %d\n", S_ISLNK(s.st_mode));
127
 
  printf("S_ISSOCK: %d\n", S_ISSOCK(s.st_mode));
128
 
  memset(&s, 0, sizeof s);
129
 
 
130
 
  printf("\n--fstat FILE--\n");
131
 
  printf("ret: %d\n", fstat(open("/test/file", O_RDONLY, 0777), &s));
132
 
  printf("errno: %d\n", errno);
133
 
  printf("st_dev: %lu\n", s.st_dev);
134
 
  printf("st_ino: %lu\n", s.st_ino);
135
 
  printf("st_mode: 0%o\n", s.st_mode);
136
 
  printf("st_nlink: %d\n", s.st_nlink);
137
 
  printf("st_rdev: %lu\n", s.st_rdev);
138
 
  printf("st_size: %ld\n", s.st_size);
139
 
  printf("st_atime: %ld\n", s.st_atime);
140
 
  printf("st_mtime: %ld\n", s.st_mtime);
141
 
  printf("st_ctime: %ld\n", s.st_ctime);
142
 
  printf("st_blksize: %ld\n", s.st_blksize);
143
 
  printf("st_blocks: %ld\n", s.st_blocks);
144
 
  printf("S_ISBLK: %d\n", S_ISBLK(s.st_mode));
145
 
  printf("S_ISCHR: %d\n", S_ISCHR(s.st_mode));
146
 
  printf("S_ISDIR: %d\n", S_ISDIR(s.st_mode));
147
 
  printf("S_ISFIFO: %d\n", S_ISFIFO(s.st_mode));
148
 
  printf("S_ISREG: %d\n", S_ISREG(s.st_mode));
149
 
  printf("S_ISLNK: %d\n", S_ISLNK(s.st_mode));
150
 
  printf("S_ISSOCK: %d\n", S_ISSOCK(s.st_mode));
151
 
  memset(&s, 0, sizeof s);
152
 
 
153
 
  printf("\n--chmod FILE--\n");
154
 
  printf("ret: %d\n", chmod("/test/file", 0200));
155
 
  printf("errno: %d\n", errno);
156
 
  stat("/test/file", &s);
157
 
  printf("st_mode: 0%o\n", s.st_mode);
158
 
  printf("st_mtime changed: %d\n", s.st_mtime != 1200000000l);
159
 
  memset(&s, 0, sizeof s);
160
 
 
161
 
  printf("\n--fchmod FILE--\n");
162
 
  printf("ret: %d\n", fchmod(open("/test/file", O_WRONLY, 0777), 0777));
163
 
  printf("errno: %d\n", errno);
164
 
  stat("/test/file", &s);
165
 
  printf("st_mode: 0%o\n", s.st_mode);
166
 
  printf("st_mtime changed: %d\n", s.st_mtime != 1200000000l);
167
 
  memset(&s, 0, sizeof s);
168
 
 
169
 
  printf("\n--chmod FOLDER--\n");
170
 
  printf("ret: %d\n", chmod("/test", 0400));
171
 
  printf("errno: %d\n", errno);
172
 
  stat("/test", &s);
173
 
  printf("st_mode: 0%o\n", s.st_mode);
174
 
  printf("st_mtime changed: %d\n", s.st_mtime != 1200000000l);
175
 
  memset(&s, 0, sizeof s);
176
 
 
177
 
  printf("\n--chmod LINK--\n");
178
 
  printf("ret: %d\n", chmod("/test/link", 0000));
179
 
  printf("errno: %d\n", errno);
180
 
  stat("/test/file", &s);
181
 
  printf("st_mode: 0%o\n", s.st_mode);
182
 
  memset(&s, 0, sizeof s);
183
 
 
184
 
  // Make sure we can create stuff in the root.
185
 
  chmod("/", 0777);
186
 
 
187
 
  printf("\n--mkdir--\n");
188
 
  printf("ret: %d\n", mkdir("/test-mkdir", 0777));
189
 
  printf("errno: %d\n", errno);
190
 
  stat("/test-mkdir", &s);
191
 
  printf("st_mode: 0%o\n", s.st_mode);
192
 
  printf("S_ISBLK: %d\n", S_ISBLK(s.st_mode));
193
 
  printf("S_ISCHR: %d\n", S_ISCHR(s.st_mode));
194
 
  printf("S_ISDIR: %d\n", S_ISDIR(s.st_mode));
195
 
  printf("S_ISFIFO: %d\n", S_ISFIFO(s.st_mode));
196
 
  printf("S_ISREG: %d\n", S_ISREG(s.st_mode));
197
 
  printf("S_ISLNK: %d\n", S_ISLNK(s.st_mode));
198
 
  printf("S_ISSOCK: %d\n", S_ISSOCK(s.st_mode));
199
 
  memset(&s, 0, sizeof s);
200
 
 
201
 
  printf("\n--mknod FILE--\n");
202
 
  printf("ret: %d\n", mknod("/test-mknod-file", S_IFREG | 0777, 0));
203
 
  printf("errno: %d\n", errno);
204
 
  stat("/test-mknod-file", &s);
205
 
  printf("st_mode: 0%o\n", s.st_mode);
206
 
  printf("S_ISBLK: %d\n", S_ISBLK(s.st_mode));
207
 
  printf("S_ISCHR: %d\n", S_ISCHR(s.st_mode));
208
 
  printf("S_ISDIR: %d\n", S_ISDIR(s.st_mode));
209
 
  printf("S_ISFIFO: %d\n", S_ISFIFO(s.st_mode));
210
 
  printf("S_ISREG: %d\n", S_ISREG(s.st_mode));
211
 
  printf("S_ISLNK: %d\n", S_ISLNK(s.st_mode));
212
 
  printf("S_ISSOCK: %d\n", S_ISSOCK(s.st_mode));
213
 
  memset(&s, 0, sizeof s);
214
 
 
215
 
  printf("\n--mknod FOLDER--\n");
216
 
  printf("ret: %d\n", mknod("/test-mknod-dir", S_IFDIR | 0777, 0));
217
 
  printf("errno: %d\n", errno);
218
 
  stat("/test-mknod-dir", &s);
219
 
  printf("st_mode: 0%o\n", s.st_mode);
220
 
  printf("S_ISBLK: %d\n", S_ISBLK(s.st_mode));
221
 
  printf("S_ISCHR: %d\n", S_ISCHR(s.st_mode));
222
 
  printf("S_ISDIR: %d\n", S_ISDIR(s.st_mode));
223
 
  printf("S_ISFIFO: %d\n", S_ISFIFO(s.st_mode));
224
 
  printf("S_ISREG: %d\n", S_ISREG(s.st_mode));
225
 
  printf("S_ISLNK: %d\n", S_ISLNK(s.st_mode));
226
 
  printf("S_ISSOCK: %d\n", S_ISSOCK(s.st_mode));
227
 
  memset(&s, 0, sizeof s);
228
 
 
229
 
  printf("\n--mknod FIFO--\n");
230
 
  printf("ret: %d\n", mknod("/test-mknod-fifo", S_IFIFO | 0777, 0));
231
 
  printf("errno: %d\n", errno);
232
 
 
233
 
  printf("\n--mknod DEVICE--\n");
234
 
  printf("ret: %d\n", mknod("/test-mknod-device", S_IFCHR | 0777, 123));
235
 
  printf("errno: %d\n", errno);
236
 
 
237
 
  printf("\n--mkfifo--\n");
238
 
  printf("ret: %d\n", mkfifo("/test-mkfifo", 0777));
239
 
  printf("errno: %d\n", errno);
240
 
 
241
 
  return 0;
242
 
}