forked from llvm/llvm-project
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not list adb devices when a device id is given
Summary: On Android, this method gets called twice: first when establishing a host-server connection, then when attaching to a process id. Each call takes several seconds to finish (especially slower on Windows) and eliminating the call for the typical case improves latency significantly. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D79586
- Loading branch information
1 parent
2c22c14
commit 7ff2de4
Showing
4 changed files
with
71 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//===-- AdbClientTest.cpp -------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "gtest/gtest.h" | ||
#include "Plugins/Platform/Android/AdbClient.h" | ||
#include <cstdlib> | ||
|
||
static void set_env(const char *var, const char *value) { | ||
#ifdef _WIN32 | ||
_putenv_s(var, value); | ||
#else | ||
setenv(var, value, true); | ||
#endif | ||
} | ||
|
||
using namespace lldb; | ||
using namespace lldb_private; | ||
|
||
namespace lldb_private { | ||
namespace platform_android { | ||
|
||
class AdbClientTest : public ::testing::Test { | ||
public: | ||
void SetUp() override { set_env("ANDROID_SERIAL", ""); } | ||
|
||
void TearDown() override { set_env("ANDROID_SERIAL", ""); } | ||
}; | ||
|
||
TEST(AdbClientTest, CreateByDeviceId) { | ||
AdbClient adb; | ||
Status error = AdbClient::CreateByDeviceID("device1", adb); | ||
EXPECT_TRUE(error.Success()); | ||
EXPECT_EQ("device1", adb.GetDeviceID()); | ||
} | ||
|
||
TEST(AdbClientTest, CreateByDeviceId_ByEnvVar) { | ||
set_env("ANDROID_SERIAL", "device2"); | ||
|
||
AdbClient adb; | ||
Status error = AdbClient::CreateByDeviceID("", adb); | ||
EXPECT_TRUE(error.Success()); | ||
EXPECT_EQ("device2", adb.GetDeviceID()); | ||
} | ||
|
||
} // end namespace platform_android | ||
} // end namespace lldb_private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
include_directories(${LLDB_SOURCE_DIR}/source/Plugins/Platform/Android) | ||
|
||
add_lldb_unittest(AdbClientTest | ||
AdbClientTest.cpp | ||
|
||
LINK_LIBS | ||
lldbPluginPlatformAndroid | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ add_lldb_unittest(LLDBPlatformTests | |
LINK_COMPONENTS | ||
Support | ||
) | ||
|
||
add_subdirectory(Android) |