@@ -351,20 +351,23 @@ TEST_CASE("eventfd multiple selects", "[vfs][eventfd]")
351351}
352352
353353typedef struct {
354- int * value ;
354+ QueueHandle_t queue ;
355355 int fd ;
356356} select_block_task_args_t ;
357357
358358static void select_block_task (void * arg )
359359{
360- int fd = ((select_block_task_args_t * )arg )-> fd ;
360+ select_block_task_args_t * select_arg = (select_block_task_args_t * )arg ;
361+ int fd = select_arg -> fd ;
361362 fd_set read_fds ;
362363
363364 FD_ZERO (& read_fds );
364365 FD_SET (fd , & read_fds );
365366
366- select (fd + 1 , & read_fds , NULL , NULL , NULL );
367- * (((select_block_task_args_t * )arg )-> value ) = 1 ;
367+ int val = select (fd + 1 , & read_fds , NULL , NULL , NULL );
368+ assert (val == 1 );
369+ bool is_selected = true;
370+ xQueueSend (select_arg -> queue , & is_selected , 0 );
368371 vTaskDelete (NULL );
369372}
370373
@@ -376,20 +379,20 @@ TEST_CASE("eventfd select block", "[vfs][eventfd]")
376379 select_block_task_args_t args ;
377380 args .fd = eventfd (0 , 0 );
378381 TEST_ASSERT_GREATER_OR_EQUAL (0 , args .fd );
379- int a = 0 ;
380- args .value = & a ;
382+ args .queue = xQueueCreate (1 , sizeof (bool ));
381383
382384 int fd_write = eventfd (0 , 0 );
383385 TEST_ASSERT_GREATER_OR_EQUAL (0 , fd_write );
384386
385387 xTaskCreate (select_block_task , "select_block_task" , 2048 , & args , 5 , NULL );
386- vTaskDelay (pdMS_TO_TICKS (2000 ));
387388
389+ bool is_selected = false;
388390 uint64_t val = 1 ;
389391 TEST_ASSERT_EQUAL (sizeof (val ), write (fd_write , & val , sizeof (val )));
390- vTaskDelay (pdMS_TO_TICKS (2000 ));
391-
392- TEST_ASSERT_EQUAL (0 , * (args .value ));
392+ TEST_ASSERT (!xQueueReceive (args .queue , & is_selected , pdMS_TO_TICKS (2000 )));
393+ TEST_ASSERT_EQUAL (sizeof (val ), write (args .fd , & val , sizeof (val )));
394+ TEST_ASSERT (xQueueReceive (args .queue , & is_selected , pdMS_TO_TICKS (1000 )));
395+ TEST_ASSERT_EQUAL (true, is_selected );
393396 TEST_ASSERT_EQUAL (0 , close (args .fd ));
394397 TEST_ASSERT_EQUAL (0 , close (fd_write ));
395398 TEST_ESP_OK (esp_vfs_eventfd_unregister ());
0 commit comments