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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 TEST(FilesystemTest, Sanity) { | 36 TEST(FilesystemTest, Sanity) { |
37 MemFsForTesting fs; | 37 MemFsForTesting fs; |
38 | 38 |
39 ScopedNode file; | 39 ScopedNode file; |
40 ScopedNode root; | 40 ScopedNode root; |
41 ScopedNode result_node; | 41 ScopedNode result_node; |
42 | 42 |
43 size_t result_size = 0; | 43 off_t result_size = 0; |
44 int result_bytes = 0; | 44 int result_bytes = 0; |
45 char buf1[1024]; | 45 char buf1[1024]; |
46 | 46 |
47 // A memory filesystem starts with one directory node: the root. | 47 // A memory filesystem starts with one directory node: the root. |
48 EXPECT_EQ(1, fs.num_nodes()); | 48 EXPECT_EQ(1, fs.num_nodes()); |
49 | 49 |
50 // Fail to open non existent file | 50 // Fail to open non existent file |
51 EXPECT_EQ(ENOENT, fs.Access(Path("/foo"), R_OK | W_OK)); | 51 EXPECT_EQ(ENOENT, fs.Access(Path("/foo"), R_OK | W_OK)); |
52 EXPECT_EQ(ENOENT, fs.Open(Path("/foo"), O_RDWR, &result_node)); | 52 EXPECT_EQ(ENOENT, fs.Open(Path("/foo"), O_RDWR, &result_node)); |
53 EXPECT_EQ(NULL, result_node.get()); | 53 EXPECT_EQ(NULL, result_node.get()); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 double expected_count = kTotalSamples / 256.; | 380 double expected_count = kTotalSamples / 256.; |
381 double chi_squared = 0; | 381 double chi_squared = 0; |
382 for (int i = 0; i < 256; ++i) { | 382 for (int i = 0; i < 256; ++i) { |
383 double difference = byte_count[i] - expected_count; | 383 double difference = byte_count[i] - expected_count; |
384 chi_squared += difference * difference / expected_count; | 384 chi_squared += difference * difference / expected_count; |
385 } | 385 } |
386 | 386 |
387 // Approximate chi-squared value for p-value 0.05, 255 degrees-of-freedom. | 387 // Approximate chi-squared value for p-value 0.05, 255 degrees-of-freedom. |
388 EXPECT_LE(chi_squared, 293.24); | 388 EXPECT_LE(chi_squared, 293.24); |
389 } | 389 } |
OLD | NEW |