blob: cbab5cfc883ac21b64e087b7babd5441fcaf2aa7 [file] [log] [blame]
Raul Silvera0c3c35e2016-09-21 13:14:55 -07001/*
2 * Copyright (c) 2016, Google Inc.
3 * All rights reserved.
Googler3a8b0ae2017-07-11 18:19:34 -07004 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
Raul Silvera0c3c35e2016-09-21 13:14:55 -07006 */
7
8#include <vector>
9
10#include "path_matching.h"
11#include "string_compat.h"
12#include "test_compat.h"
13
14namespace perftools {
Raul Silvera0c3c35e2016-09-21 13:14:55 -070015
16TEST(PathMatching, DeletedSharedObjectMatching) {
17 const std::vector<string> paths = {
18 "lib.so.v1(deleted)",
19 "lib.so.v1(deleted)junk",
20 "lib.so (deleted)",
21 "lib.so_junk_(deleted)",
22 "lib.so .so junk_(deleted)",
23 };
24 for (const auto& path : paths) {
Alexey Alexandrove18bc452016-11-04 14:55:48 -070025 ASSERT_TRUE(IsDeletedSharedObject(path));
Raul Silvera0c3c35e2016-09-21 13:14:55 -070026 }
27}
28
29TEST(PathMatching, DeletedSharedObjectNotMatching) {
30 const std::vector<string> paths = {
31 "abc",
32 "lib.so ",
33 "lib.so(deleted)",
34 ".so (deleted)",
35 "lib.sojunk(deleted)",
36 "",
37 };
38
39 for (const auto& path : paths) {
Alexey Alexandrove18bc452016-11-04 14:55:48 -070040 ASSERT_FALSE(IsDeletedSharedObject(path));
Raul Silvera0c3c35e2016-09-21 13:14:55 -070041 }
42}
43
44TEST(PathMatching, VersionedSharedObjectMatching) {
45 const std::vector<string> paths = {
46 "lib.so.", "lib.so.abc", "lib.so.1", "lib.so.v1",
47 };
48 for (const auto& path : paths) {
Alexey Alexandrove18bc452016-11-04 14:55:48 -070049 ASSERT_TRUE(IsVersionedSharedObject(path));
Raul Silvera0c3c35e2016-09-21 13:14:55 -070050 }
51}
52
53TEST(PathMatching, VersionedSharedObjectNotMatching) {
54 const std::vector<string> paths = {
55 "abc", "lib.so(deleted)", ".so.v1", ".so.", "",
56 };
57 for (const auto& path : paths) {
Alexey Alexandrove18bc452016-11-04 14:55:48 -070058 ASSERT_FALSE(IsDeletedSharedObject(path));
Raul Silvera0c3c35e2016-09-21 13:14:55 -070059 }
60}
61
Raul Silvera0c3c35e2016-09-21 13:14:55 -070062} // namespace perftools
63
64int main(int argc, char** argv) {
65 ::testing::InitGoogleTest(&argc, argv);
66 return RUN_ALL_TESTS();
67}