[PATCH 1/2] psxmsgq05: Added priority unblocking mq tests

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Aug 30 07:08:57 UTC 2019


On 29/08/2019 20:11, Lou Woods wrote:
> From: Lou Woods <Lou.Woods at OARCorp.com>
> 
> This test exercises the unblocking order of a POSIX
> message queue
> 
> -Added psxmsgq05 test to the make structure.
> -Added tests, doc, and scn output.
> 
> updates #3791.
> ---
>   testsuites/psxtests/Makefile.am             |  10 +
>   testsuites/psxtests/configure.ac            |   1 +
>   testsuites/psxtests/psxmsgq05/init.c        | 440 ++++++++++++++++++++++++++++
>   testsuites/psxtests/psxmsgq05/psxmsgq05.doc |  42 +++
>   testsuites/psxtests/psxmsgq05/psxmsgq05.scn |   4 +
>   testsuites/psxtests/psxmsgq05/system.h      |  56 ++++
>   6 files changed, 553 insertions(+)
>   mode change 100755 => 100644 testsuites/psxtests/Makefile.am
>   create mode 100644 testsuites/psxtests/psxmsgq05/init.c
>   create mode 100644 testsuites/psxtests/psxmsgq05/psxmsgq05.doc
>   create mode 100644 testsuites/psxtests/psxmsgq05/psxmsgq05.scn
>   create mode 100644 testsuites/psxtests/psxmsgq05/system.h
> 
> diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
> old mode 100755
> new mode 100644
> index c12b036..52c9644
> --- a/testsuites/psxtests/Makefile.am
> +++ b/testsuites/psxtests/Makefile.am
> @@ -685,6 +685,16 @@ psxmsgq04_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxmsgq04) \
>   	$(support_includes) -I$(top_srcdir)/include
>   endif
>   
> +if TEST_psxmsgq05
> +psx_tests += psxmsgq05
> +psx_screens += psxmsgq05/psxmsgq05.scn
> +psx_docs += psxmsgq05/psxmsgq05.doc
> +psxmsgq05_SOURCES = psxmsgq05/init.c psxmsgq05/system.h \
> +	include/pmacros.h ../support/src/test_support.c
> +psxmsgq05_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxmsgq05) \
> +	$(support_includes) -I$(top_srcdir)/include
> +endif
> +
>   if TEST_psxmutexattr01
>   psx_tests += psxmutexattr01
>   psx_screens += psxmutexattr01/psxmutexattr01.scn
> diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
> index bb44bb8..32d143a 100644
> --- a/testsuites/psxtests/configure.ac
> +++ b/testsuites/psxtests/configure.ac
> @@ -112,6 +112,7 @@ RTEMS_TEST_CHECK([psxmsgq01])
>   RTEMS_TEST_CHECK([psxmsgq02])
>   RTEMS_TEST_CHECK([psxmsgq03])
>   RTEMS_TEST_CHECK([psxmsgq04])
> +RTEMS_TEST_CHECK([psxmsgq05])
>   RTEMS_TEST_CHECK([psxmutexattr01])
>   RTEMS_TEST_CHECK([psxndbm01])
>   RTEMS_TEST_CHECK([psxobj01])
> diff --git a/testsuites/psxtests/psxmsgq05/init.c b/testsuites/psxtests/psxmsgq05/init.c
> new file mode 100644
> index 0000000..ab06156
> --- /dev/null
> +++ b/testsuites/psxtests/psxmsgq05/init.c
> @@ -0,0 +1,440 @@
> +/*
> + * SPDX-License-Identifier: BSD-2-Clause
> + *
> + * Copyright (C) 2019 On-Line Applications Research.  All rights reserved.

In the licence template:

https://git.rtems.org/rtems/tree/LICENSE.BSD-2-Clause

there is no "All rights reserved.".

[...]
> +/* forward declarations to avoid warnings */

Static functions don't need forward declarations to avoid warnings.

> +static int test_msgQ_unblock_order(
> +  bool  receive_test,    /* true to test receive order, false for
> +                            send order */
> +  bool *task1_released,  /* set by function to indicate task1 was
> +                            released */
> +  bool *task2_released   /* set by function to indicate task2 was
> +                            released */
> +);
> +static void *taskEntry( void *arg );
> +
> +/* The taskEntry function calls send or receive on the provided message queue
> + * and will block waiting to receive or send a message depending on the
> + * receive_test flag.  Once the tasked is unblocked it will post the provided
> + * semaphore.
> + */
> +static void *taskEntry( void *arg )
> +{
> +  char              buffer[ DEFAULT_BUFFER_SIZE ];
> +  struct timespec   timeout;
> +  int               retval;
> +  struct task_args *args = arg;
> +
> +  if ( args == NULL ) {
> +    fprintf( stderr, "NULL argument passed to task, exiting\n" );
> +
> +    return NULL;
> +  }
> +
> +#if 0
> +  fprintf( stderr,
> +    "task id %x with sem %x about to block\n",
> +    pthread_self(),
> +    (unsigned int) ( args->p_task_sem ) );
> +#endif

#if 0 code should be removed.

> +
> +  if ( args->receive_test == true ) {
> +    if ( args->wait_timeout != 0 ) {
> +      retval = clock_gettime( CLOCK_REALTIME, &timeout );
> +
> +      if ( retval == ( -1 ) ) {
> +        perror( "clock gettime failed" );
> +
> +        return NULL;
> +      }
> +
> +      timeout.tv_sec += args->wait_timeout;
> +      retval = mq_timedreceive( *( args->p_main_msgQ ),
> +        buffer,
> +        DEFAULT_BUFFER_SIZE,
> +        NULL,
> +        &timeout );
> +
> +      if ( retval == ( -1 ) ) {
> +        perror( "time mq_receive returned unexpectedly." );
> +
> +        return NULL;
> +      }

Test cases should use assertions to check test conditions.  The new test 
framework helps you to do this:

https://docs.rtems.org/branches/master/eng/test-framework.html#posix-error-numbers

https://docs.rtems.org/branches/master/eng/test-framework.html#posix-status-codes

You should also test for success and not some failure.

[...]

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list