| OLD | NEW |
| 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 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 | 5 |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 TEST(MountTest, Sanity) { | 49 TEST(MountTest, Sanity) { |
| 50 MountMemMock* mnt = new MountMemMock(); | 50 MountMemMock* mnt = new MountMemMock(); |
| 51 MountNode* file; | 51 MountNode* file; |
| 52 MountNode* root; | 52 MountNode* root; |
| 53 | 53 |
| 54 char buf1[1024]; | 54 char buf1[1024]; |
| 55 | 55 |
| 56 // A memory mount starts with one directory node: the root. | 56 // A memory mount starts with one directory node: the root. |
| 57 EXPECT_EQ(1, mnt->num_nodes()); | 57 EXPECT_EQ(1, mnt->num_nodes()); |
| 58 | 58 |
| 59 // Fail to open non existant file | 59 // Fail to open non existent file |
| 60 EXPECT_EQ(NULL_NODE, mnt->Open(Path("/foo"), O_RDWR)); | 60 EXPECT_EQ(NULL_NODE, mnt->Open(Path("/foo"), O_RDWR)); |
| 61 EXPECT_EQ(errno, ENOENT); | 61 EXPECT_EQ(errno, ENOENT); |
| 62 | 62 |
| 63 // Create a file | 63 // Create a file |
| 64 file = mnt->Open(Path("/foo"), O_RDWR | O_CREAT); | 64 file = mnt->Open(Path("/foo"), O_RDWR | O_CREAT); |
| 65 EXPECT_NE(NULL_NODE, file); | 65 EXPECT_NE(NULL_NODE, file); |
| 66 if (file == NULL) return; | 66 if (file == NULL) return; |
| 67 EXPECT_EQ(2, file->RefCount()); | 67 EXPECT_EQ(2, file->RefCount()); |
| 68 EXPECT_EQ(2, mnt->num_nodes()); | 68 EXPECT_EQ(2, mnt->num_nodes()); |
| 69 | 69 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 double expected_count = kTotalSamples / 256.; | 218 double expected_count = kTotalSamples / 256.; |
| 219 double chi_squared = 0; | 219 double chi_squared = 0; |
| 220 for (int i = 0; i < 256; ++i) { | 220 for (int i = 0; i < 256; ++i) { |
| 221 double difference = byte_count[i] - expected_count; | 221 double difference = byte_count[i] - expected_count; |
| 222 chi_squared += difference * difference / expected_count; | 222 chi_squared += difference * difference / expected_count; |
| 223 } | 223 } |
| 224 | 224 |
| 225 // Approximate chi-squared value for p-value 0.05, 255 degrees-of-freedom. | 225 // Approximate chi-squared value for p-value 0.05, 255 degrees-of-freedom. |
| 226 EXPECT_LE(chi_squared, 293.24); | 226 EXPECT_LE(chi_squared, 293.24); |
| 227 } | 227 } |
| OLD | NEW |