@@ -70,6 +70,40 @@ static int s_test_thread_creation_join_fn(struct aws_allocator *allocator, void
70
70
71
71
AWS_TEST_CASE (thread_creation_join_test , s_test_thread_creation_join_fn )
72
72
73
+ static int s_test_thread_creation_join_invalid_cpu_id_fn (struct aws_allocator * allocator , void * ctx ) {
74
+ (void )ctx ;
75
+ aws_common_library_init (allocator );
76
+ struct thread_test_data test_data = {.allocator = allocator };
77
+
78
+ struct aws_thread thread ;
79
+ aws_thread_init (& thread , allocator );
80
+
81
+ struct aws_thread_options thread_options = * aws_default_thread_options ();
82
+ /* invalid cpu_id. Ensure that the cpu_id is best-effort based. */
83
+ thread_options .cpu_id = 4096 ;
84
+
85
+ ASSERT_SUCCESS (
86
+ aws_thread_launch (& thread , s_thread_fn , (void * )& test_data , & thread_options ), "thread creation failed" );
87
+ ASSERT_INT_EQUALS (
88
+ AWS_THREAD_JOINABLE , aws_thread_get_detach_state (& thread ), "thread state should have returned JOINABLE" );
89
+ ASSERT_SUCCESS (aws_thread_join (& thread ), "thread join failed" );
90
+ ASSERT_TRUE (
91
+ aws_thread_thread_id_equal (test_data .thread_id , aws_thread_get_id (& thread )),
92
+ "get_thread_id should have returned the same id as the thread calling current_thread_id" );
93
+ ASSERT_INT_EQUALS (
94
+ AWS_THREAD_JOIN_COMPLETED ,
95
+ aws_thread_get_detach_state (& thread ),
96
+ "thread state should have returned JOIN_COMPLETED" );
97
+
98
+ aws_string_destroy (test_data .thread_name );
99
+ aws_thread_clean_up (& thread );
100
+ aws_common_library_clean_up ();
101
+
102
+ return 0 ;
103
+ }
104
+
105
+ AWS_TEST_CASE (thread_creation_join_invalid_cpu_id_test , s_test_thread_creation_join_invalid_cpu_id_fn )
106
+
73
107
static uint32_t s_atexit_call_count = 0 ;
74
108
static void s_thread_atexit_fn (void * user_data ) {
75
109
(void )user_data ;
0 commit comments