summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testsuites/psxtests/psx08/init.c118
-rw-r--r--testsuites/psxtests/psx12/init.c2
-rw-r--r--testsuites/psxtests/psx13/test.c2
-rw-r--r--testsuites/psxtests/psx15/init.c2
-rw-r--r--testsuites/psxtests/psxbarrier01/test.c2
-rw-r--r--testsuites/psxtests/psxchroot01/test.c2
-rw-r--r--testsuites/psxtests/psxcleanup02/init.c2
-rw-r--r--testsuites/psxtests/psxcleanup02/main.c2
-rw-r--r--testsuites/psxtests/psxclock/init.c172
-rw-r--r--testsuites/psxtests/psxclockrealtime01/init.c2
-rw-r--r--testsuites/psxtests/psxconfig01/init.c4
-rw-r--r--testsuites/psxtests/psxconfig01/psxconfig01.doc2
-rw-r--r--testsuites/psxtests/psxenosys/init.c10
-rw-r--r--testsuites/psxtests/psxenosys/psxenosys.scn2
-rw-r--r--testsuites/psxtests/psxftw01/init.c64
-rw-r--r--testsuites/psxtests/psxglobalcon01/init.cc2
-rw-r--r--testsuites/psxtests/psxglobalcon02/init.cc2
-rw-r--r--testsuites/psxtests/psxintrcritical01/init.c2
-rw-r--r--testsuites/psxtests/psxkey07/init.c31
-rw-r--r--testsuites/psxtests/psxmount/test.c2
-rw-r--r--testsuites/psxtests/psxonce01/init.c2
-rw-r--r--testsuites/psxtests/psxonce01/psxonce01.doc2
-rw-r--r--testsuites/psxtests/psxrwlock01/test.c28
-rw-r--r--testsuites/psxtests/psxthreadname01/init.c2
-rw-r--r--testsuites/psxtests/psxtimer01/psxtimer.c9
-rw-r--r--testsuites/psxtests/psxtimer02/psxtimer.c9
-rw-r--r--testsuites/psxtests/psxtimer_face01/psxtimer.c123
-rw-r--r--testsuites/psxtests/psxtimer_face01/psxtimer_face01.doc49
-rw-r--r--testsuites/psxtests/psxtimer_face01/psxtimer_face01.scn6
29 files changed, 553 insertions, 104 deletions
diff --git a/testsuites/psxtests/psx08/init.c b/testsuites/psxtests/psx08/init.c
index b4b22a5338..3af6f83d7f 100644
--- a/testsuites/psxtests/psx08/init.c
+++ b/testsuites/psxtests/psx08/init.c
@@ -4,6 +4,8 @@
* COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
+ * Copyright (C) 2022 embedded brains GmbH & Co. KG
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -36,6 +38,119 @@
const char rtems_test_name[] = "PSX 8";
+static void *async_join_thread( void *arg )
+{
+ pthread_t *th;
+ int eno;
+ int type;
+
+ th = arg;
+
+ type = PTHREAD_CANCEL_ASYNCHRONOUS;
+ eno = pthread_setcanceltype( type, &type );
+ rtems_test_assert( eno == 0 );
+ rtems_test_assert( type == PTHREAD_CANCEL_DEFERRED );
+
+ (void) pthread_join( *th, NULL );
+ rtems_test_assert( 0 );
+}
+
+static void test_join_deadlock( void )
+{
+ pthread_t td;
+ pthread_t self;
+ int eno;
+ void *value;
+
+ self = pthread_self();
+
+ eno = pthread_create( &td, NULL, async_join_thread, &self );
+ rtems_test_assert( eno == 0 );
+
+ sched_yield();
+
+ eno = pthread_join( td, NULL );
+ rtems_test_assert( eno == EDEADLK );
+
+ eno = pthread_cancel( td );
+ rtems_test_assert( eno == 0 );
+
+ value = NULL;
+ eno = pthread_join( td, &value );
+ rtems_test_assert( eno == 0 );
+ rtems_test_assert( value == PTHREAD_CANCELED );
+}
+
+typedef struct {
+ pthread_t protected_join;
+ pthread_t deleter;
+ rtems_status_code delete_status;
+} delete_deadlock_context;
+
+static void *protected_join_thread( void *arg )
+{
+ delete_deadlock_context *ctx;
+ int state;
+ int eno;
+ void *value;
+
+ ctx = arg;
+
+ state = PTHREAD_CANCEL_DISABLE;
+ eno = pthread_setcancelstate( state, &state );
+ rtems_test_assert( eno == 0 );
+ rtems_test_assert( state == PTHREAD_CANCEL_ENABLE );
+
+ value = NULL;
+ eno = pthread_join( ctx->deleter, &value );
+ rtems_test_assert( eno == 0 );
+ rtems_test_assert( value == &ctx->deleter );
+
+ state = PTHREAD_CANCEL_ENABLE;
+ eno = pthread_setcancelstate( state, &state );
+ rtems_test_assert( eno == 0 );
+ rtems_test_assert( state == PTHREAD_CANCEL_DISABLE );
+
+ pthread_testcancel();
+ rtems_test_assert( 0 );
+}
+
+static void *deleter_thread( void *arg )
+{
+ delete_deadlock_context *ctx;
+
+ ctx = arg;
+ ctx->delete_status = rtems_task_delete( ctx->protected_join );
+ return &ctx->deleter;
+}
+
+static void test_delete_deadlock( void )
+{
+ delete_deadlock_context ctx;
+ int eno;
+ void *value;
+
+ ctx.delete_status = RTEMS_NOT_IMPLEMENTED;
+
+ eno = pthread_create(
+ &ctx.protected_join,
+ NULL,
+ protected_join_thread,
+ &ctx
+ );
+ rtems_test_assert( eno == 0 );
+
+ eno = pthread_create( &ctx.deleter, NULL, deleter_thread, &ctx );
+ rtems_test_assert( eno == 0 );
+
+ value = NULL;
+ eno = pthread_join( ctx.protected_join, &value );
+ rtems_test_assert( eno == 0 );
+ rtems_test_assert( value == PTHREAD_CANCELED );
+
+ rtems_test_assert( ctx.delete_status == RTEMS_INCORRECT_STATE );
+}
+
void *POSIX_Init(
void *argument
)
@@ -54,6 +169,9 @@ void *POSIX_Init(
Init_id = pthread_self();
printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
+ test_join_deadlock();
+ test_delete_deadlock();
+
puts( "Init: pthread_detach - ESRCH (invalid id)" );
status = pthread_detach( (pthread_t) -1 );
rtems_test_assert( status == ESRCH );
diff --git a/testsuites/psxtests/psx12/init.c b/testsuites/psxtests/psx12/init.c
index 76737b0c3b..6526805313 100644
--- a/testsuites/psxtests/psx12/init.c
+++ b/testsuites/psxtests/psx12/init.c
@@ -226,6 +226,8 @@ static void *POSIX_Init( void *argument )
puts( "Init: pthread_create - SUCCESSFUL" );
+ pthread_setschedprio( pthread_self(), SS_PRIO_LOW );
+
/* Align with clock tick */
sleep( 1 );
diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c
index 0754dbcf30..951953ae98 100644
--- a/testsuites/psxtests/psx13/test.c
+++ b/testsuites/psxtests/psx13/test.c
@@ -639,6 +639,8 @@ static void FutimensTest( void )
/* EBADF test case */
/* Case: Pass an invalid file descriptor */
+ _Timespec_Set_to_zero( &time[0] );
+ _Timespec_Set_to_zero( &time[1] );
rv = futimens( -1, time );
rtems_test_assert( rv == -1 );
rtems_test_assert( errno == EBADF );
diff --git a/testsuites/psxtests/psx15/init.c b/testsuites/psxtests/psx15/init.c
index e6ade823f7..fff3db01c3 100644
--- a/testsuites/psxtests/psx15/init.c
+++ b/testsuites/psxtests/psx15/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2010 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2010 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/psxtests/psxbarrier01/test.c b/testsuites/psxtests/psxbarrier01/test.c
index 3bea278aac..1f3bdb138c 100644
--- a/testsuites/psxtests/psxbarrier01/test.c
+++ b/testsuites/psxtests/psxbarrier01/test.c
@@ -6,7 +6,7 @@
* COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
- * Copyright (c) 2017 embedded brains GmbH
+ * Copyright (c) 2017 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/psxtests/psxchroot01/test.c b/testsuites/psxtests/psxchroot01/test.c
index 8270bf5b58..7ac6a80d56 100644
--- a/testsuites/psxtests/psxchroot01/test.c
+++ b/testsuites/psxtests/psxchroot01/test.c
@@ -5,7 +5,7 @@
* On-Line Applications Research Corporation (OAR).
*
* Modifications to support reference counting in the file system are
- * Copyright (c) 2012 embedded brains GmbH.
+ * Copyright (c) 2012 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/psxtests/psxcleanup02/init.c b/testsuites/psxtests/psxcleanup02/init.c
index 89ae7f1930..c123a817ea 100644
--- a/testsuites/psxtests/psxcleanup02/init.c
+++ b/testsuites/psxtests/psxcleanup02/init.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2015 embedded brains GmbH & Co. KG
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
diff --git a/testsuites/psxtests/psxcleanup02/main.c b/testsuites/psxtests/psxcleanup02/main.c
index 071d84c059..a72c30970a 100644
--- a/testsuites/psxtests/psxcleanup02/main.c
+++ b/testsuites/psxtests/psxcleanup02/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2015 embedded brains GmbH & Co. KG
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
diff --git a/testsuites/psxtests/psxclock/init.c b/testsuites/psxtests/psxclock/init.c
index 2300056f61..eb2f1d130c 100644
--- a/testsuites/psxtests/psxclock/init.c
+++ b/testsuites/psxtests/psxclock/init.c
@@ -50,6 +50,174 @@ static void check_enosys(int status)
rtems_test_exit(0);
}
+static void wait_ticks( rtems_interval ticks )
+{
+ /*
+ * Avoid any clock related sleep calls
+ */
+ rtems_test_assert( rtems_task_wake_after( ticks ) == RTEMS_SUCCESSFUL );
+}
+
+struct clock_context;
+typedef struct clock_context clock_context;
+typedef void (*clock_sleeper)(clock_context* ctx);
+struct clock_context {
+ const char* name;
+ int instance;
+ rtems_id tid;
+ int counter;
+ int result;
+ rtems_interval ticks;
+ struct timespec tspec;
+ clock_sleeper sleeper;
+};
+
+static void clock_context_init(
+ clock_context* ctx, const char* name, int instance,
+ time_t secs, long nsecs, clock_sleeper sleeper)
+{
+ memset( ctx, 0, sizeof( *ctx ) );
+ ctx->name = name;
+ ctx->instance = instance;
+ ctx->tspec.tv_sec = secs;
+ ctx->tspec.tv_nsec = nsecs;
+ ctx->sleeper = sleeper;
+}
+
+static void test_nanosleep( clock_context* ctx )
+{
+ if ( nanosleep ( &ctx->tspec, NULL ) < 0 )
+ {
+ ctx->result = errno;
+ }
+}
+
+static void test_clock_nanosleep_realtime( clock_context* ctx )
+{
+ if ( clock_nanosleep ( CLOCK_REALTIME, 0, &ctx->tspec, NULL ) < 0 )
+ {
+ ctx->result = errno;
+ }
+}
+
+static void test_clock_nanosleep_monotonic( clock_context* ctx )
+{
+ if ( clock_nanosleep ( CLOCK_MONOTONIC, 0, &ctx->tspec, NULL ) < 0 )
+ {
+ ctx->result = errno;
+ }
+}
+
+static void test_clock_check( clock_context* ctx, const rtems_interval ticks_per_sec )
+{
+ const long tick_period_nsec = 1000000000LLU / ticks_per_sec;
+ rtems_interval ticks =
+ (((ctx->tspec.tv_sec * 1000000000LLU) + ctx->tspec.tv_nsec) / tick_period_nsec) + 1;
+ rtems_test_assert( ctx->result == 0 );
+ printf(
+ "clock: %s: sec=%" PRIdtime_t" nsec=%li ticks=%u expected-ticks=%u\n",
+ ctx->name, ctx->tspec.tv_sec, ctx->tspec.tv_nsec, ctx->ticks, ticks);
+ rtems_test_assert( ctx->ticks == ticks );
+}
+
+static void task_clock( rtems_task_argument arg )
+{
+ clock_context* ctx = (clock_context*) arg;
+ rtems_interval start = rtems_clock_get_ticks_since_boot();
+ rtems_interval end;
+ ctx->result = 0;
+ ctx->sleeper( ctx );
+ end = rtems_clock_get_ticks_since_boot();
+ ctx->ticks = end - start;
+ ++ctx->counter;
+ rtems_task_delete( RTEMS_SELF );
+}
+
+static void test_start_task( clock_context* ctx )
+{
+ rtems_status_code sc;
+ sc = rtems_task_create(
+ rtems_build_name( 'C', 'R', 'T', '0' + ctx->instance ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &ctx->tid
+ );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+ sc = rtems_task_start( ctx->tid, task_clock, (rtems_task_argument) ctx );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+}
+
+static void test_settime_and_sleeping_step( int step )
+{
+ const rtems_interval ticks_per_sec = rtems_clock_get_ticks_per_second();
+ struct timespec tv;
+
+ clock_context ns_ctx;
+ clock_context cnr_ctx;
+ clock_context cnm_ctx;
+
+ printf( "\nClock settime while sleeping: step=%i\n", step );
+
+ clock_context_init(
+ &ns_ctx, "nanosleep", 0, 0, 500000000,
+ test_nanosleep );
+ clock_context_init(
+ &cnr_ctx, "clock_nanosleep(CLOCK_REALTIME)", 0, 0, 500000000,
+ test_clock_nanosleep_realtime );
+ clock_context_init(
+ &cnm_ctx, "clock_nanosleep(CLOCK_MONOTONIC)", 0, 0, 500000000,
+ test_clock_nanosleep_monotonic );
+
+ /* Sat, 01 Jan 2000 00:00:00 GMT */
+ tv.tv_sec = 946684800;
+ tv.tv_nsec = 0;
+ rtems_test_assert( clock_settime( CLOCK_REALTIME, &tv ) == 0 );
+
+ wait_ticks( 1 );
+
+ test_start_task( &ns_ctx );
+ test_start_task( &cnr_ctx );
+ test_start_task( &cnm_ctx );
+
+ wait_ticks( 2 );
+
+ /*
+ * Jump forwards 1 second
+ */
+ if ( step != 0 )
+ {
+ tv.tv_sec = 946684800 + step;
+ tv.tv_nsec = 0;
+ rtems_test_assert( clock_settime( CLOCK_REALTIME, &tv ) == 0 );
+ }
+
+ while (true)
+ {
+ int counts = 0;
+ wait_ticks( ticks_per_sec / 4 );
+ counts += ns_ctx.counter;
+ counts += cnr_ctx.counter;
+ counts += cnm_ctx.counter;
+ if (counts == 3)
+ {
+ break;
+ }
+ }
+
+ test_clock_check( &ns_ctx, ticks_per_sec );
+ test_clock_check( &cnr_ctx, ticks_per_sec );
+ test_clock_check( &cnm_ctx, ticks_per_sec );
+}
+
+static void test_settime_and_sleeping( void )
+{
+ test_settime_and_sleeping_step( 0 );
+ test_settime_and_sleeping_step( 1 );
+ test_settime_and_sleeping_step( -1 );
+}
+
typedef struct {
int counter;
struct timespec delta;
@@ -358,6 +526,8 @@ static rtems_task Init(
}
#endif
+ test_settime_and_sleeping( );
+
TEST_END();
rtems_test_exit(0);
}
@@ -370,7 +540,7 @@ static rtems_task Init(
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
-#define CONFIGURE_MAXIMUM_TASKS 2
+#define CONFIGURE_MAXIMUM_TASKS 4
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
diff --git a/testsuites/psxtests/psxclockrealtime01/init.c b/testsuites/psxtests/psxclockrealtime01/init.c
index 720e7ced52..722a756ebb 100644
--- a/testsuites/psxtests/psxclockrealtime01/init.c
+++ b/testsuites/psxtests/psxclockrealtime01/init.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2017 embedded brains GmbH & Co. KG
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
diff --git a/testsuites/psxtests/psxconfig01/init.c b/testsuites/psxtests/psxconfig01/init.c
index f1fcfe2b3b..77a96d1c67 100644
--- a/testsuites/psxtests/psxconfig01/init.c
+++ b/testsuites/psxtests/psxconfig01/init.c
@@ -10,7 +10,7 @@
/*
* Copyright (c) 2014. On-Line Applications Research Corporation (OAR).
- * Copyright (c) 2011-2014 embedded brains GmbH. All rights reserved.
+ * Copyright (C) 2011, 2014 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -200,7 +200,7 @@ static rtems_task Init(rtems_task_argument argument);
#include <rtems/confdefs.h>
typedef struct RTEMS_ALIGNED(RTEMS_PARTITION_ALIGNMENT) {
- uint64_t data [16];
+ uint64_t data [32];
} area;
#if CONFIGURE_MAXIMUM_PARTITIONS > 0
diff --git a/testsuites/psxtests/psxconfig01/psxconfig01.doc b/testsuites/psxtests/psxconfig01/psxconfig01.doc
index 524c8a9994..d8f70bded3 100644
--- a/testsuites/psxtests/psxconfig01/psxconfig01.doc
+++ b/testsuites/psxtests/psxconfig01/psxconfig01.doc
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
-# Copyright (c) 2011 embedded brains GmbH.
+# Copyright (c) 2011 embedded brains GmbH & Co. KG
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
diff --git a/testsuites/psxtests/psxenosys/init.c b/testsuites/psxtests/psxenosys/init.c
index 40f83aa0f0..d9a4d835f7 100644
--- a/testsuites/psxtests/psxenosys/init.c
+++ b/testsuites/psxtests/psxenosys/init.c
@@ -104,9 +104,15 @@ void *POSIX_Init(
sc = fork();
check_enosys( sc );
- puts( "pthread_atfork -- ENOSYS" );
+ /*
+ * The behavior of pthread_atfork() in single process environments was
+ * undefined by POSIX but the fACE Technical Standard required returning
+ * 0. Before ticket #4713, this did return ENOSYS. Just leaving this test
+ * case here for convenience.
+ */
+ puts( "pthread_atfork -- 0" );
sc = pthread_atfork( NULL, NULL, NULL );
- check_enosys( sc );
+ rtems_test_assert( !sc );
puts( "pthread_getcpuclockid -- ENOSYS" );
sc = pthread_getcpuclockid( 0, NULL );
diff --git a/testsuites/psxtests/psxenosys/psxenosys.scn b/testsuites/psxtests/psxenosys/psxenosys.scn
index 1ed64f92e9..9e88acd05a 100644
--- a/testsuites/psxtests/psxenosys/psxenosys.scn
+++ b/testsuites/psxtests/psxenosys/psxenosys.scn
@@ -9,7 +9,7 @@ execv -- ENOSYS
execve -- ENOSYS
execvp -- ENOSYS
fork -- ENOSYS
-pthread_atfork -- ENOSYS
+pthread_atfork -- 0
pthread_getcpuclockid -- ENOSYS
sched_setparam -- ENOSYS
sched_getparam -- ENOSYS
diff --git a/testsuites/psxtests/psxftw01/init.c b/testsuites/psxtests/psxftw01/init.c
index ee0e40c84a..5bd89928d1 100644
--- a/testsuites/psxtests/psxftw01/init.c
+++ b/testsuites/psxtests/psxftw01/init.c
@@ -6,7 +6,7 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (C) 2020 Eshan Dhawan, embedded brains GmbH, Joel Sherrill
+ * Copyright (C) 2020 Eshan Dhawan, embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -66,36 +66,6 @@ void *POSIX_Init (void * argument);
static char file_traverse_order[6][20];
static int file_order;
-static char buffer[512];
-
-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 = "psxftw01",
- .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 int fn_function (const char *fpath, const struct stat *sb,
int tflag, struct FTW *ftwbuf)
{
@@ -122,9 +92,7 @@ T_TEST_CASE(ftw)
TARFILE_SIZE,
&rtems_test_printer
);
- if (sc != RTEMS_SUCCESSFUL) {
- printf ("error: untar failed: %s\n", rtems_status_text (sc));
- }
+ T_rsc_success( sc );
/* Array with expected file order */
char arr_ftw_depth[5][20] = { "test_file", "test_script", "def", "abc", "home" };
@@ -136,49 +104,31 @@ T_TEST_CASE(ftw)
file_order = 0;
flags |= FTW_DEPTH;
r = nftw( files_path, fn_function, 5, flags );
-
- T_quiet_psx_success(r);
+ T_psx_success( r );
/*comparing the nftw file tree to the expexted file tree traversal */
for (i = 0; i < file_order; i++){
r = strcmp( arr_ftw_depth[i], file_traverse_order[i]);
- if (r){
- printf( "Incorrect Order " );
- }
- T_quiet_psx_success(r);
+ T_eq_int( r, 0 );
}
/*----------------Test Block 2--------------------*/
flags = 0;
file_order = 0;
flags |= FTW_PHYS;
r = nftw( files_path, fn_function, 5, flags );
- T_quiet_psx_success(r);
+ T_psx_success(r);
/*comparing the nftw file tree to the expected file tree traversal*/
for (i = 0; i < file_order; i++){
r = strcmp( arr_ftw_phys[i], file_traverse_order[i]);
- if (r){
- printf( "Incorrect Order " );
- }
- T_quiet_psx_success(r);
+ T_eq_int( r, 0 );
}
}
void *POSIX_Init (void * argument)
{
- int exit_code;
-
- TEST_BEGIN();
-
- T_register();
- exit_code = T_main(&config);
- if (exit_code == 0) {
- TEST_END();
- }
-
- rtems_test_exit(exit_code);
-
+ rtems_test_run( (rtems_task_argument) argument, TEST_STATE );
}
/* NOTICE: the clock driver is explicitly disabled */
diff --git a/testsuites/psxtests/psxglobalcon01/init.cc b/testsuites/psxtests/psxglobalcon01/init.cc
index 2ccbba9e34..a61734bcd1 100644
--- a/testsuites/psxtests/psxglobalcon01/init.cc
+++ b/testsuites/psxtests/psxglobalcon01/init.cc
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2014 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/psxtests/psxglobalcon02/init.cc b/testsuites/psxtests/psxglobalcon02/init.cc
index 0e530246e0..3d8206261a 100644
--- a/testsuites/psxtests/psxglobalcon02/init.cc
+++ b/testsuites/psxtests/psxglobalcon02/init.cc
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2014 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/psxtests/psxintrcritical01/init.c b/testsuites/psxtests/psxintrcritical01/init.c
index deb95da994..27126e31ec 100644
--- a/testsuites/psxtests/psxintrcritical01/init.c
+++ b/testsuites/psxtests/psxintrcritical01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2020 embedded brains GmbH & Co. KG
*
* COPYRIGHT (c) 1989-2012.
* On-Line Applications Research Corporation (OAR).
diff --git a/testsuites/psxtests/psxkey07/init.c b/testsuites/psxtests/psxkey07/init.c
index 593df739db..ff7b3a0bd0 100644
--- a/testsuites/psxtests/psxkey07/init.c
+++ b/testsuites/psxtests/psxkey07/init.c
@@ -39,23 +39,25 @@
const char rtems_test_name[] = "PSXKEY 7";
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-rtems_task Test_Thread(rtems_task_argument argument);
+#define INITIAL_TASK_COUNT 10
-pthread_key_t Key;
-int created_thread_count, setted_thread_count, got_thread_count;
-int all_thread_created;
-pthread_mutex_t mutex1, mutex2;
-pthread_cond_t create_condition_var, set_condition_var;
+#define ADDITIONAL_TASK_COUNT 13
-rtems_task Test_Thread(rtems_task_argument argument)
+static pthread_key_t Key;
+static int created_thread_count, setted_thread_count, got_thread_count;
+static int all_thread_created;
+static pthread_mutex_t mutex1, mutex2;
+static pthread_cond_t create_condition_var, set_condition_var;
+
+static rtems_task Test_Thread(rtems_task_argument argument)
{
int sc;
int *value_p, *value_p2;
value_p = malloc( sizeof( int ) );
rtems_test_assert(value_p != NULL);
+
+ *value_p = 123;
sc = pthread_setspecific( Key, value_p );
rtems_test_assert( !sc );
@@ -79,12 +81,13 @@ rtems_task Test_Thread(rtems_task_argument argument)
rtems_task_exit();
}
-rtems_task Init(rtems_task_argument argument)
+static rtems_task Init(rtems_task_argument argument)
{
rtems_status_code rc;
int sc;
struct timespec delay_request;
- uintptr_t max_free_size = 13 * RTEMS_MINIMUM_STACK_SIZE;
+ uintptr_t max_free_size =
+ ADDITIONAL_TASK_COUNT * RTEMS_MINIMUM_STACK_SIZE;
void *greedy;
all_thread_created = 0;
@@ -215,8 +218,10 @@ rtems_task Init(rtems_task_argument argument)
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
-#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(10)
-#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
+#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(INITIAL_TASK_COUNT)
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
+#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \
+ (INITIAL_TASK_COUNT + ADDITIONAL_TASK_COUNT)
#define CONFIGURE_UNIFIED_WORK_AREAS
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
diff --git a/testsuites/psxtests/psxmount/test.c b/testsuites/psxtests/psxmount/test.c
index 9ce68dda59..202baed46c 100644
--- a/testsuites/psxtests/psxmount/test.c
+++ b/testsuites/psxtests/psxmount/test.c
@@ -5,7 +5,7 @@
* On-Line Applications Research Corporation (OAR).
*
* Modifications to support reference counting in the file system are
- * Copyright (c) 2012 embedded brains GmbH.
+ * Copyright (c) 2012 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/psxtests/psxonce01/init.c b/testsuites/psxtests/psxonce01/init.c
index dfa0204d62..033b1a02f3 100644
--- a/testsuites/psxtests/psxonce01/init.c
+++ b/testsuites/psxtests/psxonce01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (C) 2019 embedded brains GmbH
+ * Copyright (C) 2019 embedded brains GmbH & Co. KG
* Copyright (C) 2019 Sebastian Huber
*
* COPYRIGHT (c) 1989-2009.
diff --git a/testsuites/psxtests/psxonce01/psxonce01.doc b/testsuites/psxtests/psxonce01/psxonce01.doc
index 7abbd2e037..3ca5d680c7 100644
--- a/testsuites/psxtests/psxonce01/psxonce01.doc
+++ b/testsuites/psxtests/psxonce01/psxonce01.doc
@@ -3,7 +3,7 @@
# COPYRIGHT (c) 1989-2009.
# On-Line Applications Research Corporation (OAR).
# Copyright (c) 2013 Annelies Odermann <annelies.odermann@gmail.com>
-# Copyright (c) 2014 embedded brains GmbH.
+# Copyright (c) 2014 embedded brains GmbH & Co. KG
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
diff --git a/testsuites/psxtests/psxrwlock01/test.c b/testsuites/psxtests/psxrwlock01/test.c
index 5767aa7c07..f6954007c0 100644
--- a/testsuites/psxtests/psxrwlock01/test.c
+++ b/testsuites/psxtests/psxrwlock01/test.c
@@ -454,10 +454,6 @@ int main(
status = pthread_rwlock_timedrdlock( NULL, &abstime);
rtems_test_assert( status == EINVAL );
- puts( "pthread_rwlock_timedrdlock( &rwlock, NULL) -- EINVAL" );
- status = pthread_rwlock_timedrdlock( &rwlock, NULL);
- rtems_test_assert( status == EINVAL );
-
puts( "pthread_rwlock_tryrdlock(NULL) -- EINVAL" );
status = pthread_rwlock_tryrdlock(NULL);
rtems_test_assert( status == EINVAL );
@@ -470,10 +466,6 @@ int main(
status = pthread_rwlock_timedwrlock( NULL, &abstime );
rtems_test_assert( status == EINVAL );
- puts( "pthread_rwlock_timedwrlock( &rwlock, NULL) -- EINVAL" );
- status = pthread_rwlock_timedwrlock( &rwlock, NULL);
- rtems_test_assert( status == EINVAL );
-
puts( "pthread_rwlock_trywrlock(NULL) -- EINVAL" );
status = pthread_rwlock_trywrlock(NULL);
rtems_test_assert( status == EINVAL );
@@ -482,6 +474,26 @@ int main(
status = pthread_rwlock_unlock(NULL);
rtems_test_assert( status == EINVAL );
+ status = pthread_rwlock_init( &rwlock, NULL );
+ rtems_test_assert( status == 0 );
+
+ status = pthread_rwlock_wrlock( &rwlock );
+ rtems_test_assert( status == 0 );
+
+ puts( "pthread_rwlock_timedrdlock( &rwlock, NULL) -- EINVAL" );
+ status = pthread_rwlock_timedrdlock( &rwlock, NULL);
+ rtems_test_assert( status == EINVAL );
+
+ puts( "pthread_rwlock_timedwrlock( &rwlock, NULL) -- EINVAL" );
+ status = pthread_rwlock_timedwrlock( &rwlock, NULL);
+ rtems_test_assert( status == EINVAL );
+
+ status = pthread_rwlock_unlock( &rwlock );
+ rtems_test_assert( status == 0 );
+
+ status = pthread_rwlock_destroy( &rwlock );
+ rtems_test_assert( status == 0 );
+
/*************** BAD ID CHECK *****************/
/* make a valid abstime */
puts( "clock_gettime(CLOCK_REALTIME, &abstime) -- OK" );
diff --git a/testsuites/psxtests/psxthreadname01/init.c b/testsuites/psxtests/psxthreadname01/init.c
index 3183272ce8..c5d5cef604 100644
--- a/testsuites/psxtests/psxthreadname01/init.c
+++ b/testsuites/psxtests/psxthreadname01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2017 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2017 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/psxtests/psxtimer01/psxtimer.c b/testsuites/psxtests/psxtimer01/psxtimer.c
index 560dc2eebd..57d23c1582 100644
--- a/testsuites/psxtests/psxtimer01/psxtimer.c
+++ b/testsuites/psxtests/psxtimer01/psxtimer.c
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
-/*
+/**
+ * @file POSIX Timer Test
*
* This is a simple real-time applications which contains 3 periodic tasks.
*
@@ -12,8 +13,10 @@
*
* 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).
*
diff --git a/testsuites/psxtests/psxtimer02/psxtimer.c b/testsuites/psxtests/psxtimer02/psxtimer.c
index 7da0f7acd1..26d1d5a67c 100644
--- a/testsuites/psxtests/psxtimer02/psxtimer.c
+++ b/testsuites/psxtests/psxtimer02/psxtimer.c
@@ -1,6 +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.
*
@@ -12,8 +13,10 @@
*
* 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).
*
diff --git a/testsuites/psxtests/psxtimer_face01/psxtimer.c b/testsuites/psxtests/psxtimer_face01/psxtimer.c
new file mode 100644
index 0000000000..155afc5ce0
--- /dev/null
+++ b/testsuites/psxtests/psxtimer_face01/psxtimer.c
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file POSIX Timer Test of FACE Behavior
+ */
+
+/*
+ * COPYRIGHT (c) 2022. On-Line Applications Research Corporation (OAR).
+ *
+ * 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 <pmacros.h>
+#include "tmacros.h"
+
+#include <unistd.h>
+#include <errno.h>
+#include <sched.h>
+#include <time.h> /* time facilities */
+#include <stdio.h> /* console facilities */
+
+const char rtems_test_name[] = "PSXTIMER FACE 1";
+
+static void *POSIX_Init (
+ void *argument
+)
+
+{
+ struct sigevent event;
+ int status;
+ timer_t timer;
+
+ /*
+ * 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);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
+#define CONFIGURE_MAXIMUM_POSIX_TIMERS 1
+
+#define CONFIGURE_POSIX_TIMERS_FACE_BEHAVIOR
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+
+/* end of include file */
diff --git a/testsuites/psxtests/psxtimer_face01/psxtimer_face01.doc b/testsuites/psxtests/psxtimer_face01/psxtimer_face01.doc
new file mode 100644
index 0000000000..e975419539
--- /dev/null
+++ b/testsuites/psxtests/psxtimer_face01/psxtimer_face01.doc
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: BSD-2-Clause
+
+# COPYRIGHT (c) 1989-2009.
+# On-Line Applications Research Corporation (OAR).
+#
+# 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.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: psxtimer_face01
+
+directives:
+ timer_create
+ CONFIGURE_POSIX_TIMERS_FACE_BEHAVIOR
+
+concepts:
+
++ This test exercises the CONFIGURE_POSIX_TIMERS_FACE_BEHAVIOR configure
+ 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
new file mode 100644
index 0000000000..b83b41f281
--- /dev/null
+++ b/testsuites/psxtests/psxtimer_face01/psxtimer_face01.scn
@@ -0,0 +1,6 @@
+*** 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 ***