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

Side by Side Diff: tests/irt_ext/file_desc.c

Issue 511253005: Added irt extension support for supplying the nacl_irt_memory interface. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Moved size declaration down Created 6 years, 3 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/untrusted/nacl/nacl_ext_supply.c ('k') | tests/irt_ext/libc/file_tests.h » ('j') | 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 (c) 2014 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <string.h> 9 #include <string.h>
10 10
11 #include "native_client/tests/irt_ext/file_desc.h"
12 #include "native_client/src/include/nacl_assert.h" 11 #include "native_client/src/include/nacl_assert.h"
13 #include "native_client/src/include/nacl_macros.h" 12 #include "native_client/src/include/nacl_macros.h"
14 #include "native_client/src/untrusted/irt/irt_dev.h" 13 #include "native_client/src/untrusted/irt/irt_dev.h"
15 #include "native_client/src/untrusted/irt/irt_extension.h" 14 #include "native_client/src/untrusted/irt/irt_extension.h"
15 #include "native_client/tests/irt_ext/file_desc.h"
16 16
17 static struct file_desc_environment *g_activated_env = NULL; 17 static struct file_desc_environment *g_activated_env = NULL;
18 static const struct inode_data g_default_inode = { 18 static const struct inode_data g_default_inode = {
19 .valid = false, 19 .valid = false,
20 .mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, 20 .mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
21 }; 21 };
22 22
23 static struct inode_data g_root_dir = { 23 static struct inode_data g_root_dir = {
24 .valid = true, 24 .valid = true,
25 .mode = S_IFDIR, 25 .mode = S_IFDIR,
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 my_fstat, 289 my_fstat,
290 my_getdents, 290 my_getdents,
291 my_fchdir, 291 my_fchdir,
292 my_fchmod, 292 my_fchmod,
293 my_fsync, 293 my_fsync,
294 my_fdatasync, 294 my_fdatasync,
295 my_ftruncate, 295 my_ftruncate,
296 my_isatty, 296 my_isatty,
297 }; 297 };
298 298
299 /* These tables should have share common prefixes with one another. */ 299 size_t size = nacl_interface_ext_supply(NACL_IRT_DEV_FDIO_v0_3, &fdio,
300 ASSERT_GT(sizeof(struct nacl_irt_dev_fdio_v0_2), 300 sizeof(fdio));
301 sizeof(struct nacl_irt_fdio)); 301 ASSERT_EQ(size, sizeof(fdio));
302 ASSERT_GT(sizeof(struct nacl_irt_dev_fdio),
303 sizeof(struct nacl_irt_dev_fdio_v0_2));
304
305 nacl_interface_ext_supply(NACL_IRT_FDIO_v0_1, &fdio,
306 sizeof(struct nacl_irt_fdio));
307 nacl_interface_ext_supply(NACL_IRT_DEV_FDIO_v0_2, &fdio,
308 sizeof(struct nacl_irt_dev_fdio_v0_2));
309 nacl_interface_ext_supply(NACL_IRT_DEV_FDIO_v0_3, &fdio,
310 sizeof(fdio));
311 302
312 struct nacl_irt_dev_filename fname = { 303 struct nacl_irt_dev_filename fname = {
313 my_open, 304 my_open,
314 my_stat, 305 my_stat,
315 my_mkdir, 306 my_mkdir,
316 my_rmdir, 307 my_rmdir,
317 my_chdir, 308 my_chdir,
318 my_getcwd, 309 my_getcwd,
319 my_unlink, 310 my_unlink,
320 my_truncate, 311 my_truncate,
321 my_lstat, 312 my_lstat,
322 my_link, 313 my_link,
323 my_rename, 314 my_rename,
324 my_symlink, 315 my_symlink,
325 my_chmod, 316 my_chmod,
326 my_access, 317 my_access,
327 my_readlink, 318 my_readlink,
328 my_utimes, 319 my_utimes,
329 }; 320 };
330 321
331 /* These tables should have share common prefixes with one another. */ 322 /* These tables should have share common prefixes with one another. */
332 ASSERT_GT(sizeof(struct nacl_irt_dev_filename_v0_2), 323 size = nacl_interface_ext_supply(NACL_IRT_DEV_FILENAME_v0_3, &fname,
333 sizeof(struct nacl_irt_filename)); 324 sizeof(fname));
334 ASSERT_GT(sizeof(struct nacl_irt_dev_filename), 325 ASSERT_EQ(size, sizeof(fname));
335 sizeof(struct nacl_irt_dev_filename_v0_2));
336
337 nacl_interface_ext_supply(NACL_IRT_FILENAME_v0_1, &fname,
338 sizeof(struct nacl_irt_filename));
339 nacl_interface_ext_supply(NACL_IRT_DEV_FILENAME_v0_2, &fname,
340 sizeof(struct nacl_irt_dev_filename_v0_2));
341 nacl_interface_ext_supply(NACL_IRT_DEV_FILENAME_v0_3, &fname,
342 sizeof(fname));
343 } 326 }
344 327
345 void init_inode_data(struct inode_data *inode_data) { 328 void init_inode_data(struct inode_data *inode_data) {
346 *inode_data = g_default_inode; 329 *inode_data = g_default_inode;
347 } 330 }
348 331
349 void init_file_descriptor(struct file_descriptor *file_desc) { 332 void init_file_descriptor(struct file_descriptor *file_desc) {
350 file_desc->valid = false; 333 file_desc->valid = false;
351 file_desc->data = NULL; 334 file_desc->data = NULL;
352 } 335 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 return find_inode_name(env, current_dir, path_iter, strlen(path_iter)); 412 return find_inode_name(env, current_dir, path_iter, strlen(path_iter));
430 } 413 }
431 414
432 void activate_file_desc_env(struct file_desc_environment *env) { 415 void activate_file_desc_env(struct file_desc_environment *env) {
433 g_activated_env = env; 416 g_activated_env = env;
434 } 417 }
435 418
436 void deactivate_file_desc_env(void) { 419 void deactivate_file_desc_env(void) {
437 g_activated_env = NULL; 420 g_activated_env = NULL;
438 } 421 }
OLDNEW
« no previous file with comments | « src/untrusted/nacl/nacl_ext_supply.c ('k') | tests/irt_ext/libc/file_tests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698