/* * Copyright (c) 2016, Google Inc. * All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include <vector> #include "path_matching.h" #include "string_compat.h" #include "test_compat.h" namespace perftools { TEST(PathMatching, DeletedSharedObjectMatching) { const std::vector<string> paths = { "lib.so.v1(deleted)", "lib.so.v1(deleted)junk", "lib.so (deleted)", "lib.so_junk_(deleted)", "lib.so .so junk_(deleted)", }; for (const auto& path : paths) { ASSERT_TRUE(IsDeletedSharedObject(path)); } } TEST(PathMatching, DeletedSharedObjectNotMatching) { const std::vector<string> paths = { "abc", "lib.so ", "lib.so(deleted)", ".so (deleted)", "lib.sojunk(deleted)", "", }; for (const auto& path : paths) { ASSERT_FALSE(IsDeletedSharedObject(path)); } } TEST(PathMatching, VersionedSharedObjectMatching) { const std::vector<string> paths = { "lib.so.", "lib.so.abc", "lib.so.1", "lib.so.v1", }; for (const auto& path : paths) { ASSERT_TRUE(IsVersionedSharedObject(path)); } } TEST(PathMatching, VersionedSharedObjectNotMatching) { const std::vector<string> paths = { "abc", "lib.so(deleted)", ".so.v1", ".so.", "", }; for (const auto& path : paths) { ASSERT_FALSE(IsDeletedSharedObject(path)); } } } // namespace perftools int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }