@@ -36,16 +36,11 @@ int __wrap_getsockopt(int fd, int level, int optname, void *optval, socklen_t *o
3636 return mock_type (int );
3737}
3838
39- // Mocked gettimeofday
40- int __wrap_gettimeofday ( struct timeval * time_Info , struct timezone * timezone_Info )
39+ // Mocked zend_time_mono_fallback
40+ uint64_t __wrap_zend_time_mono_fallback ( void )
4141{
4242 function_called ();
43- struct timeval * now = mock_ptr_type (struct timeval * );
44- if (now ) {
45- time_Info -> tv_sec = now -> tv_sec ;
46- time_Info -> tv_usec = now -> tv_usec ;
47- }
48- return mock_type (int );
43+ return mock_type (uint64_t );
4944}
5045
5146// Test successful connection
@@ -74,9 +69,8 @@ static void test_php_network_connect_socket_progress_success(void **state) {
7469 will_return (__wrap_connect , EINPROGRESS );
7570
7671 // Mock time setting - ignored
77- expect_function_call (__wrap_gettimeofday );
78- will_return (__wrap_gettimeofday , NULL );
79- will_return (__wrap_gettimeofday , 0 );
72+ expect_function_call (__wrap_zend_time_mono_fallback );
73+ will_return (__wrap_zend_time_mono_fallback , 0 );
8074
8175 // Mock poll to return success
8276 expect_function_call (__wrap_poll );
@@ -96,8 +90,8 @@ static void test_php_network_connect_socket_progress_success(void **state) {
9690
9791static void test_php_network_connect_socket_eintr_t1 (void * * state ) {
9892 struct timeval timeout_tv = { .tv_sec = 2 , .tv_usec = 500000 };
99- struct timeval start_time = { . tv_sec = 1000 , . tv_usec = 0 } ; // Initial time
100- struct timeval retry_time = { . tv_sec = 1001 , . tv_usec = 200000 } ; // Time after EINTR
93+ uint64_t start_time = 1000000000000 ; // Initial time
94+ uint64_t retry_time = 1001200000000 ; // Time after EINTR
10195 php_socket_t sockfd = 12 ;
10296 int error_code = 0 ;
10397
@@ -106,19 +100,17 @@ static void test_php_network_connect_socket_eintr_t1(void **state) {
106100 will_return (__wrap_connect , EINPROGRESS );
107101
108102 // Mock gettimeofday for initial call
109- expect_function_call (__wrap_gettimeofday );
110- will_return (__wrap_gettimeofday , & start_time );
111- will_return (__wrap_gettimeofday , 0 );
103+ expect_function_call (__wrap_zend_time_mono_fallback );
104+ will_return (__wrap_zend_time_mono_fallback , start_time );
112105
113106 // Mock poll to return EINTR first
114107 expect_function_call (__wrap_poll );
115108 expect_value (__wrap_poll , timeout , 2500 );
116109 will_return (__wrap_poll , - EINTR );
117110
118111 // Mock gettimeofday after EINTR
119- expect_function_call (__wrap_gettimeofday );
120- will_return (__wrap_gettimeofday , & retry_time );
121- will_return (__wrap_gettimeofday , 0 );
112+ expect_function_call (__wrap_zend_time_mono_fallback );
113+ will_return (__wrap_zend_time_mono_fallback , retry_time );
122114
123115 // Mock poll to succeed on retry
124116 expect_function_call (__wrap_poll );
@@ -139,8 +131,8 @@ static void test_php_network_connect_socket_eintr_t1(void **state) {
139131
140132static void test_php_network_connect_socket_eintr_t2 (void * * state ) {
141133 struct timeval timeout_tv = { .tv_sec = 2 , .tv_usec = 1500000 };
142- struct timeval start_time = { . tv_sec = 1000 , . tv_usec = 300000 } ; // Initial time
143- struct timeval retry_time = { . tv_sec = 1001 , . tv_usec = 200000 } ; // Time after EINTR
134+ uint64_t start_time = 1000300000000 ; // Initial time
135+ uint64_t retry_time = 1001200000000 ; // Time after EINTR
144136 php_socket_t sockfd = 12 ;
145137 int error_code = 0 ;
146138
@@ -149,19 +141,17 @@ static void test_php_network_connect_socket_eintr_t2(void **state) {
149141 will_return (__wrap_connect , EINPROGRESS );
150142
151143 // Mock gettimeofday for initial call
152- expect_function_call (__wrap_gettimeofday );
153- will_return (__wrap_gettimeofday , & start_time );
154- will_return (__wrap_gettimeofday , 0 );
144+ expect_function_call (__wrap_zend_time_mono_fallback );
145+ will_return (__wrap_zend_time_mono_fallback , start_time );
155146
156147 // Mock poll to return EINTR first
157148 expect_function_call (__wrap_poll );
158149 expect_value (__wrap_poll , timeout , 3500 );
159150 will_return (__wrap_poll , - EINTR );
160151
161152 // Mock gettimeofday after EINTR
162- expect_function_call (__wrap_gettimeofday );
163- will_return (__wrap_gettimeofday , & retry_time );
164- will_return (__wrap_gettimeofday , 0 );
153+ expect_function_call (__wrap_zend_time_mono_fallback );
154+ will_return (__wrap_zend_time_mono_fallback , retry_time );
165155
166156 // Mock poll to succeed on retry
167157 expect_function_call (__wrap_poll );
@@ -182,8 +172,8 @@ static void test_php_network_connect_socket_eintr_t2(void **state) {
182172
183173static void test_php_network_connect_socket_eintr_t3 (void * * state ) {
184174 struct timeval timeout_tv = { .tv_sec = 2 , .tv_usec = 500000 };
185- struct timeval start_time = { . tv_sec = 1002 , . tv_usec = 300000 } ; // Initial time
186- struct timeval retry_time = { . tv_sec = 1001 , . tv_usec = 2200000 } ; // Time after EINTR
175+ uint64_t start_time = 1002300000000 ; // Initial time
176+ uint64_t retry_time = 1003200000000 ; // Time after EINTR
187177 php_socket_t sockfd = 12 ;
188178 int error_code = 0 ;
189179
@@ -192,19 +182,17 @@ static void test_php_network_connect_socket_eintr_t3(void **state) {
192182 will_return (__wrap_connect , EINPROGRESS );
193183
194184 // Mock gettimeofday for initial call
195- expect_function_call (__wrap_gettimeofday );
196- will_return (__wrap_gettimeofday , & start_time );
197- will_return (__wrap_gettimeofday , 0 );
185+ expect_function_call (__wrap_zend_time_mono_fallback );
186+ will_return (__wrap_zend_time_mono_fallback , start_time );
198187
199188 // Mock poll to return EINTR first
200189 expect_function_call (__wrap_poll );
201190 expect_value (__wrap_poll , timeout , 2500 );
202191 will_return (__wrap_poll , - EINTR );
203192
204193 // Mock gettimeofday after EINTR
205- expect_function_call (__wrap_gettimeofday );
206- will_return (__wrap_gettimeofday , & retry_time );
207- will_return (__wrap_gettimeofday , 0 );
194+ expect_function_call (__wrap_zend_time_mono_fallback );
195+ will_return (__wrap_zend_time_mono_fallback , retry_time );
208196
209197 // Mock poll to succeed on retry
210198 expect_function_call (__wrap_poll );
0 commit comments