Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
devel/android-tools-adb: fix TEST=on after r527733
Browse files Browse the repository at this point in the history
socket_spec_test.cpp:101: Failure
Expected equality of these values:
  5555
  get_host_socket_spec_port("vsock:5555", &error)
    Which is: -1

* thread #1, name = 'adb_test', stop reason = signal SIGILL: privileged instruction
    frame #0: 0x00000000003fc604 adb_test`GetThreadId() at logger_write.cpp:240:31
   237  #endif
   238
   239  // Copied from base/threads.cpp
-> 240  static uint64_t GetThreadId() {
   241  #if defined(__BIONIC__)
   242    return gettid();
   243  #elif defined(__APPLE__)
(lldb) bt
* thread #1, name = 'adb_test', stop reason = signal SIGILL: privileged instruction
  * frame #0: 0x00000000003fc604 adb_test`GetThreadId() at logger_write.cpp:240:31
    frame #1: 0x00000000003fc3ce adb_test`::__android_log_stderr_logger(logger_data=0x00007fffffffce60, message="foobar") at logger_write.cpp:274:18
    frame #2: 0x00000000003fc92a adb_test`::__android_log_write_logger_data(logger_data=0x00007fffffffce60, msg="foobar") at logger_write.cpp:329:3
    frame #3: 0x00000000003f6c44 adb_test`android::base::LogMessage::LogLine(file="logging_test.cpp", line=603, severity=ERROR, tag=0x0000000000000000, message="foobar") at logging.cpp:581:5
    frame #4: 0x00000000003f683d adb_test`android::base::LogMessage::~LogMessage(this=0x00007fffffffd000) at logging.cpp:542:7
    frame #5: 0x00000000004f76fe adb_test`TestLoggingInConstructor() at logging_test.cpp:603:3

* thread #1, name = 'adb_test', stop reason = signal SIGSEGV: invalid address (fault address: 0x14)
    frame #0: 0x00000000004c8dc8 adb_test`file_RemoveFileIfExists_EACCES_Test::TestBody(this=0x0000000800f91060) at file_test.cpp:247:19
   244    // root can bypass permission restrictions, so drop root.
   245    if (getuid() == 0) {
   246      passwd* shell = getpwnam("shell");
-> 247      setgid(shell->pw_gid);
   248      setuid(shell->pw_uid);
   249    }
   250
(lldb) bt
* thread #1, name = 'adb_test', stop reason = signal SIGSEGV: invalid address (fault address: 0x14)
  * frame #0: 0x00000000004c8dc8 adb_test`file_RemoveFileIfExists_EACCES_Test::TestBody(this=0x0000000800f91060) at file_test.cpp:247:19
    frame #1: 0x0000000800982d6e libgtest.so`void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(object=0x0000000800f91060, method=21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, location="the test body")(), char const*) at gtest.cc:2433:10
    frame #2: 0x0000000800962399 libgtest.so`void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(object=0x0000000800f91060, method=21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, location="the test body")(), char const*) at gtest.cc:2469:14
    frame #3: 0x0000000800942b43 libgtest.so`testing::Test::Run(this=0x0000000800f91060) at gtest.cc:2508:5
    frame #4: 0x0000000800943792 libgtest.so`testing::TestInfo::Run(this=0x0000000800fa3ba0) at gtest.cc:2684:11
    frame #5: 0x0000000800943e17 libgtest.so`testing::TestSuite::Run(this=0x0000000800fa34a0) at gtest.cc:2816:28
    frame #6: 0x0000000800950480 libgtest.so`testing::internal::UnitTestImpl::RunAllTests(this=0x0000000800fa4000) at gtest.cc:5338:44
    frame #7: 0x0000000800987bfe libgtest.so`bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(object=0x0000000800fa4000, method=40 00 95 00 08 00 00 00 00 00 00 00 00 00 00 00, location="auxiliary test code (environments or event listeners)")(), char const*) at gtest.cc:2433:10
    frame freebsd#8: 0x00000008009650a9 libgtest.so`bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(object=0x0000000800fa4000, method=40 00 95 00 08 00 00 00 00 00 00 00 00 00 00 00, location="auxiliary test code (environments or event listeners)")(), char const*) at gtest.cc:2469:14
    frame freebsd#9: 0x000000080094ffd4 libgtest.so`testing::UnitTest::Run(this=0x000000080099a0d8) at gtest.cc:4925:10
    frame freebsd#10: 0x0000000000543cf1 adb_test`RUN_ALL_TESTS() at gtest.h:2473:46
    frame freebsd#11: 0x0000000000543c70 adb_test`main(argc=1, argv=0x00007fffffffeae8) at test_main.cpp:24:10
    frame freebsd#12: 0x000000000031710f adb_test`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76:7

PR:		245642
Submitted by:	Marcin Cieślak (based on)
  • Loading branch information
jbeich committed Apr 15, 2020
1 parent 4bc3afb commit 21a1537
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 6 deletions.
2 changes: 1 addition & 1 deletion devel/android-tools-adb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
PORTNAME= android-tools-adb
DISTVERSIONPREFIX= platform-tools-
DISTVERSION?= 29.0.6
PORTREVISION?= 0
PORTREVISION?= 1
CATEGORIES= devel comms

MAINTAINER= jbeich@FreeBSD.org
Expand Down
14 changes: 14 additions & 0 deletions devel/android-tools-adb/files/patch-adb_socket__spec__test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- adb/socket_spec_test.cpp.orig 2020-02-11 20:44:45 UTC
+++ adb/socket_spec_test.cpp
@@ -98,7 +98,11 @@ TEST(socket_spec, get_host_socket_spec_port) {
EXPECT_EQ(5555, get_host_socket_spec_port("tcp:5555", &error));
EXPECT_EQ(5555, get_host_socket_spec_port("tcp:localhost:5555", &error));
EXPECT_EQ(5555, get_host_socket_spec_port("tcp:[::1]:5555", &error));
+#if ADB_LINUX
EXPECT_EQ(5555, get_host_socket_spec_port("vsock:5555", &error));
+#else
+ EXPECT_EQ(-1, get_host_socket_spec_port("vsock:5555", &error));
+#endif
}

TEST(socket_spec, get_host_socket_spec_port_no_port) {
17 changes: 13 additions & 4 deletions devel/android-tools-adb/files/patch-base_file__test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- base/file_test.cpp.orig 2017-06-20 10:50:27 UTC
--- base/file_test.cpp.orig 2020-02-11 20:44:45 UTC
+++ base/file_test.cpp
@@ -52,12 +52,20 @@ TEST(file, ReadFileToString_WriteStringToFile_symlink)
@@ -61,12 +61,20 @@ TEST(file, ReadFileToString_WriteStringToFile_symlink)
ASSERT_EQ(0, unlink(link.path));
ASSERT_EQ(0, symlink(target.path, link.path));
ASSERT_FALSE(android::base::WriteStringToFile("foo", link.path, false));
Expand All @@ -21,15 +21,24 @@
ASSERT_TRUE(android::base::ReadFileToString(link.path, &s, true));
ASSERT_EQ("foo", s);
}
@@ -131,6 +139,7 @@ TEST(file, RemoveFileIfExist) {
@@ -235,7 +243,7 @@ TEST(file, RemoveFileIfExists_EACCES) {
// EACCES -- one of the directories in the path has no search permission
// root can bypass permission restrictions, so drop root.
if (getuid() == 0) {
- passwd* shell = getpwnam("shell");
+ passwd* shell = getpwnam("nobody");
setgid(shell->pw_gid);
setuid(shell->pw_uid);
}
@@ -257,6 +265,7 @@ TEST(file, RemoveFileIfExists_EACCES) {

TEST(file, Readlink) {
#if !defined(_WIN32)
+#ifdef __linux__
// Linux doesn't allow empty symbolic links.
std::string min("x");
// ext2 and ext4 both have PAGE_SIZE limits.
@@ -139,6 +148,10 @@ TEST(file, Readlink) {
@@ -265,6 +274,10 @@ TEST(file, Readlink) {
// in current kernels (and marlin/sailfish where we're seeing this
// failure are still on 3.18, far from current). http://b/33306057.
std::string max(static_cast<size_t>(4096 - 2 - 1 - 1), 'x');
Expand Down
36 changes: 36 additions & 0 deletions devel/android-tools-adb/files/patch-liblog_logger__write.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--- liblog/logger_write.cpp.orig 2020-02-11 20:44:45 UTC
+++ liblog/logger_write.cpp
@@ -51,6 +51,16 @@
#include <syscall.h>
#elif defined(_WIN32)
#include <windows.h>
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+#include <pthread_np.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
+#elif defined(__OpenBSD__)
+#include <unistd.h>
+#elif defined(__sun)
+#include <thread.h>
+#else // fallback
+#include <stdint.h>
#endif

using android::base::ErrnoRestorer;
@@ -248,6 +258,16 @@ static uint64_t GetThreadId() {
return syscall(__NR_gettid);
#elif defined(_WIN32)
return GetCurrentThreadId();
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+ return pthread_getthreadid_np();
+#elif defined(__NetBSD__)
+ return _lwp_self();
+#elif defined(__OpenBSD__)
+ return getthrid();
+#elif defined(__sun)
+ return thr_self();
+#else // fallback
+ return (intptr_t) pthread_self();
#endif
}

2 changes: 1 addition & 1 deletion devel/android-tools-fastboot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
PORTNAME= android-tools-fastboot
DISTVERSIONPREFIX= platform-tools-
DISTVERSION?= 29.0.6
PORTREVISION?= 0
PORTREVISION?= 1
CATEGORIES= devel sysutils
MASTER_SITES= https://salsa.debian.org/android-tools-team/android-tools/raw/706e754/debian/:manpage
DISTFILES= fastboot.1:manpage
Expand Down
36 changes: 36 additions & 0 deletions devel/android-tools-fastboot/files/patch-liblog_logger__write.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--- liblog/logger_write.cpp.orig 2020-02-11 20:44:45 UTC
+++ liblog/logger_write.cpp
@@ -51,6 +51,16 @@
#include <syscall.h>
#elif defined(_WIN32)
#include <windows.h>
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+#include <pthread_np.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
+#elif defined(__OpenBSD__)
+#include <unistd.h>
+#elif defined(__sun)
+#include <thread.h>
+#else // fallback
+#include <stdint.h>
#endif

using android::base::ErrnoRestorer;
@@ -248,6 +258,16 @@ static uint64_t GetThreadId() {
return syscall(__NR_gettid);
#elif defined(_WIN32)
return GetCurrentThreadId();
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+ return pthread_getthreadid_np();
+#elif defined(__NetBSD__)
+ return _lwp_self();
+#elif defined(__OpenBSD__)
+ return getthrid();
+#elif defined(__sun)
+ return thr_self();
+#else // fallback
+ return (intptr_t) pthread_self();
#endif
}

0 comments on commit 21a1537

Please sign in to comment.