>This test is based on the new test framework and has been tested for the >sparc/erc32 bsp. --- testsuites/psxtests/Makefile.am | 10 ++ testsuites/psxtests/configure.ac | 1 + .../psxtests/psxclocknanosleep01/init.c | 102 +++++++++++++++ .../psxclocknanosleep01.doc | 13 ++ .../psxclocknanosleep01.scn | 39 ++++++ .../test-clock-nanosleep.c | 119 ++++++++++++++++++ 6 files changed, 284 insertions(+) create mode 100644 testsuites/psxtests/psxclocknanosleep01/init.c create mode 100644 testsuites/psxtests/psxclocknanosleep01/psxclocknanosleep01.doc create mode 100644 testsuites/psxtests/psxclocknanosleep01/psxclocknanosleep01.scn create mode 100644 testsuites/psxtests/psxclocknanosleep01/test-clock-nanosleep.c
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index 1f9e4233ec..89bf493c47 100755 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -312,6 +312,16 @@ psxclock01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxclock01) \ $(support_includes) -I$(top_srcdir)/include endif +if TEST_psxclocknanosleep01 +psx_tests += psxclocknanosleep01 +psx_screens += psxclocknanosleep01/psxclocknanosleep01.scn +psx_docs += psxclocknanosleep01/psxclocknanosleep01.doc +psxclocknanosleep01_SOURCES = psxclocknanosleep01/init.c +psxclocknanosleep01_SOURCES += psxclocknanosleep01/test-clock-nanosleep.c +psxclocknanosleep01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxclocknanosleep01) \ + $(support_includes) -I$(top_srcdir)/include +endif + if TEST_psxclockrealtime01 psx_tests += psxclockrealtime01 psx_screens += psxclockrealtime01/psxclockrealtime01.scn diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac index 139787cccb..9bfe8e2c0b 100644 --- a/testsuites/psxtests/configure.ac +++ b/testsuites/psxtests/configure.ac @@ -75,6 +75,7 @@ RTEMS_TEST_CHECK([psxcleanup01]) RTEMS_TEST_CHECK([psxcleanup02]) RTEMS_TEST_CHECK([psxclock]) RTEMS_TEST_CHECK([psxclock01]) +RTEMS_TEST_CHECK([psxclocknanosleep01]) RTEMS_TEST_CHECK([psxclockrealtime01]) RTEMS_TEST_CHECK([psxconcurrency01]) RTEMS_TEST_CHECK([psxcond01]) diff --git a/testsuites/psxtests/psxclocknanosleep01/init.c b/testsuites/psxtests/psxclocknanosleep01/init.c new file mode 100644 index 0000000000..420c33b648 --- /dev/null +++ b/testsuites/psxtests/psxclocknanosleep01/init.c @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2020 Utkarsh Rai + * + * 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 +#include "config.h" +#endif + +#include <rtems.h> +#include <rtems/bspIo.h> +#include <rtems/linkersets.h> +#include <t.h> +#include <tmacros.h> + +const char rtems_test_name[] = "PSXCLOCKNANOSLEEP01"; + +static char buffer[512]; + +RTEMS_LINKER_ROSET_DECLARE(t_clock_nanosleep, const char *); +RTEMS_LINKER_ROSET(t_clock_nanosleep, const char *); + +static const T_action actions[] = { + T_report_hash_sha256, + T_check_task_context, + T_check_file_descriptors, + T_check_rtems_barriers, + T_check_rtems_extensions, + T_check_rtems_message_queues, + T_check_rtems_partitions, + T_check_rtems_periods, + T_check_rtems_regions, + T_check_rtems_semaphores, + T_check_rtems_tasks, + T_check_rtems_timers, + T_check_posix_keys +}; + +static const T_config config = { + .name = "POSIXCLOCKNANOSLEEPTEST01", + .buf = buffer, + .buf_size = sizeof(buffer), + .putchar = rtems_put_char, + .verbosity = T_VERBOSE, + .now = T_now_clock, + .action_count = T_ARRAY_SIZE(actions), + .actions = actions +}; + +static void +Init(rtems_task_argument arg) +{ + int exit_code; + + (void)arg; + TEST_BEGIN(); + + T_register(); + exit_code = T_main(&config); + if (exit_code == 0) { + TEST_END(); + } + + rtems_test_exit(exit_code); +} + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 32 + +#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 8 + +#define CONFIGURE_UNIFIED_WORK_AREAS + +#define CONFIGURE_UNLIMITED_OBJECTS + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> \ No newline at end of file diff --git a/testsuites/psxtests/psxclocknanosleep01/psxclocknanosleep01.doc b/testsuites/psxtests/psxclocknanosleep01/psxclocknanosleep01.doc new file mode 100644 index 0000000000..803c2cff15 --- /dev/null +++ b/testsuites/psxtests/psxclocknanosleep01/psxclocknanosleep01.doc @@ -0,0 +1,13 @@ +This file describes the directives and concepts tested by this test set. + +test set name: psxclocknanosleep01 + +directives: + +- clock_nanosleep() + +concepts: + +- Test some invalid and extreme timeout values. +- Ensure that the CLOCK_MONOTONIC based delay is not affected by changes to + CLOCK_REALTIME \ No newline at end of file diff --git a/testsuites/psxtests/psxclocknanosleep01/psxclocknanosleep01.scn b/testsuites/psxtests/psxclocknanosleep01/psxclocknanosleep01.scn new file mode 100644 index 0000000000..c2c9da9a99 --- /dev/null +++ b/testsuites/psxtests/psxclocknanosleep01/psxclocknanosleep01.scn @@ -0,0 +1,39 @@ +*** BEGIN OF TEST PSXCLOCKNANOSLEEP01 *** + +A:POSIXCLOCKNANOSLEEPTEST01 +S:Platform:RTEMS +S:Compiler:7.5.0 20191114 (RTEMS 5, RSB 5 (78c6e159d467), Newlib 7947581) +S:Version:5.0.0.222d687969e008cdd464b1f92c79e83671094231-modified +S:BSP:erc32 +S:RTEMS_DEBUG:0 +S:RTEMS_MULTIPROCESSING:0 +S:RTEMS_POSIX_API:1 +S:RTEMS_PROFILING:0 +S:RTEMS_SMP:0 +B:POSIXClock_Timeout_negative_sec_nsec +P:0:0:UI1:test-clock-nanosleep.c:68 +E:POSIXClock_Timeout_negative_sec_nsec:N:1:F:0:D:0.001646 +B:POSIXClock_Timeout_negative_sec +P:0:0:UI1:test-clock-nanosleep.c:43 +E:POSIXClock_Timeout_negative_sec:N:1:F:0:D:0.001641 +B:POSIXClock_Timeout_negative_nsec +P:0:0:UI1:test-clock-nanosleep.c:56 +E:POSIXClock_Timeout_negative_nsec:N:1:F:0:D:0.001641 +B:POSIXClock_Timeout_huge_nsec +P:0:0:UI1:test-clock-nanosleep.c:30 +E:POSIXClock_Timeout_huge_nsec:N:1:F:0:D:0.001641 +B:POSIXClock_Timeout_finite +P:0:0:UI1:test-clock-nanosleep.c:12 +P:1:0:UI1:test-clock-nanosleep.c:17 +E:POSIXClock_Timeout_finite:N:2:F:0:D:1.001857 +B:POSIXClock_Timeout_clock_modify +P:0:0:UI1:test-clock-nanosleep.c:78 +P:1:0:UI1:test-clock-nanosleep.c:82 +P:2:0:UI1:test-clock-nanosleep.c:85 +P:3:0:UI1:test-clock-nanosleep.c:90 +E:POSIXClock_Timeout_clock_modify:N:4:F:0:D:1.007999 +Z:POSIXCLOCKNANOSLEEPTEST01:C:6:N:10:F:0:D:2.031272 +Y:ReportHash:SHA256:735ff533b3a637ec735ac67b48a6a16092132e73b81bdc405790ab8175612dd7 + +*** END OF TEST PSXCLOCKNANOSLEEP01 *** + diff --git a/testsuites/psxtests/psxclocknanosleep01/test-clock-nanosleep.c b/testsuites/psxtests/psxclocknanosleep01/test-clock-nanosleep.c new file mode 100644 index 0000000000..eeff3dd481 --- /dev/null +++ b/testsuites/psxtests/psxclocknanosleep01/test-clock-nanosleep.c @@ -0,0 +1,119 @@ +/* SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2020 Utkarsh Rai + * + * 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 +#include "config.h" +#endif + +#include<errno.h> +#include<limits.h> +#include<time.h> +#include<t.h> + +T_TEST_CASE(POSIXClock_Timeout_finite) +{ + struct timespec delay_time; + int eno; + + eno = clock_gettime( CLOCK_MONOTONIC, &delay_time ); + T_eno_success( eno ); + + delay_time.tv_sec += 1; + + eno = clock_nanosleep( CLOCK_MONOTONIC, TIMER_ABSTIME, &delay_time, NULL ); + T_eno_success( eno ); +} + +T_TEST_CASE(POSIXClock_Timeout_huge_nsec) +{ + struct timespec delay_time; + int eno; + + delay_time.tv_sec = 1; + delay_time.tv_nsec = LONG_MAX; + + eno = clock_nanosleep( CLOCK_MONOTONIC, TIMER_ABSTIME, &delay_time, NULL ); + T_eno( EINVAL, eno ); +} + +T_TEST_CASE(POSIXClock_Timeout_negative_sec) +{ + struct timespec delay_time; + int eno; + + delay_time.tv_sec = -1; + delay_time.tv_nsec = 1; + + eno = clock_nanosleep( CLOCK_MONOTONIC, TIMER_ABSTIME, &delay_time, NULL ); + T_eno_success( eno ); + +} + +T_TEST_CASE(POSIXClock_Timeout_negative_nsec) +{ + struct timespec delay_time; + int eno; + + delay_time.tv_sec = 1; + delay_time.tv_nsec = -1; + + eno = clock_nanosleep( CLOCK_MONOTONIC, TIMER_ABSTIME, &delay_time, NULL ); + T_eno( EINVAL, eno ); +} + +T_TEST_CASE(POSIXClock_Timeout_negative_sec_nsec) +{ + struct timespec delay_time; + int eno; + + delay_time.tv_sec = -1; + delay_time.tv_nsec = -1; + + eno = clock_nanosleep( CLOCK_MONOTONIC, TIMER_ABSTIME, &delay_time, NULL ); + T_eno( EINVAL, eno); +} + +T_TEST_CASE(POSIXClock_Timeout_clock_modify) +{ + struct timespec configure_time; + struct timespec delay_time; + int eno; + + eno = clock_gettime( CLOCK_REALTIME, &configure_time ); + T_eno_success( eno ); + + configure_time.tv_sec += 3600; + eno = clock_settime( CLOCK_REALTIME, &configure_time ); + T_eno_success( eno ); + + eno = clock_gettime( CLOCK_MONOTONIC, &delay_time ); + T_eno_success( eno ); + + delay_time.tv_sec += 1; + + eno = clock_nanosleep( CLOCK_MONOTONIC, TIMER_ABSTIME, &delay_time, NULL ); + T_eno_success( eno ); +} -- 2.17.1 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel