[rtems commit] psxtmtests: added new psxtmthread04 test
Gedare Bloom
gedare at rtems.org
Tue Dec 3 03:37:24 UTC 2013
Module: rtems
Branch: master
Commit: 064820c8740766a4cbe698dd9dd7ec100fe3ebbb
Changeset: http://git.rtems.org/rtems/commit/?id=064820c8740766a4cbe698dd9dd7ec100fe3ebbb
Author: Daniel Ramirez <javamonn at gmail.com>
Date: Mon Dec 2 20:24:28 2013 -0600
psxtmtests: added new psxtmthread04 test
---
testsuites/psxtmtests/Makefile.am | 1 +
testsuites/psxtmtests/configure.ac | 1 +
testsuites/psxtmtests/psxtmtests_plan.csv | 4 +-
testsuites/psxtmtests/psxtmthread04/Makefile.am | 27 ++++++
testsuites/psxtmtests/psxtmthread04/init.c | 98 ++++++++++++++++++++
.../psxtmtests/psxtmthread04/psxtmthread04.doc | 24 +++++
6 files changed, 153 insertions(+), 2 deletions(-)
diff --git a/testsuites/psxtmtests/Makefile.am b/testsuites/psxtmtests/Makefile.am
index e5ca7b5..4474cbe 100644
--- a/testsuites/psxtmtests/Makefile.am
+++ b/testsuites/psxtmtests/Makefile.am
@@ -45,6 +45,7 @@ SUBDIRS += psxtmsleep02
SUBDIRS += psxtmthread01
SUBDIRS += psxtmthread02
SUBDIRS += psxtmthread03
+SUBDIRS += psxtmthread04
SUBDIRS += psxtmthread05
SUBDIRS += psxtmthread06
endif
diff --git a/testsuites/psxtmtests/configure.ac b/testsuites/psxtmtests/configure.ac
index 5f0a503..8b720f1 100644
--- a/testsuites/psxtmtests/configure.ac
+++ b/testsuites/psxtmtests/configure.ac
@@ -119,6 +119,7 @@ psxtmsleep02/Makefile
psxtmthread01/Makefile
psxtmthread02/Makefile
psxtmthread03/Makefile
+psxtmthread04/Makefile
psxtmthread05/Makefile
psxtmthread06/Makefile
])
diff --git a/testsuites/psxtmtests/psxtmtests_plan.csv b/testsuites/psxtmtests/psxtmtests_plan.csv
index 6f511b8..f5f4f8d 100644
--- a/testsuites/psxtmtests/psxtmtests_plan.csv
+++ b/testsuites/psxtmtests/psxtmtests_plan.csv
@@ -32,8 +32,8 @@
"pthread_detach",,,
"pthread_exit",,,
"pthread_exit","psxtmthread03","psxtmtest_single","Yes"
-"pthread_getschedparam","psxtmthread04","psxtmtest_single w/multiple timings","No"
-"pthread_setschedparam - no thread switch","psxtmthread04","psxtmtest_single w/multiple timings","No"
+"pthread_getschedparam","psxtmthread04","psxtmtest_single w/multiple timings","Yes"
+"pthread_setschedparam - no thread switch","psxtmthread04","psxtmtest_single w/multiple timings","Yes"
"pthread_setschedparam - lower own priority: preempt","psxtmthread05","psxtmtest_single","Yes"
"pthread_setschedparam - raise other priority: preempt","psxtmthread06","psxtmtest_single","Yes"
,,,
diff --git a/testsuites/psxtmtests/psxtmthread04/Makefile.am b/testsuites/psxtmtests/psxtmthread04/Makefile.am
new file mode 100644
index 0000000..e479bad
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmthread04/Makefile.am
@@ -0,0 +1,27 @@
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxtmthread04
+psxtmthread04_SOURCES = init.c
+psxtmthread04_SOURCES += ../../tmtests/include/timesys.h
+psxtmthread04_SOURCES += ../../support/src/tmtests_empty_function.c
+psxtmthread04_SOURCES += ../../support/src/tmtests_support.c
+
+dist_rtems_tests_DATA = psxtmthread04.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+OPERATION_COUNT = @OPERATION_COUNT@
+AM_CPPFLAGS += -I$(top_srcdir)/../tmtests/include
+AM_CPPFLAGS += -DOPERATION_COUNT=$(OPERATION_COUNT)
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxtmthread04_OBJECTS) $(psxtmthread04_LDADD)
+LINK_LIBS = $(psxtmthread04_LDLIBS)
+
+psxtmthread04$(EXEEXT): $(psxtmthread04_OBJECTS) $(psxtmthread04_DEPENDENCIES)
+ @rm -f psxtmthread04$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtmtests/psxtmthread04/init.c b/testsuites/psxtmtests/psxtmthread04/init.c
new file mode 100644
index 0000000..b67fca1
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmthread04/init.c
@@ -0,0 +1,98 @@
+/*
+ * COPYRIGHT (c) 1989-2013.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <timesys.h>
+#include <pthread.h>
+#include <sched.h>
+#include <rtems/timerdrv.h>
+#include "test_support.h"
+
+/* forward declarations to avoid warnings */
+void benchmark_pthread_setschedparam(void);
+void benchmark_pthread_getschedparam(void);
+void *POSIX_Init(void *argument);
+
+void benchmark_pthread_getschedparam(void)
+{
+ long end_time;
+ int status;
+ int policy;
+ struct sched_param param;
+
+ benchmark_timer_initialize();
+ status = pthread_getschedparam( pthread_self(), &policy, ¶m );
+ end_time = benchmark_timer_read();
+ rtems_test_assert( status == 0 );
+
+ put_time(
+ "pthread_getschedparam",
+ end_time,
+ 1, /* Only executed once */
+ 0,
+ 0
+ );
+
+}
+
+void benchmark_pthread_setschedparam(void)
+{
+ long end_time;
+ int status;
+ int policy;
+ struct sched_param param;
+
+ status = pthread_getschedparam( pthread_self(), &policy, ¶m );
+ rtems_test_assert( status == 0 );
+
+ /* Arbitrary priority, no other threads to preempt us so it doesn't matter. */
+ param.sched_priority = 5;
+ benchmark_timer_initialize();
+ status = pthread_setschedparam( pthread_self(), policy, ¶m );
+ end_time = benchmark_timer_read();
+ rtems_test_assert( status == 0 );
+
+ put_time(
+ "pthread_setschedparam - no thread switch",
+ end_time,
+ 1, /* Only executed once */
+ 0,
+ 0
+ );
+}
+
+void *POSIX_Init(
+ void *argument
+)
+{
+
+ puts( "\n\n*** POSIX TIME TEST PSXTMTHREAD04 ***" );
+
+ benchmark_pthread_getschedparam();
+ benchmark_pthread_setschedparam();
+
+ puts( "*** END OF POSIX TIME TEST PSXTMTHREAD04 ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
+/* end of file */
diff --git a/testsuites/psxtmtests/psxtmthread04/psxtmthread04.doc b/testsuites/psxtmtests/psxtmthread04/psxtmthread04.doc
new file mode 100644
index 0000000..7088b4e
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmthread04/psxtmthread04.doc
@@ -0,0 +1,24 @@
+# COPYRIGHT (c) 1989-2013.
+# On-Line Applications Research Corporation (OAR).
+#
+# 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 test benchmarks the following operations:
+
++ pthread_getschedparam
++ pthread_setschedparam - no thread switch
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: psxtmthread
+
+directives:
++ pthread_getschedparam
++ pthread_setschedparam
+
+concepts:
++ Benchmark the call pthread_getschedparam and pthread_setschedparam without
+ triggering a context switch.
More information about the vc
mailing list