psxtests/psxclock01: use clock() and CLOCKS_PER_SEC

Closes #2182
This commit is contained in:
Gedare Bloom
2015-03-03 11:08:51 -05:00
parent 76f37656a2
commit 56c7192606
6 changed files with 95 additions and 1 deletions

View File

@@ -14,7 +14,7 @@ _SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
psxspin01 psxspin02 psxsysconf \ psxspin01 psxspin02 psxsysconf \
psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \ psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \
psxintrcritical01 psxstack01 psxstack02 \ psxintrcritical01 psxstack01 psxstack02 \
psxeintr_join psxgetattrnp01 psxeintr_join psxgetattrnp01 psxclock01
if HAS_CPLUSPLUS if HAS_CPLUSPLUS
_SUBDIRS += psxglobalcon01 _SUBDIRS += psxglobalcon01
_SUBDIRS += psxglobalcon02 _SUBDIRS += psxglobalcon02

View File

@@ -141,6 +141,7 @@ psxclassic01/Makefile
psxcleanup/Makefile psxcleanup/Makefile
psxcleanup01/Makefile psxcleanup01/Makefile
psxclock/Makefile psxclock/Makefile
psxclock01/Makefile
psxcond01/Makefile psxcond01/Makefile
psxconfig01/Makefile psxconfig01/Makefile
psxeintr_join/Makefile psxeintr_join/Makefile

View File

@@ -0,0 +1,21 @@
rtems_tests_PROGRAMS = psxclock01
psxclock01_SOURCES = init.c
dist_rtems_tests_DATA = psxclock01.scn
dist_rtems_tests_DATA += psxclock01.doc
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
AM_CPPFLAGS += -I$(top_srcdir)/include
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
LINK_OBJS = $(psxclock01_OBJECTS) $(psxclock01_LDADD)
LINK_LIBS = $(psxclock01_LDLIBS)
psxclock01$(EXEEXT): $(psxclock01_OBJECTS) $(psxclock01_DEPENDENCIES)
@rm -f psxclock01$(EXEEXT)
$(make-exe)
include $(top_srcdir)/../automake/local.am

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2015 Gedare Bloom.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <tmacros.h>
#include "test_support.h"
const char rtems_test_name[] = "PSXCLOCK01";
#include <time.h>
/* forward declarations to avoid warnings */
void *POSIX_Init(void *argument);
void *POSIX_Init(void *argument)
{
clock_t start, end;
int diff = 0;
TEST_BEGIN();
start = clock();
end = 0;
if ( start >= 0 ) {
do {
end = clock();
diff = (int)(end - start)/CLOCKS_PER_SEC;
} while (diff < 1);
}
printf("Spun for %d second\n", diff);
TEST_END();
rtems_test_exit(0);
}
/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */

View File

@@ -0,0 +1,19 @@
# Copyright (c) 2015 Gedare Bloom
#
# The license and distribution terms for this file may be
# found in the file LICENSE in this distribution or at
# http://www.rtems.com/license/LICENSE.
#
This file describes the directives and concepts tested by this test set.
test set name: psxclock01
directives:
clock
concepts:
+ Reads clock() and converts to time in seconds.

View File

@@ -0,0 +1,3 @@
*** BEGIN OF TEST PSXCLOCK01 ***
Spun for 1 second
*** END OF TEST PSXCLOCK01 ***