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

Side by Side Diff: native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc

Issue 660353003: [NaCl SDK] nacl_io: Fix utime() on directories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <string.h> 7 #include <string.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 #include <string> 9 #include <string>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // one returned to the test, one for the name->inode map. 70 // one returned to the test, one for the name->inode map.
71 ASSERT_EQ(2, fs.num_nodes()); 71 ASSERT_EQ(2, fs.num_nodes());
72 ASSERT_EQ(2, file->RefCount()); 72 ASSERT_EQ(2, file->RefCount());
73 ASSERT_EQ(0, file->GetStat(&buf)); 73 ASSERT_EQ(0, file->GetStat(&buf));
74 ASSERT_EQ(0, buf.st_mode & S_IXUSR); 74 ASSERT_EQ(0, buf.st_mode & S_IXUSR);
75 75
76 // All access should be allowed on the root directory. 76 // All access should be allowed on the root directory.
77 EXPECT_EQ(0, fs.Open(Path("/"), O_RDONLY, &root)); 77 EXPECT_EQ(0, fs.Open(Path("/"), O_RDONLY, &root));
78 ASSERT_EQ(0, root->GetStat(&buf)); 78 ASSERT_EQ(0, root->GetStat(&buf));
79 ASSERT_EQ(S_IRWXU, buf.st_mode & S_IRWXU); 79 ASSERT_EQ(S_IRWXU, buf.st_mode & S_IRWXU);
80 // Opening a directory for write should fail.
81 EXPECT_EQ(EISDIR, fs.Open(Path("/"), O_RDWR, &root));
82 EXPECT_EQ(2, fs.num_nodes());
83 80
84 // Open the root directory, should not create a new file 81 // Open the root directory, should not create a new file
85 EXPECT_EQ(0, fs.Open(Path("/"), O_RDONLY, &root)); 82 EXPECT_EQ(0, fs.Open(Path("/"), O_RDONLY, &root));
86 EXPECT_EQ(2, fs.num_nodes()); 83 EXPECT_EQ(2, fs.num_nodes());
87 ASSERT_NE(NULL_NODE, root.get()); 84 ASSERT_NE(NULL_NODE, root.get());
88 struct dirent dirs[4]; 85 struct dirent dirs[4];
89 int len; 86 int len;
90 EXPECT_EQ(0, root->GetDents(0, dirs, sizeof(dirs), &len)); 87 EXPECT_EQ(0, root->GetDents(0, dirs, sizeof(dirs), &len));
91 // 3 == "foo", ".", ".." 88 // 3 == "foo", ".", ".."
92 EXPECT_EQ(3 * sizeof(struct dirent), len); 89 EXPECT_EQ(3 * sizeof(struct dirent), len);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 double expected_count = kTotalSamples / 256.; 394 double expected_count = kTotalSamples / 256.;
398 double chi_squared = 0; 395 double chi_squared = 0;
399 for (int i = 0; i < 256; ++i) { 396 for (int i = 0; i < 256; ++i) {
400 double difference = byte_count[i] - expected_count; 397 double difference = byte_count[i] - expected_count;
401 chi_squared += difference * difference / expected_count; 398 chi_squared += difference * difference / expected_count;
402 } 399 }
403 400
404 // Approximate chi-squared value for p-value 0.05, 255 degrees-of-freedom. 401 // Approximate chi-squared value for p-value 0.05, 255 degrees-of-freedom.
405 EXPECT_LE(chi_squared, 293.24); 402 EXPECT_LE(chi_squared, 293.24);
406 } 403 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc ('k') | native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698