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

Side by Side Diff: third_party/android_crazy_linker/src/src/crazy_linker_system_unittest.cpp

Issue 322433006: Fork of the Android NDK crazy linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a required license header to a cpp module, missing in the original. Created 6 years, 6 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "crazy_linker_system.h"
6
7 #include <minitest/minitest.h>
8 #include <stdlib.h>
9 #include "crazy_linker_system_mock.h"
10
11 namespace crazy {
12
13 TEST(System, SingleFile) {
14 static const char kPath[] = "/tmp/foo/bar";
15
16 static const char kString[] = "Hello World";
17 const size_t kStringLen = sizeof(kString) - 1;
18
19 SystemMock sys;
20 sys.AddRegularFile(kPath, kString, kStringLen);
21
22 char buff2[kStringLen + 10];
23 FileDescriptor fd(kPath);
24
25 EXPECT_EQ(kStringLen, fd.Read(buff2, sizeof(buff2)));
26 buff2[kStringLen] = '\0';
27 EXPECT_STREQ(kString, buff2);
28 }
29
30 TEST(System, PathExists) {
31 SystemMock sys;
32 sys.AddRegularFile("/tmp/foo", "FOO", 3);
33
34 EXPECT_TRUE(PathExists("/tmp/foo"));
35 }
36
37 TEST(System, PathExistsWithBadPath) {
38 SystemMock sys;
39 EXPECT_FALSE(PathExists("/tmp/foo"));
40 }
41
42 TEST(System, IsSystemLibrary) {
43 SystemMock sys;
44 static const struct {
45 const char* name;
46 bool success;
47 } kData[] = {
48 {"libEGL.so", true},
49 {"libGLESv1_CM.so", true},
50 {"libGLESv1.so", false},
51 {"libGLESv2.so", true},
52 {"libOpenMAXAL.so", true},
53 {"libOpenSLES.so", true},
54 {"libandroid.so", true},
55 {"libc.so", true},
56 {"libdl.so", true},
57 {"libjnigraphics.so", true},
58 {"libm.so", true},
59 {"libstdc++.so", true},
60 {"libstlport.so", false},
61 {"libz.so", true},
62 {"/system/lib/libc.so", true},
63 {"/system/libc.so/libfoo.so", false},
64 };
65 for (size_t n = 0; n < ARRAY_LEN(kData); ++n) {
66 TEST_TEXT << "Checking " << kData[n].name;
67 EXPECT_EQ(kData[n].success, IsSystemLibrary(kData[n].name));
68 }
69 }
70
71 } // namespace crazy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698