From 996d18c2125aa5fd8ad05db44fdbe7e867841731 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 10 Aug 2022 17:17:24 -0500 Subject: psxtimer_face01: Improve coverage and documentation Updates #4691. --- testsuites/psxtests/psxtimer_face01/psxtimer.c | 36 +++++++++++++++++++++- .../psxtests/psxtimer_face01/psxtimer_face01.doc | 12 +++++++- .../psxtests/psxtimer_face01/psxtimer_face01.scn | 10 +++--- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/testsuites/psxtests/psxtimer_face01/psxtimer.c b/testsuites/psxtests/psxtimer_face01/psxtimer.c index 5c9dcec57b..155afc5ce0 100644 --- a/testsuites/psxtests/psxtimer_face01/psxtimer.c +++ b/testsuites/psxtests/psxtimer_face01/psxtimer.c @@ -54,17 +54,51 @@ static void *POSIX_Init ( timer_t timer; /* - * If these are not filled in correctly, we don't pass its error checking. + * If these are not filled in correctly, we do not execute pass the + * error checking for a NULL event pointer. */ event.sigev_notify = SIGEV_SIGNAL; event.sigev_signo = SIGUSR1; TEST_BEGIN(); + /* + * When FACE timer behavior is configured, creating a POSIX timer + * using CLOCK_REALTIME is not allowed. + */ puts( "timer_create - CLOCK_REALTIME forbidden - EPERM" ); status = timer_create( CLOCK_REALTIME, &event, &timer ); fatal_posix_service_status_errno( status, EPERM, "not allowed" ); + /* + * When FACE timer behavior is configured, creating a POSIX timer + * on a value other than CLOCK_REALTIME or CLOCK_MONOTONIC is not allowed. + */ + puts( "timer_create - CLOCK_PROCESS_CPUTIME_ID not allowed - EINVAL" ); + status = timer_create( CLOCK_PROCESS_CPUTIME_ID, &event, &timer ); + fatal_posix_service_status_errno( status, EINVAL, "invalid clock" ); + + /* + * When FACE timer behavior is configured, creating a POSIX timer + * on CLOCK_MONOTONIC allowed. + */ + puts( "timer_create - OK" ); + status = timer_create( CLOCK_MONOTONIC, &event, &timer ); + posix_service_failed( status, "timer_create OK" ); + + /* + * Delete the previously created timer. + */ + puts( "timer_delete - OK" ); + status = timer_delete( timer ); + posix_service_failed( status, "timer_delete ok" ); + + /* + */ + puts( "timer_create - CLOCK_MONOTONIC is allowed - OK" ); + status = timer_create( CLOCK_MONOTONIC, &event, &timer ); + posix_service_failed( status, "timer_create ok" ); + TEST_END(); rtems_test_exit (0); } diff --git a/testsuites/psxtests/psxtimer_face01/psxtimer_face01.doc b/testsuites/psxtests/psxtimer_face01/psxtimer_face01.doc index 823853134a..e975419539 100644 --- a/testsuites/psxtests/psxtimer_face01/psxtimer_face01.doc +++ b/testsuites/psxtests/psxtimer_face01/psxtimer_face01.doc @@ -36,4 +36,14 @@ directives: concepts: + This test exercises the CONFIGURE_POSIX_TIMERS_FACE_BEHAVIOR configure - option which alters the behavior of timer_create(). + option which alters the behavior of timer_create(). + + - With CONFIGURE_POSIX_TIMERS_FACE_BEHAVIOR defined, timer_create() + returns EPERM to indicate this is not allowed. + + - With CONFIGURE_POSIX_TIMERS_FACE_BEHAVIOR defined, timer_create() + for CLOCK_MONOTONIC is allowed. + + - With CONFIGURE_POSIX_TIMERS_FACE_BEHAVIOR defined, timer_create() + for any other clock value is an error. + diff --git a/testsuites/psxtests/psxtimer_face01/psxtimer_face01.scn b/testsuites/psxtests/psxtimer_face01/psxtimer_face01.scn index 4dab7981cd..b83b41f281 100644 --- a/testsuites/psxtests/psxtimer_face01/psxtimer_face01.scn +++ b/testsuites/psxtests/psxtimer_face01/psxtimer_face01.scn @@ -1,4 +1,6 @@ -*** BEGIN OF TEST PSXTIMER 2 *** -*** TEST VERSION: 6.0.0.1c6ac88f938f4b135f3bbffc4b19bbc540508c80 -*** END OF TEST PSXTIMER 2 *** - +*** BEGIN OF TEST FACE 1 *** +timer_create - CLOCK_REALTIME forbidden - EPERM +timer_create - CLOCK_PROCESS_CPUTIME_ID not allowed - EINVAL +timer_create - OK +timer_delete - OK +*** END OF TEST PSXTIMER FACE 1 *** -- cgit v1.2.3