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 \ |
14 | 14 | psxspin01 psxspin02 psxsysconf \ |
15 | 15 | psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \ |
16 | 16 | psxintrcritical01 psxstack01 psxstack02 \ |
17 | | psxeintr_join psxgetattrnp01 |
| 17 | psxeintr_join psxgetattrnp01 psxclock01 |
18 | 18 | if HAS_CPLUSPLUS |
19 | 19 | _SUBDIRS += psxglobalcon01 |
20 | 20 | _SUBDIRS += psxglobalcon02 |
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index 00c9970..78ae459 100644
a
|
b
|
psxclassic01/Makefile |
141 | 141 | psxcleanup/Makefile |
142 | 142 | psxcleanup01/Makefile |
143 | 143 | psxclock/Makefile |
| 144 | psxclock01/Makefile |
144 | 145 | psxcond01/Makefile |
145 | 146 | psxconfig01/Makefile |
146 | 147 | psxeintr_join/Makefile |
diff --git a/testsuites/psxtests/psxclock01/Makefile.am b/testsuites/psxtests/psxclock01/Makefile.am
new file mode 100644
index 0000000..acb8f6d
-
|
+
|
|
| 1 | rtems_tests_PROGRAMS = psxclock01 |
| 2 | psxclock01_SOURCES = init.c |
| 3 | |
| 4 | dist_rtems_tests_DATA = psxclock01.scn |
| 5 | dist_rtems_tests_DATA += psxclock01.doc |
| 6 | |
| 7 | include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg |
| 8 | include $(top_srcdir)/../automake/compile.am |
| 9 | include $(top_srcdir)/../automake/leaf.am |
| 10 | |
| 11 | AM_CPPFLAGS += -I$(top_srcdir)/include |
| 12 | AM_CPPFLAGS += -I$(top_srcdir)/../support/include |
| 13 | |
| 14 | LINK_OBJS = $(psxclock01_OBJECTS) $(psxclock01_LDADD) |
| 15 | LINK_LIBS = $(psxclock01_LDLIBS) |
| 16 | |
| 17 | psxclock01$(EXEEXT): $(psxclock01_OBJECTS) $(psxclock01_DEPENDENCIES) |
| 18 | @rm -f psxclock01$(EXEEXT) |
| 19 | $(make-exe) |
| 20 | |
| 21 | include $(top_srcdir)/../automake/local.am |
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 | |
| 12 | const char rtems_test_name[] = "PSXCLOCK01"; |
| 13 | #include <time.h> |
| 14 | |
| 15 | /* forward declarations to avoid warnings */ |
| 16 | void *POSIX_Init(void *argument); |
| 17 | |
| 18 | void *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 */ |
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 | |
| 8 | This file describes the directives and concepts tested by this test set. |
| 9 | |
| 10 | test set name: psxclock01 |
| 11 | |
| 12 | directives: |
| 13 | |
| 14 | clock |
| 15 | |
| 16 | concepts: |
| 17 | |
| 18 | + Reads clock() and converts to time in seconds. |
| 19 | |
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 *** |
| 2 | Spun for 1 second |
| 3 | *** END OF TEST PSXCLOCK01 *** |