selftests: Improve test output grammar, code style
Subsystems (2)
PATCH 1/1 selftests: Improve test output grammar, code style
Add small grammar fixes in perf events and Real Time Clock tests' output messages.
Include braces around a single if statement, when there are multiple statements in the else branch, to align with the kernel coding style.
--- tools/testing/selftests/perf_events/watermark_signal.c | 7 ++++--- tools/testing/selftests/rtc/rtctest.c | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-)
tools/testing/selftests/perf_events/watermark_signal.c +4 -3
@@ -65,8 +65,9 @@ TEST(watermark_signal) child =fork ();EXPECT_GE (child,0 ); -if (child ==0 ) +if (child ==0 ) {do_child (); + }else if (child <0 ) {perror ("fork()" ); goto cleanup;
@@ -75,7 +76,7 @@ TEST(watermark_signal)if (waitpid (child, &child_status,WSTOPPED ) != child || !(WIFSTOPPED (child_status) &&WSTOPSIG (child_status) ==SIGSTOP )) {fprintf (stderr, -"failed to sycnhronize with child errno=%d status=%x\n" , +"failed to synchronize with child errno=%d status=%x\n" , errno, child_status); goto cleanup;
@@ -84,7 +85,7 @@ TEST(watermark_signal) fd =syscall (__NR_perf_event_open, &attr, child,-1 ,-1 ,PERF_FLAG_FD_CLOEXEC );if (fd <0 ) { -fprintf (stderr,"failed opening event %llx\n" , attr.config); +fprintf (stderr,"failed to setup performance monitoring %llx\n" , attr.config); goto cleanup; }
tools/testing/selftests/rtc/rtctest.c +5 -5
@@ -138,10 +138,10 @@ TEST_F_TIMEOUT(rtc, date_read_loop, READ_LOOP_DURATION_SEC + 2) { rtc_read =rtc_time_to_timestamp (&rtc_tm);/* Time should not go backwards */ ASSERT_LE (prev_rtc_read, rtc_read); -/* Time should not increase more then 1s at a time */ +/* Time should not increase more than 1s per read */ ASSERT_GE (prev_rtc_read +1 , rtc_read); -/* Sleep 11ms to avoid killing / overheating the RTC */ +/* Sleep 11ms to avoid overheating the RTC */ nanosleep_with_retries (READ_LOOP_SLEEP_MS *1000000 ); prev_rtc_read = rtc_read;
@@ -236,7 +236,7 @@ TEST_F(rtc, alarm_alm_set) {if (alarm_state ==RTC_ALARM_DISABLED )SKIP (return,"Skipping test since alarms are not supported." );if (alarm_state ==RTC_ALARM_RES_MINUTE ) -SKIP (return,"Skipping test since alarms has only minute granularity." ); +SKIP (return,"Skipping test since alarms have only minute granularity." ); rc =ioctl (self->fd,RTC_RD_TIME , &tm);ASSERT_NE (-1 , rc);
@@ -306,7 +306,7 @@ TEST_F(rtc, alarm_wkalm_set) {if (alarm_state ==RTC_ALARM_DISABLED )SKIP (return,"Skipping test since alarms are not supported." );if (alarm_state ==RTC_ALARM_RES_MINUTE ) -SKIP (return,"Skipping test since alarms has only minute granularity." ); +SKIP (return,"Skipping test since alarms have only minute granularity." ); rc =ioctl (self->fd,RTC_RD_TIME , &alarm.time);ASSERT_NE (-1 , rc);
@@ -502,7 +502,7 @@ int main(int argc, char **argv)if (access (rtc_file,R_OK ) ==0 ) ret =test_harness_run (argc, argv);else -ksft_exit_skip ("[SKIP]: Cannot access rtc file %s - Exiting\n" , +ksft_exit_skip ("Cannot access RTC file %s - exiting\n" , rtc_file);return ret;
Signature · 1 line
2.39.5
Alexandre Belloni
maintainerHello,
Quoted 17 lines · Hanne-Lotta Mäenpää
Add small grammar fixes in perf events and Real Time Clock tests' output messages.
Include braces around a single if statement, when there are multiple statements in the else branch, to align with the kernel coding style.
Signed-off-by Hanne-Lotta Mäenpää <[email protected]>--- tools/testing/selftests/perf_events/watermark_signal.c | 7 ++++--- tools/testing/selftests/rtc/rtctest.c | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-)tools/testing/selftests/perf_events/watermark_signal.c +0
-0
tools/testing/selftests/perf_events/watermark_signal.c TEST(watermark_signal) · line 70
Quoted 7 lines
tools/testing/selftests/perf_events/watermark_signal.c +2
-1@@ -65,8 +65,9 @@ TEST(watermark_signal) child =fork ();EXPECT_GE (child,0 ); -if (child ==0 ) +if (child ==0 ) {do_child (); + }
This change seems unrelated.
Quoted 39 lines
tools/testing/selftests/perf_events/watermark_signal.c +2
-2else if (child <0 ) {perror ("fork()" ); goto cleanup;@@ -75,7 +76,7 @@ TEST(watermark_signal)if (waitpid (child, &child_status,WSTOPPED ) != child || !(WIFSTOPPED (child_status) &&WSTOPSIG (child_status) ==SIGSTOP )) {fprintf (stderr, -"failed to sycnhronize with child errno=%d status=%x\n" , +"failed to synchronize with child errno=%d status=%x\n" , errno, child_status); goto cleanup;@@ -84,7 +85,7 @@ TEST(watermark_signal) fd =syscall (__NR_perf_event_open, &attr, child,-1 ,-1 ,PERF_FLAG_FD_CLOEXEC );if (fd <0 ) { -fprintf (stderr,"failed opening event %llx\n" , attr.config); +fprintf (stderr,"failed to setup performance monitoring %llx\n" , attr.config); goto cleanup; }tools/testing/selftests/rtc/rtctest.c +2
-2@@ -138,10 +138,10 @@ TEST_F_TIMEOUT(rtc, date_read_loop, READ_LOOP_DURATION_SEC + 2) { rtc_read =rtc_time_to_timestamp (&rtc_tm);/* Time should not go backwards */ ASSERT_LE (prev_rtc_read, rtc_read); -/* Time should not increase more then 1s at a time */ +/* Time should not increase more than 1s per read */ ASSERT_GE (prev_rtc_read +1 , rtc_read); -/* Sleep 11ms to avoid killing / overheating the RTC */ +/* Sleep 11ms to avoid overheating the RTC */ nanosleep_with_retries (READ_LOOP_SLEEP_MS *1000000 ); prev_rtc_read = rtc_read;
tools/testing/selftests/rtc/rtctest.c TEST_F(rtc, alarm_alm_set) { · line 239
Quoted 5 lines
tools/testing/selftests/rtc/rtctest.c +1
-1@@ -236,7 +236,7 @@ TEST_F(rtc, alarm_alm_set) {if (alarm_state ==RTC_ALARM_DISABLED )SKIP (return,"Skipping test since alarms are not supported." );if (alarm_state ==RTC_ALARM_RES_MINUTE ) -SKIP (return,"Skipping test since alarms has only minute granularity." ); +SKIP (return,"Skipping test since alarms have only minute granularity." );
I guess the proper fix is to remove the s in alarms as there is only one alarm.
Quoted 24 lines
tools/testing/selftests/rtc/rtctest.c +2
-2rc =ioctl (self->fd,RTC_RD_TIME , &tm);ASSERT_NE (-1 , rc);@@ -306,7 +306,7 @@ TEST_F(rtc, alarm_wkalm_set) {if (alarm_state ==RTC_ALARM_DISABLED )SKIP (return,"Skipping test since alarms are not supported." );if (alarm_state ==RTC_ALARM_RES_MINUTE ) -SKIP (return,"Skipping test since alarms has only minute granularity." ); +SKIP (return,"Skipping test since alarms have only minute granularity." ); rc =ioctl (self->fd,RTC_RD_TIME , &alarm.time);ASSERT_NE (-1 , rc);@@ -502,7 +502,7 @@ int main(int argc, char **argv)if (access (rtc_file,R_OK ) ==0 ) ret =test_harness_run (argc, argv);else -ksft_exit_skip ("[SKIP]: Cannot access rtc file %s - Exiting\n" , +ksft_exit_skip ("Cannot access RTC file %s - exiting\n" , rtc_file);return ret;Signature · 1 line
2.39.5
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Hello,
Quoted 21 lines · Alexandre Belloni
Hello,
Quoted 18 lines · Hanne-Lotta Mäenpää
Add small grammar fixes in perf events and Real Time Clock tests' output messages.
Include braces around a single if statement, when there are multiple statements in the else branch, to align with the kernel coding style.
Signed-off-by Hanne-Lotta Mäenpää <[email protected]>--- tools/testing/selftests/perf_events/watermark_signal.c | 7 ++++--- tools/testing/selftests/rtc/rtctest.c | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-)tools/testing/selftests/perf_events/watermark_signal.c +0
-0@@ -65,8 +65,9 @@ TEST(watermark_signal)
Quoted 8 lines
tools/testing/selftests/perf_events/watermark_signal.c TEST(watermark_signal) · line 70
Quoted 6 lines
tools/testing/selftests/perf_events/watermark_signal.c +2
-1child =fork ();EXPECT_GE (child,0 ); -if (child ==0 ) +if (child ==0 ) {do_child (); + }This change seems unrelated.
It is related as a code style fix. I noticed it while reviewing the tests, and decided not to make a separate commit of it. Inspiration is from the kernel coding style docs, see the second last example in: https://www.kernel.org/doc/html/latest/process/coding-style.html#placing-braces-and-spaces
Quoted 38 lines
Quoted 38 lines
tools/testing/selftests/perf_events/watermark_signal.c +2
-2else if (child <0 ) {perror ("fork()" ); goto cleanup;@@ -75,7 +76,7 @@ TEST(watermark_signal)if (waitpid (child, &child_status,WSTOPPED ) != child || !(WIFSTOPPED (child_status) &&WSTOPSIG (child_status) ==SIGSTOP )) {fprintf (stderr, -"failed to sycnhronize with child errno=%d status=%x\n" , +"failed to synchronize with child errno=%d status=%x\n" , errno, child_status); goto cleanup;@@ -84,7 +85,7 @@ TEST(watermark_signal) fd =syscall (__NR_perf_event_open, &attr, child,-1 ,-1 ,PERF_FLAG_FD_CLOEXEC );if (fd <0 ) { -fprintf (stderr,"failed opening event %llx\n" , attr.config); +fprintf (stderr,"failed to setup performance monitoring %llx\n" , attr.config); goto cleanup; }tools/testing/selftests/rtc/rtctest.c +2
-2@@ -138,10 +138,10 @@ TEST_F_TIMEOUT(rtc, date_read_loop, READ_LOOP_DURATION_SEC + 2) { rtc_read =rtc_time_to_timestamp (&rtc_tm);/* Time should not go backwards */ ASSERT_LE (prev_rtc_read, rtc_read); -/* Time should not increase more then 1s at a time */ +/* Time should not increase more than 1s per read */ ASSERT_GE (prev_rtc_read +1 , rtc_read); -/* Sleep 11ms to avoid killing / overheating the RTC */ +/* Sleep 11ms to avoid overheating the RTC */ nanosleep_with_retries (READ_LOOP_SLEEP_MS *1000000 );
Quoted 10 lines
tools/testing/selftests/rtc/rtctest.c TEST_F(rtc, alarm_alm_set) { · line 239
Quoted 7 lines
tools/testing/selftests/rtc/rtctest.c +1
-1prev_rtc_read = rtc_read;@@ -236,7 +236,7 @@ TEST_F(rtc, alarm_alm_set) {if (alarm_state ==RTC_ALARM_DISABLED )SKIP (return,"Skipping test since alarms are not supported." );if (alarm_state ==RTC_ALARM_RES_MINUTE ) -SKIP (return,"Skipping test since alarms has only minute granularity." ); +SKIP (return,"Skipping test since alarms have only minute granularity." );I guess the proper fix is to remove the s in alarms as there is only one alarm.
You are right. I sent patch v2 in another email, with the proposed change.
Quoted 21 lines
Quoted 21 lines
tools/testing/selftests/rtc/rtctest.c +2
-2rc =ioctl (self->fd,RTC_RD_TIME , &tm);ASSERT_NE (-1 , rc);@@ -306,7 +306,7 @@ TEST_F(rtc, alarm_wkalm_set) {if (alarm_state ==RTC_ALARM_DISABLED )SKIP (return,"Skipping test since alarms are not supported." );if (alarm_state ==RTC_ALARM_RES_MINUTE ) -SKIP (return,"Skipping test since alarms has only minute granularity." ); +SKIP (return,"Skipping test since alarms have only minute granularity." ); rc =ioctl (self->fd,RTC_RD_TIME , &alarm.time);ASSERT_NE (-1 , rc);@@ -502,7 +502,7 @@ int main(int argc, char **argv)if (access (rtc_file,R_OK ) ==0 ) ret =test_harness_run (argc, argv);else -ksft_exit_skip ("[SKIP]: Cannot access rtc file %s - Exiting\n" , +ksft_exit_skip ("Cannot access RTC file %s - exiting\n" , rtc_file);
Quoted 5 lines
Quoted 4 lines
tools/testing/selftests/rtc/rtctest.c +0
-0return ret;Signature · 1 line
2.39.5
Best regards,
Hanne-Lotta Mäenpää