summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxtimer02/psxtimer.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/psxtests/psxtimer02/psxtimer.c')
-rw-r--r--testsuites/psxtests/psxtimer02/psxtimer.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/testsuites/psxtests/psxtimer02/psxtimer.c b/testsuites/psxtests/psxtimer02/psxtimer.c
index 9f79d33c42..26d1d5a67c 100644
--- a/testsuites/psxtests/psxtimer02/psxtimer.c
+++ b/testsuites/psxtests/psxtimer02/psxtimer.c
@@ -1,4 +1,7 @@
-/*
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file POSIX Timer Test #2
*
* This is a simple real-time applications which contains 3 periodic tasks.
*
@@ -10,14 +13,33 @@
*
* The share data is protected with a POSIX mutex.
*
- * Other POSIX facilities such as timers, condition, .. is also used
- *
+ * Other POSIX facilities such as timers, condition, .. are also used.
+ */
+
+/*
* COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
@@ -127,6 +149,32 @@ void *POSIX_Init (
status = timer_delete( timer );
fatal_posix_service_status_errno( status, EINVAL, "bad id" );
+ puts( "timer_create (monotonic) - bad timer id pointer - EINVAL" );
+ status = timer_create( CLOCK_MONOTONIC, &event, NULL );
+ fatal_posix_service_status_errno( status, EINVAL, "bad timer id" );
+
+ puts( "timer_create (monotonic) - OK" );
+ status = timer_create( CLOCK_MONOTONIC, NULL, &timer );
+ posix_service_failed( status, "timer_create OK" );
+
+ puts( "timer_create (monotonic) - too many - EAGAIN" );
+ status = timer_create( CLOCK_MONOTONIC, NULL, &timer1 );
+ fatal_posix_service_status_errno( status, EAGAIN, "too many" );
+
+ clock_gettime( CLOCK_MONOTONIC, &now );
+ itimer.it_value = now;
+ itimer.it_value.tv_sec = itimer.it_value.tv_sec - 1;
+ puts( "timer_settime (monotonic) - bad itimer value - previous time - EINVAL" );
+ status = timer_settime( timer, TIMER_ABSTIME, &itimer, NULL );
+ fatal_posix_service_status_errno( status, EINVAL, "bad itimer value #3" );
+
+ clock_gettime( CLOCK_MONOTONIC, &now );
+ itimer.it_value = now;
+ itimer.it_value.tv_sec = itimer.it_value.tv_sec + 1;
+ puts( "timer_settime (monotonic) - bad id - EINVAL" );
+ status = timer_settime( timer1, TIMER_ABSTIME, &itimer, NULL );
+ fatal_posix_service_status_errno( status, EINVAL, "bad id" );
+
TEST_END();
rtems_test_exit (0);
}