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

Side by Side Diff: base/files/dir_reader_posix_unittest.cc

Issue 1273243002: Updates to base unittests so they run correctly in libchrome on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Existing tests using ScopedLocale are wrapped by OS_LINUX, trying that Created 5 years, 4 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
« no previous file with comments | « base/command_line_unittest.cc ('k') | base/files/file_path_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/files/dir_reader_posix.h" 5 #include "base/files/dir_reader_posix.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
11 #include <unistd.h> 11 #include <unistd.h>
12 12
13 #include "base/files/scoped_temp_dir.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 #if defined(OS_ANDROID) 17 #if defined(OS_ANDROID)
17 #include "base/os_compat_android.h" 18 #include "base/os_compat_android.h"
18 #endif 19 #endif
19 20
20 namespace base { 21 namespace base {
21 22
22 TEST(DirReaderPosixUnittest, Read) { 23 TEST(DirReaderPosixUnittest, Read) {
23 static const unsigned kNumFiles = 100; 24 static const unsigned kNumFiles = 100;
24 25
25 if (DirReaderPosix::IsFallback()) 26 if (DirReaderPosix::IsFallback())
26 return; 27 return;
27 28
28 char kDirTemplate[] = "/tmp/org.chromium.dir-reader-posix-XXXXXX"; 29 base::ScopedTempDir temp_dir;
29 const char* dir = mkdtemp(kDirTemplate); 30 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
31 const char* dir = temp_dir.path().value().c_str();
30 ASSERT_TRUE(dir); 32 ASSERT_TRUE(dir);
31 33
32 const int prev_wd = open(".", O_RDONLY | O_DIRECTORY); 34 const int prev_wd = open(".", O_RDONLY | O_DIRECTORY);
33 DCHECK_GE(prev_wd, 0); 35 DCHECK_GE(prev_wd, 0);
34 36
35 PCHECK(chdir(dir) == 0); 37 PCHECK(chdir(dir) == 0);
36 38
37 for (unsigned i = 0; i < kNumFiles; i++) { 39 for (unsigned i = 0; i < kNumFiles; i++) {
38 char buf[16]; 40 char buf[16];
39 snprintf(buf, sizeof(buf), "%d", i); 41 snprintf(buf, sizeof(buf), "%d", i);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 85
84 PCHECK(fchdir(prev_wd) == 0); 86 PCHECK(fchdir(prev_wd) == 0);
85 PCHECK(close(prev_wd) == 0); 87 PCHECK(close(prev_wd) == 0);
86 88
87 EXPECT_TRUE(seen_dot); 89 EXPECT_TRUE(seen_dot);
88 EXPECT_TRUE(seen_dotdot); 90 EXPECT_TRUE(seen_dotdot);
89 EXPECT_EQ(kNumFiles, seen.size()); 91 EXPECT_EQ(kNumFiles, seen.size());
90 } 92 }
91 93
92 } // namespace base 94 } // namespace base
OLDNEW
« no previous file with comments | « base/command_line_unittest.cc ('k') | base/files/file_path_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698