Ticket #2182: 0001-psxtests-psxclock01-use-clock-and-CLOCKS_PER_SEC.patch

File 0001-psxtests-psxclock01-use-clock-and-CLOCKS_PER_SEC.patch, 4.9 KB (added by Gedare Bloom, on 03/03/15 at 16:12:51)

Test case.

  • testsuites/psxtests/Makefile.am

    From 5587ed2ff9eb7f03894e6440d9dcbeaef78eb1e5 Mon Sep 17 00:00:00 2001
    From: Gedare Bloom <gedare@rtems.org>
    Date: Tue, 3 Mar 2015 11:08:51 -0500
    Subject: [PATCH] psxtests/psxclock01: use clock() and CLOCKS_PER_SEC
    
    Closes #2182
    ---
     testsuites/psxtests/Makefile.am               |  2 +-
     testsuites/psxtests/configure.ac              |  1 +
     testsuites/psxtests/psxclock01/Makefile.am    | 21 +++++++++++
     testsuites/psxtests/psxclock01/init.c         | 50 +++++++++++++++++++++++++++
     testsuites/psxtests/psxclock01/psxclock01.doc | 19 ++++++++++
     testsuites/psxtests/psxclock01/psxclock01.scn |  3 ++
     6 files changed, 95 insertions(+), 1 deletion(-)
     create mode 100644 testsuites/psxtests/psxclock01/Makefile.am
     create mode 100644 testsuites/psxtests/psxclock01/init.c
     create mode 100644 testsuites/psxtests/psxclock01/psxclock01.doc
     create mode 100644 testsuites/psxtests/psxclock01/psxclock01.scn
    
    diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
    index e15d72f..e734c6c 100644
    a b _SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \ 
    1414    psxspin01 psxspin02 psxsysconf \
    1515    psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \
    1616    psxintrcritical01 psxstack01 psxstack02 \
    17     psxeintr_join psxgetattrnp01
     17    psxeintr_join psxgetattrnp01 psxclock01
    1818if HAS_CPLUSPLUS
    1919_SUBDIRS += psxglobalcon01
    2020_SUBDIRS += psxglobalcon02
  • testsuites/psxtests/configure.ac

    diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
    index 00c9970..78ae459 100644
    a b psxclassic01/Makefile 
    141141psxcleanup/Makefile
    142142psxcleanup01/Makefile
    143143psxclock/Makefile
     144psxclock01/Makefile
    144145psxcond01/Makefile
    145146psxconfig01/Makefile
    146147psxeintr_join/Makefile
  • new file testsuites/psxtests/psxclock01/Makefile.am

    diff --git a/testsuites/psxtests/psxclock01/Makefile.am b/testsuites/psxtests/psxclock01/Makefile.am
    new file mode 100644
    index 0000000..acb8f6d
    - +  
     1rtems_tests_PROGRAMS = psxclock01
     2psxclock01_SOURCES = init.c
     3
     4dist_rtems_tests_DATA = psxclock01.scn
     5dist_rtems_tests_DATA += psxclock01.doc
     6
     7include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
     8include $(top_srcdir)/../automake/compile.am
     9include $(top_srcdir)/../automake/leaf.am
     10
     11AM_CPPFLAGS += -I$(top_srcdir)/include
     12AM_CPPFLAGS += -I$(top_srcdir)/../support/include
     13
     14LINK_OBJS = $(psxclock01_OBJECTS) $(psxclock01_LDADD)
     15LINK_LIBS = $(psxclock01_LDLIBS)
     16
     17psxclock01$(EXEEXT): $(psxclock01_OBJECTS) $(psxclock01_DEPENDENCIES)
     18        @rm -f psxclock01$(EXEEXT)
     19        $(make-exe)
     20
     21include $(top_srcdir)/../automake/local.am
  • new file testsuites/psxtests/psxclock01/init.c

    diff --git a/testsuites/psxtests/psxclock01/init.c b/testsuites/psxtests/psxclock01/init.c
    new file mode 100644
    index 0000000..bb39faa
    - +  
     1/*
     2 * Copyright (C) 2015 Gedare Bloom.
     3 *
     4 * The license and distribution terms for this file may be
     5 * found in the file LICENSE in this distribution or at
     6 * http://www.rtems.com/license/LICENSE.
     7 */
     8
     9#include <tmacros.h>
     10#include "test_support.h"
     11
     12const char rtems_test_name[] = "PSXCLOCK01";
     13#include <time.h>
     14
     15/* forward declarations to avoid warnings */
     16void *POSIX_Init(void *argument);
     17
     18void *POSIX_Init(void *argument)
     19{
     20  clock_t start, end;
     21  int diff = 0;
     22
     23  TEST_BEGIN();
     24
     25  start = clock();
     26  end = 0;
     27  if ( start >= 0 ) {
     28    do {
     29      end = clock();
     30      diff = (int)(end - start)/CLOCKS_PER_SEC;
     31    } while (diff < 1);
     32  }
     33
     34  printf("Spun for %d second\n", diff);
     35
     36  TEST_END();
     37  rtems_test_exit(0);
     38}
     39
     40/* configuration information */
     41
     42#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     43#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
     44#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
     45#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
     46#define CONFIGURE_POSIX_INIT_THREAD_TABLE
     47
     48#define CONFIGURE_INIT
     49#include <rtems/confdefs.h>
     50/* end of file */
  • new file testsuites/psxtests/psxclock01/psxclock01.doc

    diff --git a/testsuites/psxtests/psxclock01/psxclock01.doc b/testsuites/psxtests/psxclock01/psxclock01.doc
    new file mode 100644
    index 0000000..f1d0c8f
    - +  
     1# Copyright (c) 2015 Gedare Bloom
     2#
     3# The license and distribution terms for this file may be
     4# found in the file LICENSE in this distribution or at
     5# http://www.rtems.com/license/LICENSE.
     6#
     7
     8This file describes the directives and concepts tested by this test set.
     9
     10test set name:  psxclock01
     11
     12directives:
     13
     14  clock
     15
     16concepts:
     17
     18+ Reads clock() and converts to time in seconds.
     19
  • new file testsuites/psxtests/psxclock01/psxclock01.scn

    diff --git a/testsuites/psxtests/psxclock01/psxclock01.scn b/testsuites/psxtests/psxclock01/psxclock01.scn
    new file mode 100644
    index 0000000..ec29080
    - +  
     1*** BEGIN OF TEST PSXCLOCK01 ***
     2Spun for 1 second
     3*** END OF TEST PSXCLOCK01 ***