@@ -32,47 +32,86 @@ static inline uint64_t cycle_get_64(void)
32
32
}
33
33
}
34
34
35
+ static uint32_t trace_idx ;
36
+ static uint32_t trace_cycle ;
37
+
38
+ static void trace_test_reset (void )
39
+ {
40
+ trace_idx = 0 ;
41
+ trace_cycle = cycle_get_64 ();
42
+ }
43
+
44
+ static void trace_test (void )
45
+ {
46
+ uint64_t cycle ;
47
+ uint64_t delta_cycle ;
48
+
49
+ cycle = cycle_get_64 ();
50
+ delta_cycle = cycle - trace_cycle ;
51
+ trace_cycle = cycle ;
52
+
53
+ TC_PRINT ("idx: %u, cycle: %llu, delta: %llu\n" , trace_idx , cycle , delta_cycle );
54
+ trace_idx ++ ;
55
+ }
56
+
35
57
static void common_errors (int selection , clockid_t clock_id , int flags )
36
58
{
37
59
struct timespec rem = {};
38
60
struct timespec req = {};
39
61
62
+ trace_test ();
63
+
40
64
/*
41
65
* invalid parameters
42
66
*/
43
67
zassert_equal (select_nanosleep (selection , clock_id , flags , NULL , NULL ), -1 );
44
68
zassert_equal (errno , EFAULT );
45
69
70
+ trace_test ();
71
+
46
72
/* NULL request */
47
73
errno = 0 ;
48
74
zassert_equal (select_nanosleep (selection , clock_id , flags , NULL , & rem ), -1 );
49
75
zassert_equal (errno , EFAULT );
76
+
77
+ trace_test ();
78
+
50
79
/* Expect rem to be the same when function returns */
51
80
zassert_equal (rem .tv_sec , 0 , "actual: %d expected: %d" , rem .tv_sec , 0 );
52
81
zassert_equal (rem .tv_nsec , 0 , "actual: %d expected: %d" , rem .tv_nsec , 0 );
53
82
83
+ trace_test ();
84
+
54
85
/* negative times */
55
86
errno = 0 ;
56
87
req = (struct timespec ){.tv_sec = -1 , .tv_nsec = 0 };
57
88
zassert_equal (select_nanosleep (selection , clock_id , flags , & req , NULL ), -1 );
58
89
zassert_equal (errno , EINVAL );
59
90
91
+ trace_test ();
92
+
60
93
errno = 0 ;
61
94
req = (struct timespec ){.tv_sec = 0 , .tv_nsec = -1 };
62
95
zassert_equal (select_nanosleep (selection , clock_id , flags , & req , NULL ), -1 );
63
96
zassert_equal (errno , EINVAL );
64
97
98
+ trace_test ();
99
+
65
100
errno = 0 ;
66
101
req = (struct timespec ){.tv_sec = -1 , .tv_nsec = -1 };
67
102
zassert_equal (select_nanosleep (selection , clock_id , flags , & req , NULL ), -1 );
68
103
zassert_equal (errno , EINVAL );
69
104
105
+ trace_test ();
106
+
70
107
/* nanoseconds too high */
71
108
errno = 0 ;
72
109
req = (struct timespec ){.tv_sec = 0 , .tv_nsec = 1000000000 };
73
110
zassert_equal (select_nanosleep (selection , clock_id , flags , & req , NULL ), -1 );
74
111
zassert_equal (errno , EINVAL );
75
112
113
+ trace_test ();
114
+
76
115
/*
77
116
* Valid parameters
78
117
*/
@@ -85,12 +124,16 @@ static void common_errors(int selection, clockid_t clock_id, int flags)
85
124
zassert_equal (req .tv_sec , 1 );
86
125
zassert_equal (req .tv_nsec , 1 );
87
126
127
+ trace_test ();
128
+
88
129
/* Sleep for 0.0 s. Expect req & rem to be the same when function returns */
89
130
zassert_equal (select_nanosleep (selection , clock_id , flags , & req , & rem ), 0 );
90
131
zassert_equal (errno , 0 );
91
132
zassert_equal (rem .tv_sec , 0 , "actual: %d expected: %d" , rem .tv_sec , 0 );
92
133
zassert_equal (rem .tv_nsec , 0 , "actual: %d expected: %d" , rem .tv_nsec , 0 );
93
134
135
+ trace_test ();
136
+
94
137
/*
95
138
* req and rem point to the same timespec
96
139
*
@@ -102,10 +145,13 @@ static void common_errors(int selection, clockid_t clock_id, int flags)
102
145
zassert_equal (errno , 0 );
103
146
zassert_equal (req .tv_sec , 0 , "actual: %d expected: %d" , req .tv_sec , 0 );
104
147
zassert_equal (req .tv_nsec , 0 , "actual: %d expected: %d" , req .tv_nsec , 0 );
148
+
149
+ trace_test ();
105
150
}
106
151
107
152
ZTEST (nanosleep , test_nanosleep_errors_errno )
108
153
{
154
+ trace_test_reset ();
109
155
common_errors (SELECT_NANOSLEEP , CLOCK_REALTIME , 0 );
110
156
}
111
157
@@ -114,19 +160,26 @@ ZTEST(nanosleep, test_clock_nanosleep_errors_errno)
114
160
struct timespec rem = {};
115
161
struct timespec req = {};
116
162
163
+ trace_test_reset ();
117
164
common_errors (SELECT_CLOCK_NANOSLEEP , CLOCK_MONOTONIC , TIMER_ABSTIME );
118
165
166
+ trace_test ();
167
+
119
168
/* Absolute timeout in the past. */
120
169
clock_gettime (CLOCK_MONOTONIC , & req );
121
170
zassert_equal (clock_nanosleep (CLOCK_MONOTONIC , TIMER_ABSTIME , & req , & rem ), 0 );
122
171
zassert_equal (rem .tv_sec , 0 , "actual: %d expected: %d" , rem .tv_sec , 0 );
123
172
zassert_equal (rem .tv_nsec , 0 , "actual: %d expected: %d" , rem .tv_nsec , 0 );
124
173
174
+ trace_test ();
175
+
125
176
/* Absolute timeout in the past relative to the realtime clock. */
126
177
clock_gettime (CLOCK_REALTIME , & req );
127
178
zassert_equal (clock_nanosleep (CLOCK_REALTIME , TIMER_ABSTIME , & req , & rem ), 0 );
128
179
zassert_equal (rem .tv_sec , 0 , "actual: %d expected: %d" , rem .tv_sec , 0 );
129
180
zassert_equal (rem .tv_nsec , 0 , "actual: %d expected: %d" , rem .tv_nsec , 0 );
181
+
182
+ trace_test ();
130
183
}
131
184
132
185
/**
0 commit comments