OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |