[PATCH] Tests for pthread_getcpuclockid method

Gedare Bloom gedare at rtems.org
Tue Apr 7 19:29:43 UTC 2020


Is there a ticket for psxgetcpuclockid? Linked from the psx compliance ticket?

On Tue, Apr 7, 2020 at 5:28 AM Eshan dhawan <eshandhawan51 at gmail.com> wrote:
>

If so the commit message should include

Updates #nnnn.

> ---
>  testsuites/psxtests/Makefile.am               | 10 ++
>  testsuites/psxtests/configure.ac              |  1 +
>  testsuites/psxtests/psxgetcpuclockid01/init.c | 96 +++++++++++++++++++
>  .../psxgetcpuclockid01/psxgetcpuclockid01.doc | 19 ++++
>  .../psxgetcpuclockid01/psxgetcpuclockid01.scn |  4 +
>  5 files changed, 130 insertions(+)
>  create mode 100644 testsuites/psxtests/psxgetcpuclockid01/init.c
>  create mode 100644 testsuites/psxtests/psxgetcpuclockid01/psxgetcpuclockid01.doc
>  create mode 100644 testsuites/psxtests/psxgetcpuclockid01/psxgetcpuclockid01.scn
>
> diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
> index 1f9e4233ec..ffadff16e7 100755
> --- a/testsuites/psxtests/Makefile.am
> +++ b/testsuites/psxtests/Makefile.am
> @@ -462,6 +462,16 @@ psxgetattrnp01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxgetattrnp01) \
>         $(support_includes) -I$(top_srcdir)/include
>  endif
>
> +if TEST_psxgetcpuclockid01
> +psx_tests += psxgetcpuclockid01
> +psx_screens += psxgetcpuclockid01/psxgetcpuclockid01.scn
> +psx_docs += psxgetcpuclockid01/psxgetcpuclockid01.doc
> +psxgetcpuclockid01_SOURCES = psxgetcpuclockid01/init.c
> +psxgetcpuclockid01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxgetcpuclockid01) \
> +       $(support_includes)
> +endif
> +
> +
>  if TEST_psxgetrusage01
>  psx_tests += psxgetrusage01
>  psx_screens += psxgetrusage01/psxgetrusage01.scn
> diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
> index 139787cccb..c509086abc 100644
> --- a/testsuites/psxtests/configure.ac
> +++ b/testsuites/psxtests/configure.ac
> @@ -91,6 +91,7 @@ RTEMS_TEST_CHECK([psxfile01])
>  RTEMS_TEST_CHECK([psxfile02])
>  RTEMS_TEST_CHECK([psxfilelock01])
>  RTEMS_TEST_CHECK([psxgetattrnp01])
> +RTEMS_TEST_CHECK([psxgetcpuclockid01])
>  RTEMS_TEST_CHECK([psxgetrusage01])
>  RTEMS_TEST_CHECK([psxglobalcon01])
>  RTEMS_TEST_CHECK([psxglobalcon02])
> diff --git a/testsuites/psxtests/psxgetcpuclockid01/init.c b/testsuites/psxtests/psxgetcpuclockid01/init.c
> new file mode 100644
> index 0000000000..b2b26339d2
> --- /dev/null
> +++ b/testsuites/psxtests/psxgetcpuclockid01/init.c
> @@ -0,0 +1,96 @@
> +/*
> + *  @file
> + *  @brief Test suite for getcpuclockid methods
> + */
> +
> +/*
> + * SPDX-License-Identifier: BSD-2-Clause
> + *
> + * Copyright (C) 2020 Eshan Dhawan
> + *
> + * 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.
> + */
> +
> +#define _GNU_SOURCE
is this necessary?  why?

> +
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
> +#include <errno.h>
> +#include <pthread.h>
> +#include <stdint.h>
> +#include <rtems/test.h>
> +#include <sys/utsname.h>
> +#include <unistd.h>
> +#include <errno.h>
> +#include <sched.h>
> +
> +#include <rtems/score/todimpl.h>
> +#include <rtems/score/threadimpl.h>
> +#include "tmacros.h"
> +
Are all of the above headers necessary?

> +const char rtems_test_name[] = "PSXGETCPUCLOCKID 1";
> +
> +/* Forward declaration to avoid warnings */
> +rtems_task Init(rtems_task_argument ignored);
> +void *test_task(void);
> +/* test_task function begins */
> +void *test_task()
> +{
> +  int r;
> +  clockid_t cid;
> +
> +  r = pthread_getcpuclockid(pthread_self(), &cid);
add spaces after (  and before )

> +  if(r)
> +  {
formatting: if ( r ) {

> +    printf("pthread_getcpuclockid : 0x%d", r );
space after (
Probably want a \n also.

> +  }
> +  rtems_test_assert( r == 0 );
> +
> +  return NULL;
> +}
> +
> +/* init test function begins */
> +rtems_task Init(rtems_task_argument ignored)
> +{
> +  TEST_BEGIN();
> +
> +  test_task();
This isn't a "task" the function name is a bit misleading.
> +
> +  TEST_END();
> +  rtems_test_exit(0);
> +}
> +
> +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
> +#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
> +
> +#define CONFIGURE_MAXIMUM_TASKS 1
> +
> +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
> +
> +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> +
> +#define CONFIGURE_INIT
> +
> +#include <rtems/confdefs.h>
> +
> diff --git a/testsuites/psxtests/psxgetcpuclockid01/psxgetcpuclockid01.doc b/testsuites/psxtests/psxgetcpuclockid01/psxgetcpuclockid01.doc
> new file mode 100644
> index 0000000000..bfe9c7b9ff
> --- /dev/null
> +++ b/testsuites/psxtests/psxgetcpuclockid01/psxgetcpuclockid01.doc
> @@ -0,0 +1,19 @@
> +#  COPYRIGHT (c) 2020
> +#  On-Line Applications Research Corporation (OAR).
> +#
> +# SPDX-License-Identifier: BSD-2-Clause
> +#
> +
> +This file describes the directives and concepts tested by this test set.
> +
> +test set name:  psxgetcpuclockid 1
> +
> +Directives:
> +  Pthread_getcpuclockid()
> +
> +Concepts:
> +
> ++ This test exercises the getcpuclockid methods.
> +
> ++ For pthread_getcpuclockid it gets the clockid_t for the current thread.
> +
> diff --git a/testsuites/psxtests/psxgetcpuclockid01/psxgetcpuclockid01.scn b/testsuites/psxtests/psxgetcpuclockid01/psxgetcpuclockid01.scn
> new file mode 100644
> index 0000000000..937a908fd5
> --- /dev/null
> +++ b/testsuites/psxtests/psxgetcpuclockid01/psxgetcpuclockid01.scn
> @@ -0,0 +1,4 @@
> +*** BEGIN OF TEST PSXGETCLOCKID 1 ***
> +
> +*** END OF TEST PSXGETCPUCLOCKID 1 ***
> +
Is this the output you get from running the test?

> --
> 2.17.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list