From 4d34dd9db01dc25a7c21ea5065cab6fadd392256 Mon Sep 17 00:00:00 2001 From: xiaomings Date: Mon, 29 Apr 2024 17:40:01 -0700 Subject: [PATCH 1/3] [media] Add UMA metrics for color space info (#3109) Now primaries, transfer, matrix, and range ids for both SDR and HDR playbacks are reported to UMA. b/322027866 Change-Id: Id58f73684404a5d8fc1051ca5a4c6b6083c8ff19 --- cobalt/media/base/sbplayer_bridge.cc | 20 ++++++ cobalt/media/base/sbplayer_bridge.h | 1 + .../histograms/metadata/cobalt/enums.xml | 71 +++++++++++++++++++ .../histograms/metadata/cobalt/histograms.xml | 68 ++++++++++++++++++ 4 files changed, 160 insertions(+) diff --git a/cobalt/media/base/sbplayer_bridge.cc b/cobalt/media/base/sbplayer_bridge.cc index 5d2bbe498457..0e5847119fdd 100644 --- a/cobalt/media/base/sbplayer_bridge.cc +++ b/cobalt/media/base/sbplayer_bridge.cc @@ -23,6 +23,7 @@ #include "base/compiler_specific.h" #include "base/location.h" #include "base/logging.h" +#include "base/metrics/histogram_functions.h" #include "base/trace_event/trace_event.h" #include "cobalt/base/statistics.h" #include "cobalt/media/base/format_support_query_metrics.h" @@ -273,6 +274,7 @@ SbPlayerBridge::SbPlayerBridge( } if (video_config.IsValidConfig()) { UpdateVideoConfig(video_config, video_mime_type); + SendColorSpaceHistogram(); } output_mode_ = ComputeSbPlayerOutputMode(default_output_mode); @@ -1360,5 +1362,23 @@ void SbPlayerBridge::LogStartupLatency() const { // clang-format on } +void SbPlayerBridge::SendColorSpaceHistogram() const { + using base::UmaHistogramEnumeration; + + const auto& cs_info = video_config_.color_space_info(); + + if (video_stream_info_.color_metadata.bits_per_channel > 8) { + UmaHistogramEnumeration("Cobalt.Media.HDR.Primaries", cs_info.primaries); + UmaHistogramEnumeration("Cobalt.Media.HDR.Transfer", cs_info.transfer); + UmaHistogramEnumeration("Cobalt.Media.HDR.Matrix", cs_info.matrix); + UmaHistogramEnumeration("Cobalt.Media.HDR.Range", cs_info.range); + } else { + UmaHistogramEnumeration("Cobalt.Media.SDR.Primaries", cs_info.primaries); + UmaHistogramEnumeration("Cobalt.Media.SDR.Transfer", cs_info.transfer); + UmaHistogramEnumeration("Cobalt.Media.SDR.Matrix", cs_info.matrix); + UmaHistogramEnumeration("Cobalt.Media.SDR.Range", cs_info.range); + } +} + } // namespace media } // namespace cobalt diff --git a/cobalt/media/base/sbplayer_bridge.h b/cobalt/media/base/sbplayer_bridge.h index 147a2174f22c..f6cc6879c12b 100644 --- a/cobalt/media/base/sbplayer_bridge.h +++ b/cobalt/media/base/sbplayer_bridge.h @@ -245,6 +245,7 @@ class SbPlayerBridge { SbPlayerOutputMode default_output_mode) const; void LogStartupLatency() const; + void SendColorSpaceHistogram() const; // The following variables are initialized in the ctor and never changed. #if SB_HAS(PLAYER_WITH_URL) diff --git a/tools/metrics/histograms/metadata/cobalt/enums.xml b/tools/metrics/histograms/metadata/cobalt/enums.xml index f54fc6fdc46a..17bce4975980 100644 --- a/tools/metrics/histograms/metadata/cobalt/enums.xml +++ b/tools/metrics/histograms/metadata/cobalt/enums.xml @@ -69,6 +69,77 @@ https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histogra + + + Possible primary ids reported by the Media Pipeline + + + + + + + + + + + + + + + + + + + Possible transfer ids reported by the Media Pipeline + + + + + + + + + + + + + + + + + + + + + + + + Possible matrix ids reported by the Media Pipeline + + + + + + + + + + + + + + + + + + Possible range ids reported by the Media Pipeline + + + + + + + Possible status of Crashpad installation by the Loader App diff --git a/tools/metrics/histograms/metadata/cobalt/histograms.xml b/tools/metrics/histograms/metadata/cobalt/histograms.xml index 196672dee12b..29323aafae69 100644 --- a/tools/metrics/histograms/metadata/cobalt/histograms.xml +++ b/tools/metrics/histograms/metadata/cobalt/histograms.xml @@ -131,6 +131,40 @@ Always run the pretty print utility on this file after editing: + + + + xiaomings@google.com + cobalt-team@google.com + Matrix id used in HDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Primary id used in HDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Range id used in HDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Transfer id used in HDR playbacks. + + @@ -260,6 +294,40 @@ Always run the pretty print utility on this file after editing: Timing data for the destruction of SbPlayer. + + + + xiaomings@google.com + cobalt-team@google.com + Matrix id used in SDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Primary id used in SDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Range id used in SDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Transfer id used in SDR playbacks. + + From 86ca328c3ac721e93fb26d1616e90ff0d92cea76 Mon Sep 17 00:00:00 2001 From: Yavor Goulishev Date: Tue, 30 Apr 2024 02:08:54 +0000 Subject: [PATCH 2/3] Switch the posix_compliance tests to use pthread_create (#3107) b/302335657 Test-On-Device: true Change-Id: I785845e79e1954e81e77eac8dac2d6fc853d2c24 --- .../posix_condition_variable_wait_test.cc | 15 ++++++------ ...osix_condition_variable_wait_timed_test.cc | 14 +++++------ .../posix_mutex_acquire_test.cc | 7 +++--- .../posix_mutex_acquire_try_test.cc | 11 ++++----- .../nplb/posix_compliance/posix_once_test.cc | 10 ++++---- .../posix_socket_send_test.cc | 12 ++++++---- .../posix_socket_sendto_test.cc | 12 ++++++---- .../posix_compliance/posix_thread_helpers.h | 22 +++++++---------- .../posix_thread_local_value_test.cc | 24 ++++++++----------- 9 files changed, 58 insertions(+), 69 deletions(-) diff --git a/starboard/nplb/posix_compliance/posix_condition_variable_wait_test.cc b/starboard/nplb/posix_compliance/posix_condition_variable_wait_test.cc index fb27b0c9dc13..9ef64325ada4 100644 --- a/starboard/nplb/posix_compliance/posix_condition_variable_wait_test.cc +++ b/starboard/nplb/posix_compliance/posix_condition_variable_wait_test.cc @@ -47,9 +47,8 @@ TEST(PosixConditionVariableWaitTest, SunnyDayAutoInit) { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER}; // Start the thread. - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - posix::TakeThenSignalEntryPoint, &context); + pthread_t thread = 0; + pthread_create(&thread, NULL, posix::TakeThenSignalEntryPoint, &context); EXPECT_EQ(pthread_mutex_lock(&context.mutex), 0); @@ -65,7 +64,7 @@ TEST(PosixConditionVariableWaitTest, SunnyDayAutoInit) { EXPECT_EQ(pthread_mutex_unlock(&context.mutex), 0); // Now we wait for the thread to exit. - EXPECT_TRUE(SbThreadJoin(thread, NULL)); + EXPECT_TRUE(pthread_join(thread, NULL) == 0); EXPECT_EQ(pthread_cond_destroy(&context.condition), 0); EXPECT_EQ(pthread_mutex_destroy(&context.mutex), 0); } @@ -74,10 +73,9 @@ TEST(PosixConditionVariableWaitTest, SunnyDay) { const int kMany = kSbMaxThreads > 64 ? 64 : kSbMaxThreads; posix::WaiterContext context; - std::vector threads(kMany); + std::vector threads(kMany); for (int i = 0; i < kMany; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, posix::WaiterEntryPoint, &context); + pthread_create(&threads[i], NULL, posix::WaiterEntryPoint, &context); } for (int i = 0; i < kMany; ++i) { @@ -89,7 +87,8 @@ TEST(PosixConditionVariableWaitTest, SunnyDay) { // Now we wait for the threads to exit. for (int i = 0; i < kMany; ++i) { - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)) << "thread = " << threads[i]; + EXPECT_TRUE(pthread_join(threads[i], NULL) == 0) + << "thread = " << threads[i]; } } diff --git a/starboard/nplb/posix_compliance/posix_condition_variable_wait_timed_test.cc b/starboard/nplb/posix_compliance/posix_condition_variable_wait_timed_test.cc index 442e8c74ae54..c4aacf30b275 100644 --- a/starboard/nplb/posix_compliance/posix_condition_variable_wait_timed_test.cc +++ b/starboard/nplb/posix_compliance/posix_condition_variable_wait_timed_test.cc @@ -98,9 +98,8 @@ struct timespec CalculateDelayTimestamp(int64_t delay, bool use_monotonic) { void DoSunnyDay(posix::TakeThenSignalContext* context, bool check_timeout, bool use_monotonic) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - posix::TakeThenSignalEntryPoint, context); + pthread_t thread = 0; + pthread_create(&thread, NULL, posix::TakeThenSignalEntryPoint, context); const int64_t kDelayUs = 10'000; // 10ms // Allow two-millisecond-level precision. @@ -156,7 +155,7 @@ void DoSunnyDay(posix::TakeThenSignalContext* context, } // Now we wait for the thread to exit. - EXPECT_TRUE(SbThreadJoin(thread, NULL)); + EXPECT_TRUE(pthread_join(thread, NULL) == 0); EXPECT_EQ(pthread_cond_destroy(&context->condition), 0); EXPECT_EQ(pthread_mutex_destroy(&context->mutex), 0); } @@ -212,9 +211,8 @@ TEST(PosixConditionVariableWaitTimedTest, FLAKY_SunnyDayNearMaxTime) { EXPECT_EQ(pthread_mutex_init(&context.mutex, NULL), 0); InitCondition(&context.condition, false /* use_monotonic */); - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - posix::TakeThenSignalEntryPoint, &context); + pthread_t thread = 0; + pthread_create(&thread, NULL, posix::TakeThenSignalEntryPoint, &context); EXPECT_EQ(pthread_mutex_lock(&context.mutex), 0); @@ -243,7 +241,7 @@ TEST(PosixConditionVariableWaitTimedTest, FLAKY_SunnyDayNearMaxTime) { EXPECT_EQ(pthread_mutex_unlock(&context.mutex), 0); // Now we wait for the thread to exit. - EXPECT_TRUE(SbThreadJoin(thread, NULL)); + EXPECT_TRUE(pthread_join(thread, NULL) == 0); EXPECT_EQ(pthread_cond_destroy(&context.condition), 0); EXPECT_EQ(pthread_mutex_destroy(&context.mutex), 0); } diff --git a/starboard/nplb/posix_compliance/posix_mutex_acquire_test.cc b/starboard/nplb/posix_compliance/posix_mutex_acquire_test.cc index 1eb479616581..b768e4f5922a 100644 --- a/starboard/nplb/posix_compliance/posix_mutex_acquire_test.cc +++ b/starboard/nplb/posix_compliance/posix_mutex_acquire_test.cc @@ -48,10 +48,9 @@ TEST(PosixMutexAcquireTest, SunnyDayContended) { TestContext context; EXPECT_EQ(pthread_mutex_init(&context.mutex, NULL), 0); const int kThreads = 4; - SbThread threads[kThreads]; + pthread_t threads[kThreads]; for (int i = 0; i < kThreads; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, EntryPoint, &context); + pthread_create(&threads[i], NULL, EntryPoint, &context); } for (int i = 0; i < kLoops; ++i) { @@ -64,7 +63,7 @@ TEST(PosixMutexAcquireTest, SunnyDayContended) { // Join other threads and clean up. for (int i = 0; i < kThreads; ++i) { - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)); + EXPECT_TRUE(pthread_join(threads[i], NULL) == 0); } EXPECT_EQ(pthread_mutex_destroy(&context.mutex), 0); EXPECT_EQ(0, context.count); diff --git a/starboard/nplb/posix_compliance/posix_mutex_acquire_try_test.cc b/starboard/nplb/posix_compliance/posix_mutex_acquire_try_test.cc index 104654e76426..40a9458aeff3 100644 --- a/starboard/nplb/posix_compliance/posix_mutex_acquire_try_test.cc +++ b/starboard/nplb/posix_compliance/posix_mutex_acquire_try_test.cc @@ -32,6 +32,7 @@ struct TestContext { }; void* EntryPoint(void* parameter) { + pthread_setname_np(pthread_self(), nplb::kThreadName); TestContext* context = static_cast(parameter); context->was_locked_ = (pthread_mutex_trylock(context->mutex_) == 0); return NULL; @@ -60,13 +61,11 @@ TEST(PosixMutexAcquireTryTest, RainyDayReentrant) { EXPECT_EQ(pthread_mutex_trylock(&mutex), 0); TestContext context(&mutex); - // TODO: Migrate to pthread_create when available. - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - nplb::kThreadName, &EntryPoint, &context); + pthread_t thread = 0; + pthread_create(&thread, NULL, &EntryPoint, &context); - EXPECT_TRUE(SbThreadIsValid(thread)); - EXPECT_TRUE(SbThreadJoin(thread, NULL)); + EXPECT_TRUE(thread != 0); + EXPECT_TRUE(pthread_join(thread, NULL) == 0); EXPECT_FALSE(context.was_locked_); EXPECT_EQ(pthread_mutex_unlock(&mutex), 0); EXPECT_EQ(pthread_mutex_destroy(&mutex), 0); diff --git a/starboard/nplb/posix_compliance/posix_once_test.cc b/starboard/nplb/posix_compliance/posix_once_test.cc index d0eed7a34b37..dd3bf87756c6 100644 --- a/starboard/nplb/posix_compliance/posix_once_test.cc +++ b/starboard/nplb/posix_compliance/posix_once_test.cc @@ -73,6 +73,8 @@ struct RunPosixOnceContext { }; void* RunPosixOnceEntryPoint(void* context) { + pthread_setname_np(pthread_self(), posix::kThreadName); + RunPosixOnceContext* run_sbonce_context = reinterpret_cast(context); @@ -98,7 +100,7 @@ void* RunPosixOnceEntryPoint(void* context) { // initialization routine got called exactly one time. TEST(PosixOnceTest, SunnyDayMultipleThreadsInit) { const int kMany = kSbMaxThreads; - std::vector threads(kMany); + std::vector threads(kMany); const int kIterationCount = 10; for (int i = 0; i < kIterationCount; ++i) { @@ -107,9 +109,7 @@ TEST(PosixOnceTest, SunnyDayMultipleThreadsInit) { s_global_value = 0; for (int j = 0; j < kMany; ++j) { - threads[j] = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - posix::kThreadName, RunPosixOnceEntryPoint, &context); + pthread_create(&threads[j], NULL, RunPosixOnceEntryPoint, &context); } // Wait for all threads to finish initializing and become ready, then @@ -127,7 +127,7 @@ TEST(PosixOnceTest, SunnyDayMultipleThreadsInit) { // Signal threads to beginWait for all threads to complete. for (int i = 0; i < kMany; ++i) { void* result; - SbThreadJoin(threads[i], &result); + pthread_join(threads[i], &result); } EXPECT_EQ(s_global_value, 1); diff --git a/starboard/nplb/posix_compliance/posix_socket_send_test.cc b/starboard/nplb/posix_compliance/posix_socket_send_test.cc index 218b83cc1628..668fbd239832 100644 --- a/starboard/nplb/posix_compliance/posix_socket_send_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_send_test.cc @@ -16,6 +16,7 @@ // this is hooked up to something. #include +#include #include #include "starboard/nplb/posix_compliance/posix_socket_helpers.h" #include "starboard/thread.h" @@ -40,6 +41,8 @@ void* PosixSocketSendToServerSocketEntryPoint(void* trio_as_void_ptr) { char* send_buf = new char[kBufSize]; memset(send_buf, 0, kBufSize); + pthread_setname_np(pthread_self(), "SendToTest"); + // Continue sending to the socket until it fails to send. It's expected that // SbSocketSendTo will fail when the server socket closes, but the application // should not terminate. @@ -95,17 +98,16 @@ TEST(PosixSocketSendTest, RainyDaySendToClosedSocket) { // Start a thread to write to the client socket. const bool kJoinable = true; - SbThread send_thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, kJoinable, - "SendToTest", PosixSocketSendToServerSocketEntryPoint, - static_cast(&trio_as_void_ptr)); + pthread_t send_thread = 0; + pthread_create(&send_thread, NULL, PosixSocketSendToServerSocketEntryPoint, + static_cast(&trio_as_void_ptr)); // Close the client, which should cause writes to the server socket to fail. EXPECT_TRUE(close(client_socket_fd) == 0); // Wait for the thread to exit and check the last socket error. void* thread_result; - EXPECT_TRUE(SbThreadJoin(send_thread, &thread_result)); + EXPECT_TRUE(pthread_join(send_thread, &thread_result) == 0); // TODO: errno: EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno // == EPIPE); diff --git a/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc b/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc index bb988ba9227a..5405e5e0e281 100644 --- a/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc @@ -16,6 +16,7 @@ // this is hooked up to something. #include +#include #include #include "starboard/nplb/posix_compliance/posix_socket_helpers.h" @@ -41,6 +42,8 @@ void* PosixSocketSendToServerSocketEntryPoint(void* trio_as_void_ptr) { char* send_buf = new char[kBufSize]; memset(send_buf, 0, kBufSize); + pthread_setname_np(pthread_self(), "SendToTest"); + // Continue sending to the socket until it fails to send. It's expected that // SbSocketSendTo will fail when the server socket closes, but the application // should not terminate. @@ -98,17 +101,16 @@ TEST(PosixSocketSendtoTest, RainyDaySendToClosedSocket) { // Start a thread to write to the client socket. const bool kJoinable = true; - SbThread send_thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, kJoinable, - "SendToTest", PosixSocketSendToServerSocketEntryPoint, - static_cast(&trio_as_void_ptr)); + pthread_t send_thread = 0; + pthread_create(&send_thread, NULL, PosixSocketSendToServerSocketEntryPoint, + static_cast(&trio_as_void_ptr)); // Close the client, which should cause writes to the server socket to fail. EXPECT_TRUE(close(client_socket_fd) == 0); // Wait for the thread to exit and check the last socket error. void* thread_result; - EXPECT_TRUE(SbThreadJoin(send_thread, &thread_result)); + EXPECT_TRUE(pthread_join(send_thread, &thread_result) == 0); // TODO: errno: EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno // == EPIPE); diff --git a/starboard/nplb/posix_compliance/posix_thread_helpers.h b/starboard/nplb/posix_compliance/posix_thread_helpers.h index 9e085f53d5a7..b4a4d6ed7d18 100644 --- a/starboard/nplb/posix_compliance/posix_thread_helpers.h +++ b/starboard/nplb/posix_compliance/posix_thread_helpers.h @@ -158,44 +158,38 @@ struct TakeThenSignalContext { // thread. Subclasses must override Run(). class AbstractTestThread { public: - AbstractTestThread() : thread_(kSbThreadInvalid) {} + AbstractTestThread() : thread_(0) {} virtual ~AbstractTestThread() {} // Subclasses should override the Run method. virtual void Run() = 0; - // Calls SbThreadCreate() with default parameters. + // Calls pthread_create() with default parameters. void Start() { - SbThreadEntryPoint entry_point = ThreadEntryPoint; - - thread_ = SbThreadCreate(0, // default stack_size. - kSbThreadNoPriority, // default priority. - kSbThreadNoAffinity, // default affinity. - true, // joinable. - "AbstractTestThread", entry_point, this); - - if (kSbThreadInvalid == thread_) { + pthread_create(&thread_, NULL, ThreadEntryPoint, this); + if (0 == thread_) { ADD_FAILURE_AT(__FILE__, __LINE__) << "Invalid thread."; } return; } void Join() { - if (!SbThreadJoin(thread_, NULL)) { + if (pthread_join(thread_, NULL) != 0) { ADD_FAILURE_AT(__FILE__, __LINE__) << "Could not join thread."; } } - SbThread GetThread() { return thread_; } + pthread_t GetThread() { return thread_; } private: static void* ThreadEntryPoint(void* ptr) { + pthread_setname_np(pthread_self(), "AbstractTestThread"); AbstractTestThread* this_ptr = static_cast(ptr); this_ptr->Run(); return NULL; } - SbThread thread_; + pthread_t thread_; AbstractTestThread(const AbstractTestThread&) = delete; void operator=(const AbstractTestThread&) = delete; diff --git a/starboard/nplb/posix_compliance/posix_thread_local_value_test.cc b/starboard/nplb/posix_compliance/posix_thread_local_value_test.cc index 0d17e4e18138..cae57d6749d3 100644 --- a/starboard/nplb/posix_compliance/posix_thread_local_value_test.cc +++ b/starboard/nplb/posix_compliance/posix_thread_local_value_test.cc @@ -53,6 +53,7 @@ void* EntryPoint(void* context) { // Sets a thread local non-NULL value, and then sets it back to NULL. static void* ThreadEntryPoint(void* ptr) { + pthread_setname_np(pthread_self(), "TestThread"); pthread_key_t key = *static_cast(ptr); EXPECT_EQ(NULL, pthread_getspecific(key)); // Set the value and then NULL it out. We expect that because the final @@ -67,7 +68,7 @@ void DoSunnyDayTest(bool use_destructor) { const int kThreads = 16; ThreadLocalValue values[kThreads]; Context contexts[kThreads]; - SbThread threads[kThreads]; + pthread_t threads[kThreads]; ThreadLocalValue my_value; pthread_key_t key = 0; @@ -81,13 +82,12 @@ void DoSunnyDayTest(bool use_destructor) { } for (int i = 0; i < kThreads; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, EntryPoint, &contexts[i]); + pthread_create(&threads[i], NULL, EntryPoint, &contexts[i]); } for (int i = 0; i < kThreads; ++i) { - EXPECT_TRUE(SbThreadIsValid(threads[i])); - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)); + EXPECT_TRUE(threads[i] != 0); + EXPECT_TRUE(pthread_join(threads[i], NULL) == 0); EXPECT_EQ(contexts[i].in_value, contexts[i].out_value); // The destructor for all thread-local values will be called at thread exit @@ -132,16 +132,12 @@ TEST(PosixThreadLocalValueTest, NoDestructorsForNullValue) { EXPECT_EQ(NULL, pthread_getspecific(key)); // Spawn the thread. - SbThread thread = - SbThreadCreate(0, // Signals automatic thread stack size. - kSbThreadNoPriority, // Signals default priority. - kSbThreadNoAffinity, // Signals default affinity. - true, // joinable thread. - "TestThread", ThreadEntryPoint, static_cast(&key)); - - ASSERT_NE(kSbThreadInvalid, thread) << "Thread creation not successful"; + pthread_t thread = 0; + pthread_create(&thread, NULL, ThreadEntryPoint, static_cast(&key)); + + ASSERT_TRUE(thread != 0) << "Thread creation not successful"; // 2nd param is return value from ThreadEntryPoint, which is always NULL. - ASSERT_TRUE(SbThreadJoin(thread, NULL)); + ASSERT_TRUE(pthread_join(thread, NULL) == 0); // No destructors should have run. EXPECT_EQ(0, s_num_destructor_calls); From c21f78eac273eb4c45c4513b6c4125e63f717d03 Mon Sep 17 00:00:00 2001 From: Dana Dahlstrom Date: Tue, 30 Apr 2024 12:00:00 -0700 Subject: [PATCH 3/3] Move download_from_gcs to cobalt/tools This belongs to Cobalt; tools belongs to Chromium. Issue: 169056570 Reviewed-on: https://github.com/youtube/cobalt/pull/3114 --- .pre-commit-config.yaml | 3 +-- cobalt/media/testing/BUILD.gn | 2 +- cobalt/renderer/BUILD.gn | 2 +- {tools => cobalt/tools}/download_from_gcs.py | 0 {tools => cobalt/tools}/download_from_gcs_test.py | 2 +- .../tools}/testing/download_from_gcs/clang-format.sha1 | 0 .../testing/download_from_gcs/test_dir/clang-format.exe.sha1 | 0 .../testing/download_from_gcs/test_dir/clang-format.sha1 | 0 components/crx_file/BUILD.gn | 2 +- download_resources.py | 2 +- starboard/shared/starboard/player/BUILD.gn | 2 +- 11 files changed, 7 insertions(+), 8 deletions(-) rename {tools => cobalt/tools}/download_from_gcs.py (100%) rename {tools => cobalt/tools}/download_from_gcs_test.py (98%) rename {tools => cobalt/tools}/testing/download_from_gcs/clang-format.sha1 (100%) rename {tools => cobalt/tools}/testing/download_from_gcs/test_dir/clang-format.exe.sha1 (100%) rename {tools => cobalt/tools}/testing/download_from_gcs/test_dir/clang-format.sha1 (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 79b871fc3b58..c0093a3d3632 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,6 @@ files: | starboard| tools/metrics/actions/cobalt| tools/metrics/histograms/metadata/cobalt| - tools/testing| )/ | ^[^/]+$ # files in the root ) @@ -176,7 +175,7 @@ repos: pass_filenames: false always_run: true stages: [push] - args: [-m, unittest, tools/download_from_gcs_test.py] + args: [-m, unittest, cobalt/tools/download_from_gcs_test.py] - id: test-python3-compatibility name: Test Python 3 Compatibility description: Checks that scripts can be run in Python 3 diff --git a/cobalt/media/testing/BUILD.gn b/cobalt/media/testing/BUILD.gn index 0e0529c29690..49052ff3706e 100644 --- a/cobalt/media/testing/BUILD.gn +++ b/cobalt/media/testing/BUILD.gn @@ -17,7 +17,7 @@ import("//cobalt/media/testing/data/sha1_files.gni") action("cobalt_media_download_test_data") { install_content = true - script = "//tools/download_from_gcs.py" + script = "//cobalt/tools/download_from_gcs.py" sha_sources = [] foreach(sha1_file, sha1_files) { diff --git a/cobalt/renderer/BUILD.gn b/cobalt/renderer/BUILD.gn index e734036af6f5..140e187b46e8 100644 --- a/cobalt/renderer/BUILD.gn +++ b/cobalt/renderer/BUILD.gn @@ -502,7 +502,7 @@ copy("renderer_copy_lottie_test_data") { action("renderer_download_lottie_test_data") { install_content = true - script = "//tools/download_from_gcs.py" + script = "//cobalt/tools/download_from_gcs.py" inputs = [ "$_lottie_resource_path/finger_print-expected.png.sha1", diff --git a/tools/download_from_gcs.py b/cobalt/tools/download_from_gcs.py similarity index 100% rename from tools/download_from_gcs.py rename to cobalt/tools/download_from_gcs.py diff --git a/tools/download_from_gcs_test.py b/cobalt/tools/download_from_gcs_test.py similarity index 98% rename from tools/download_from_gcs_test.py rename to cobalt/tools/download_from_gcs_test.py index 6731305e84ac..120e77a0994a 100755 --- a/tools/download_from_gcs_test.py +++ b/cobalt/tools/download_from_gcs_test.py @@ -18,7 +18,7 @@ import tempfile import unittest -from tools import download_from_gcs +from cobalt.tools import download_from_gcs _BUCKET = 'chromium-clang-format' _HASH_FILE_EXT = '.sha1' diff --git a/tools/testing/download_from_gcs/clang-format.sha1 b/cobalt/tools/testing/download_from_gcs/clang-format.sha1 similarity index 100% rename from tools/testing/download_from_gcs/clang-format.sha1 rename to cobalt/tools/testing/download_from_gcs/clang-format.sha1 diff --git a/tools/testing/download_from_gcs/test_dir/clang-format.exe.sha1 b/cobalt/tools/testing/download_from_gcs/test_dir/clang-format.exe.sha1 similarity index 100% rename from tools/testing/download_from_gcs/test_dir/clang-format.exe.sha1 rename to cobalt/tools/testing/download_from_gcs/test_dir/clang-format.exe.sha1 diff --git a/tools/testing/download_from_gcs/test_dir/clang-format.sha1 b/cobalt/tools/testing/download_from_gcs/test_dir/clang-format.sha1 similarity index 100% rename from tools/testing/download_from_gcs/test_dir/clang-format.sha1 rename to cobalt/tools/testing/download_from_gcs/test_dir/clang-format.sha1 diff --git a/components/crx_file/BUILD.gn b/components/crx_file/BUILD.gn index 074de4c708a6..0614a146e2b5 100644 --- a/components/crx_file/BUILD.gn +++ b/components/crx_file/BUILD.gn @@ -35,7 +35,7 @@ if (is_starboard) { action("crx_file_download_test_data") { install_content = true - script = "//tools/download_from_gcs.py" + script = "//cobalt/tools/download_from_gcs.py" sha_sources = [] foreach(sha1_file, sha1_files) { diff --git a/download_resources.py b/download_resources.py index db26837815cc..3f5e6bdacbd5 100644 --- a/download_resources.py +++ b/download_resources.py @@ -22,7 +22,7 @@ except ImportError: import urllib2 as urllib -from tools import download_from_gcs +from cobalt.tools import download_from_gcs def DownloadGerritCommitMsgHook(force=False): diff --git a/starboard/shared/starboard/player/BUILD.gn b/starboard/shared/starboard/player/BUILD.gn index 46de5c9ecf40..25b786f71583 100644 --- a/starboard/shared/starboard/player/BUILD.gn +++ b/starboard/shared/starboard/player/BUILD.gn @@ -34,7 +34,7 @@ static_library("video_dmp") { action("player_download_test_data") { install_content = true - script = "//tools/download_from_gcs.py" + script = "//cobalt/tools/download_from_gcs.py" sha_sources = [] foreach(sha1_file, sha1_files) {