@@ -33,9 +33,20 @@ typedef long (*vdso_clock_gettime_t)(clockid_t clk_id, struct timespec *ts);
3333typedef long (* vdso_clock_getres_t )(clockid_t clk_id , struct timespec * ts );
3434typedef time_t (* vdso_time_t )(time_t * t );
3535
36- #define VDSO_TEST_PASS_MSG () "\n%s(): PASS\n", __func__
37- #define VDSO_TEST_FAIL_MSG (x ) "\n%s(): %s FAIL\n", __func__, x
38- #define VDSO_TEST_SKIP_MSG (x ) "\n%s(): SKIP: Could not find %s\n", __func__, x
36+ const char * vdso_clock_name [12 ] = {
37+ "CLOCK_REALTIME" ,
38+ "CLOCK_MONOTONIC" ,
39+ "CLOCK_PROCESS_CPUTIME_ID" ,
40+ "CLOCK_THREAD_CPUTIME_ID" ,
41+ "CLOCK_MONOTONIC_RAW" ,
42+ "CLOCK_REALTIME_COARSE" ,
43+ "CLOCK_MONOTONIC_COARSE" ,
44+ "CLOCK_BOOTTIME" ,
45+ "CLOCK_REALTIME_ALARM" ,
46+ "CLOCK_BOOTTIME_ALARM" ,
47+ "CLOCK_SGI_CYCLE" ,
48+ "CLOCK_TAI" ,
49+ };
3950
4051static void vdso_test_gettimeofday (void )
4152{
@@ -44,7 +55,8 @@ static void vdso_test_gettimeofday(void)
4455 (vdso_gettimeofday_t )vdso_sym (version , name [0 ]);
4556
4657 if (!vdso_gettimeofday ) {
47- ksft_test_result_skip (VDSO_TEST_SKIP_MSG (name [0 ]));
58+ ksft_print_msg ("Couldn't find %s\n" , name [0 ]);
59+ ksft_test_result_skip ("%s\n" , name [0 ]);
4860 return ;
4961 }
5062
@@ -54,9 +66,9 @@ static void vdso_test_gettimeofday(void)
5466 if (ret == 0 ) {
5567 ksft_print_msg ("The time is %lld.%06lld\n" ,
5668 (long long )tv .tv_sec , (long long )tv .tv_usec );
57- ksft_test_result_pass (VDSO_TEST_PASS_MSG () );
69+ ksft_test_result_pass ("%s\n" , name [ 0 ] );
5870 } else {
59- ksft_test_result_fail (VDSO_TEST_FAIL_MSG ( name [0 ]) );
71+ ksft_test_result_fail ("%s\n" , name [0 ]);
6072 }
6173}
6274
@@ -67,7 +79,9 @@ static void vdso_test_clock_gettime(clockid_t clk_id)
6779 (vdso_clock_gettime_t )vdso_sym (version , name [1 ]);
6880
6981 if (!vdso_clock_gettime ) {
70- ksft_test_result_skip (VDSO_TEST_SKIP_MSG (name [1 ]));
82+ ksft_print_msg ("Couldn't find %s\n" , name [1 ]);
83+ ksft_test_result_skip ("%s %s\n" , name [1 ],
84+ vdso_clock_name [clk_id ]);
7185 return ;
7286 }
7387
@@ -77,9 +91,11 @@ static void vdso_test_clock_gettime(clockid_t clk_id)
7791 if (ret == 0 ) {
7892 ksft_print_msg ("The time is %lld.%06lld\n" ,
7993 (long long )ts .tv_sec , (long long )ts .tv_nsec );
80- ksft_test_result_pass (VDSO_TEST_PASS_MSG ());
94+ ksft_test_result_pass ("%s %s\n" , name [1 ],
95+ vdso_clock_name [clk_id ]);
8196 } else {
82- ksft_test_result_fail (VDSO_TEST_FAIL_MSG (name [1 ]));
97+ ksft_test_result_fail ("%s %s\n" , name [1 ],
98+ vdso_clock_name [clk_id ]);
8399 }
84100}
85101
@@ -90,7 +106,8 @@ static void vdso_test_time(void)
90106 (vdso_time_t )vdso_sym (version , name [2 ]);
91107
92108 if (!vdso_time ) {
93- ksft_test_result_skip (VDSO_TEST_SKIP_MSG (name [2 ]));
109+ ksft_print_msg ("Couldn't find %s\n" , name [2 ]);
110+ ksft_test_result_skip ("%s\n" , name [2 ]);
94111 return ;
95112 }
96113
@@ -99,9 +116,9 @@ static void vdso_test_time(void)
99116 if (ret > 0 ) {
100117 ksft_print_msg ("The time in hours since January 1, 1970 is %lld\n" ,
101118 (long long )(ret / 3600 ));
102- ksft_test_result_pass (VDSO_TEST_PASS_MSG () );
119+ ksft_test_result_pass ("%s\n" , name [ 2 ] );
103120 } else {
104- ksft_test_result_fail (VDSO_TEST_FAIL_MSG ( name [2 ]) );
121+ ksft_test_result_fail ("%s\n" , name [2 ]);
105122 }
106123}
107124
@@ -114,7 +131,9 @@ static void vdso_test_clock_getres(clockid_t clk_id)
114131 (vdso_clock_getres_t )vdso_sym (version , name [3 ]);
115132
116133 if (!vdso_clock_getres ) {
117- ksft_test_result_skip (VDSO_TEST_SKIP_MSG (name [3 ]));
134+ ksft_print_msg ("Couldn't find %s\n" , name [3 ]);
135+ ksft_test_result_skip ("%s %s\n" , name [3 ],
136+ vdso_clock_name [clk_id ]);
118137 return ;
119138 }
120139
@@ -137,34 +156,21 @@ static void vdso_test_clock_getres(clockid_t clk_id)
137156 clock_getres_fail ++ ;
138157
139158 if (clock_getres_fail > 0 ) {
140- ksft_test_result_fail (VDSO_TEST_FAIL_MSG (name [3 ]));
159+ ksft_test_result_fail ("%s %s\n" , name [3 ],
160+ vdso_clock_name [clk_id ]);
141161 } else {
142- ksft_test_result_pass (VDSO_TEST_PASS_MSG ());
162+ ksft_test_result_pass ("%s %s\n" , name [3 ],
163+ vdso_clock_name [clk_id ]);
143164 }
144165}
145166
146- const char * vdso_clock_name [12 ] = {
147- "CLOCK_REALTIME" ,
148- "CLOCK_MONOTONIC" ,
149- "CLOCK_PROCESS_CPUTIME_ID" ,
150- "CLOCK_THREAD_CPUTIME_ID" ,
151- "CLOCK_MONOTONIC_RAW" ,
152- "CLOCK_REALTIME_COARSE" ,
153- "CLOCK_MONOTONIC_COARSE" ,
154- "CLOCK_BOOTTIME" ,
155- "CLOCK_REALTIME_ALARM" ,
156- "CLOCK_BOOTTIME_ALARM" ,
157- "CLOCK_SGI_CYCLE" ,
158- "CLOCK_TAI" ,
159- };
160-
161167/*
162168 * This function calls vdso_test_clock_gettime and vdso_test_clock_getres
163169 * with different values for clock_id.
164170 */
165171static inline void vdso_test_clock (clockid_t clock_id )
166172{
167- ksft_print_msg ("\nclock_id : %s\n" , vdso_clock_name [clock_id ]);
173+ ksft_print_msg ("clock_id : %s\n" , vdso_clock_name [clock_id ]);
168174
169175 vdso_test_clock_gettime (clock_id );
170176
@@ -181,14 +187,14 @@ int main(int argc, char **argv)
181187 ksft_set_plan (VDSO_TEST_PLAN );
182188
183189 if (!sysinfo_ehdr ) {
184- printf ("AT_SYSINFO_EHDR is not present!\n" );
190+ ksft_print_msg ("AT_SYSINFO_EHDR is not present!\n" );
185191 return KSFT_SKIP ;
186192 }
187193
188194 version = versions [VDSO_VERSION ];
189195 name = (const char * * )& names [VDSO_NAMES ];
190196
191- printf ("[vDSO kselftest] VDSO_VERSION: %s\n" , version );
197+ ksft_print_msg ("[vDSO kselftest] VDSO_VERSION: %s\n" , version );
192198
193199 vdso_init_from_sysinfo_ehdr (getauxval (AT_SYSINFO_EHDR ));
194200
0 commit comments