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

Unified Diff: third_party/crazy_linker/crazy_linker/src/crazy_linker_search_path_list_unittest.cpp

Issue 23717023: Android: Add chrome-specific dynamic linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove findbugs issues. Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/crazy_linker/crazy_linker/src/crazy_linker_search_path_list_unittest.cpp
diff --git a/third_party/crazy_linker/crazy_linker/src/crazy_linker_search_path_list_unittest.cpp b/third_party/crazy_linker/crazy_linker/src/crazy_linker_search_path_list_unittest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e93f706c67bec535ae23e104744c6bfd815be70e
--- /dev/null
+++ b/third_party/crazy_linker/crazy_linker/src/crazy_linker_search_path_list_unittest.cpp
@@ -0,0 +1,73 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "crazy_linker_search_path_list.h"
+
+#include <minitest/minitest.h>
+#include "crazy_linker_system_mock.h"
+
+namespace crazy {
+
+class TestSystem {
+public:
+ TestSystem() : sys_() {
+ sys_.AddRegularFile("/tmp/foo/bar", "BARBARBAR", 9);
+ sys_.AddRegularFile("/tmp/zoo", "ZOO", 3);
+ sys_.AddRegularFile("/foo", "Foo", 3);
+ sys_.AddEnvVariable("TEST_LIBRARY_PATH", "/tmp:/");
+ }
+
+ ~TestSystem() {}
+
+private:
+ SystemMock sys_;
+};
+
+TEST(SearchPathList, Empty) {
+ TestSystem sys;
+ SearchPathList list;
+ EXPECT_FALSE(list.FindFile("/foo"));
+ EXPECT_FALSE(list.FindFile("/tmp/zoo"));
+ EXPECT_FALSE(list.FindFile("/tmp/foo/bar"));
+}
+
+TEST(SearchPathList, OneItem) {
+ TestSystem sys;
+ SearchPathList list;
+ list.AddPaths("/tmp/foo");
+ EXPECT_STREQ("/tmp/foo/bar", list.FindFile("bar"));
+ EXPECT_FALSE(list.FindFile("zoo"));
+ EXPECT_FALSE(list.FindFile("foo"));
+}
+
+TEST(SearchPathList, Reset) {
+ TestSystem sys;
+ SearchPathList list;
+ list.AddPaths("/tmp/foo");
+ EXPECT_STREQ("/tmp/foo/bar", list.FindFile("bar"));
+
+ list.Reset();
+ EXPECT_FALSE(list.FindFile("bar"));
+}
+
+TEST(SearchPathList, ResetFromEnv) {
+ TestSystem sys;
+ SearchPathList list;
+ list.ResetFromEnv("TEST_LIBRARY_PATH");
+ EXPECT_STREQ("/tmp/foo/bar", list.FindFile("foo/bar"));
+ EXPECT_STREQ("/foo", list.FindFile("foo"));
+}
+
+TEST(SearchPathList, ThreeItems) {
+ TestSystem sys;
+ SearchPathList list;
+ list.AddPaths("/tmp/foo");
+ list.AddPaths("/tmp/");
+
+ EXPECT_STREQ("/tmp/foo/bar", list.FindFile("bar"));
+ EXPECT_STREQ("/tmp/zoo", list.FindFile("zoo"));
+ EXPECT_FALSE(list.FindFile("foo"));
+}
+
+} // namespace crazy

Powered by Google App Engine
This is Rietveld 408576698