[rtems commit] psxtests/psxclock01: use clock() and CLOCKS_PER_SEC

Gedare Bloom gedare at rtems.org
Wed Mar 4 20:39:08 UTC 2015


Module:    rtems
Branch:    master
Commit:    56c719260668c35e87acda32bb12bdf81f08d9e0
Changeset: http://git.rtems.org/rtems/commit/?id=56c719260668c35e87acda32bb12bdf81f08d9e0

Author:    Gedare Bloom <gedare at rtems.org>
Date:      Tue Mar  3 11:08:51 2015 -0500

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(-)

diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index e15d72f..e734c6c 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -14,7 +14,7 @@ _SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
     psxspin01 psxspin02 psxsysconf \
     psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \
     psxintrcritical01 psxstack01 psxstack02 \
-    psxeintr_join psxgetattrnp01
+    psxeintr_join psxgetattrnp01 psxclock01
 if HAS_CPLUSPLUS
 _SUBDIRS += psxglobalcon01
 _SUBDIRS += psxglobalcon02
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index 00c9970..78ae459 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -141,6 +141,7 @@ psxclassic01/Makefile
 psxcleanup/Makefile
 psxcleanup01/Makefile
 psxclock/Makefile
+psxclock01/Makefile
 psxcond01/Makefile
 psxconfig01/Makefile
 psxeintr_join/Makefile
diff --git a/testsuites/psxtests/psxclock01/Makefile.am b/testsuites/psxtests/psxclock01/Makefile.am
new file mode 100644
index 0000000..acb8f6d
--- /dev/null
+++ b/testsuites/psxtests/psxclock01/Makefile.am
@@ -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 at .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
diff --git a/testsuites/psxtests/psxclock01/init.c b/testsuites/psxtests/psxclock01/init.c
new file mode 100644
index 0000000..bb39faa
--- /dev/null
+++ b/testsuites/psxtests/psxclock01/init.c
@@ -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 */
diff --git a/testsuites/psxtests/psxclock01/psxclock01.doc b/testsuites/psxtests/psxclock01/psxclock01.doc
new file mode 100644
index 0000000..f1d0c8f
--- /dev/null
+++ b/testsuites/psxtests/psxclock01/psxclock01.doc
@@ -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.
+
diff --git a/testsuites/psxtests/psxclock01/psxclock01.scn b/testsuites/psxtests/psxclock01/psxclock01.scn
new file mode 100644
index 0000000..ec29080
--- /dev/null
+++ b/testsuites/psxtests/psxclock01/psxclock01.scn
@@ -0,0 +1,3 @@
+*** BEGIN OF TEST PSXCLOCK01 ***
+Spun for 1 second
+*** END OF TEST PSXCLOCK01 ***




More information about the vc mailing list