From 233e26e1f90b640f2ecb997435aec0ed2ad2617f Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 28 Feb 2025 21:05:55 +0800 Subject: [PATCH] Adapt process-tests to Android * src/android.c (android_init_thread_events) (android_run_select_thread): Guarantee that the select thread is initialized before returning. * test/src/process-tests.el (process-tests/fd-setsize-no-crash/make-process) (process-tests/fd-setsize-no-crash/make-pipe-process) (process-tests/fd-setsize-no-crash/make-network-process) (process-tests/fd-setsize-no-crash/make-serial-process): Skip on Android. (cherry picked from commit 18c8c44bef9b85adf3cff65f08b7f6a8c59687db) --- src/android.c | 9 +++++++++ test/src/process-tests.el | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/android.c b/src/android.c index 15edca94fdf..b7d68def467 100644 --- a/src/android.c +++ b/src/android.c @@ -388,6 +388,10 @@ android_init_thread_events (struct android_thread_event_queue *thread) strerror (errno)); emacs_abort (); } + + /* Wait for the thread to be initialized. */ + while (sem_wait (&thread->select_sem) < 0) + ;; } #ifdef THREADS_ENABLED @@ -521,6 +525,9 @@ android_run_select_thread (void *thread_data) inside pselect, a file descriptor is selected. Data is written to the file descriptor whenever select is supposed to return. */ + /* Release the user after initialization. */ + sem_post (&data->select_sem); + while (true) { /* Wait for the thread to be released. */ @@ -603,6 +610,8 @@ android_run_select_thread (void *thread_data) #ifdef THREADS_ENABLED pthread_setspecific (poll_thread_internal, thread_data); #endif /* THREADS_ENABLED */ + /* Release the user after initialization. */ + sem_post (&data->select_sem); while (true) { diff --git a/test/src/process-tests.el b/test/src/process-tests.el index 276e9af6ee1..6da960d1af0 100644 --- a/test/src/process-tests.el +++ b/test/src/process-tests.el @@ -663,6 +663,10 @@ FD_SETSIZE." (ert-deftest process-tests/fd-setsize-no-crash/make-process () "Check that Emacs doesn't crash when trying to use more than FD_SETSIZE file descriptors (Bug#24325)." + ;; Emacs is terminated on Android or aborts when the toolkit fails to + ;; allocate sufficient graphics buffer handles long before FD_SETSIZE + ;; is exceeded. + (skip-when (eq system-type 'android)) (with-timeout (60 (ert-fail "Test timed out")) (let ((cat (executable-find "cat"))) (skip-unless cat) @@ -708,6 +712,10 @@ FD_SETSIZE file descriptors (Bug#24325)." (ert-deftest process-tests/fd-setsize-no-crash/make-pipe-process () "Check that Emacs doesn't crash when trying to use more than FD_SETSIZE file descriptors (Bug#24325)." + ;; Emacs is terminated on Android or aborts when the toolkit fails to + ;; allocate sufficient graphics buffer handles long before FD_SETSIZE + ;; is exceeded. + (skip-when (eq system-type 'android)) (with-timeout (60 (ert-fail "Test timed out")) (process-tests--fd-setsize-test (process-tests--with-buffers buffers @@ -735,6 +743,10 @@ FD_SETSIZE file descriptors (Bug#24325)." (ert-deftest process-tests/fd-setsize-no-crash/make-network-process () "Check that Emacs doesn't crash when trying to use more than FD_SETSIZE file descriptors (Bug#24325)." + ;; Emacs is terminated on Android or aborts when the toolkit fails to + ;; allocate sufficient graphics buffer handles long before FD_SETSIZE + ;; is exceeded. + (skip-when (eq system-type 'android)) (skip-unless (featurep 'make-network-process '(:server t))) (skip-unless (featurep 'make-network-process '(:family local))) ;; Avoid hang due to connect/accept handshake on Cygwin (bug#49496). @@ -777,6 +789,10 @@ FD_SETSIZE file descriptors (Bug#24325)." (ert-deftest process-tests/fd-setsize-no-crash/make-serial-process () "Check that Emacs doesn't crash when trying to use more than FD_SETSIZE file descriptors (Bug#24325)." + ;; Emacs is terminated on Android or aborts when the toolkit fails to + ;; allocate sufficient graphics buffer handles long before FD_SETSIZE + ;; is exceeded. + (skip-when (eq system-type 'android)) ;; This test cannot be run if PTYs aren't supported. (skip-when (eq system-type 'windows-nt)) (with-timeout (60 (ert-fail "Test timed out")) -- 2.39.5