2011-07-22 Ricardo Aguirre <el.mastin@ymail.com>

PR 1846/tests
	* Makefile.am, configure.ac, psxtmtests_plan.csv: Add benchmark of
	various sem_open(), sem_close(), sem_unlink(), sem_init(), and
	sem_destroy() cases.
	* psxtmsem01/.cvsignore, psxtmsem01/Makefile.am, psxtmsem01/init.c,
	psxtmsem01/psxtmsem01.doc: New files.
This commit is contained in:
Joel Sherrill
2011-07-22 17:05:46 +00:00
parent 58f3fab959
commit f31fcd44e4
8 changed files with 279 additions and 8 deletions

View File

@@ -1,3 +1,12 @@
2011-07-22 Ricardo Aguirre <el.mastin@ymail.com>
PR 1846/tests
* Makefile.am, configure.ac, psxtmtests_plan.csv: Add benchmark of
various sem_open(), sem_close(), sem_unlink(), sem_init(), and
sem_destroy() cases.
* psxtmsem01/.cvsignore, psxtmsem01/Makefile.am, psxtmsem01/init.c,
psxtmsem01/psxtmsem01.doc: New files.
2011-07-21 Ricardo Aguirre <el.mastin@ymail.com>
PR 1835/tests

View File

@@ -18,6 +18,7 @@ SUBDIRS += psxtmmutex06
SUBDIRS += psxtmmutex07
SUBDIRS += psxtmnanosleep01
SUBDIRS += psxtmnanosleep02
SUBDIRS += psxtmsem01
SUBDIRS += psxtmsleep01
SUBDIRS += psxtmsleep02
SUBDIRS += psxtmthread01

View File

@@ -90,6 +90,7 @@ psxtmmutex06/Makefile
psxtmmutex07/Makefile
psxtmnanosleep01/Makefile
psxtmnanosleep02/Makefile
psxtmsem01/Makefile
psxtmsleep01/Makefile
psxtmsleep02/Makefile
psxtmthread01/Makefile

View File

@@ -0,0 +1,2 @@
Makefile
Makefile.in

View File

@@ -0,0 +1,30 @@
##
## $Id$
##
MANAGERS = all
rtems_tests_PROGRAMS = psxtmsem01
psxtmsem01_SOURCES = init.c ../../tmtests/include/timesys.h \
../../support/src/tmtests_empty_function.c \
../../support/src/tmtests_support.c
dist_rtems_tests_DATA = psxtmsem01.doc
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.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 = $(psxtmsem01_OBJECTS) $(psxtmsem01_LDADD)
LINK_LIBS = $(psxtmsem01_LDLIBS)
psxtmsem01$(EXEEXT): $(psxtmsem01_OBJECTS) $(psxtmsem01_DEPENDENCIES)
@rm -f psxtmsem01$(EXEEXT)
$(make-exe)
include $(top_srcdir)/../automake/local.am

View File

@@ -0,0 +1,206 @@
/*
* COPYRIGHT (c) 1989-2011.
* 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.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <errno.h>
#include <fcntl.h>
#include <semaphore.h>
#include <tmacros.h>
#include <timesys.h>
#include <rtems/timerdrv.h>
#include "test_support.h"
#define MAX_SEMS 2
sem_t sem1;
sem_t *n_sem1;
sem_t *n_sem2;
void benchmark_sem_init(void)
{
long end_time;
int status;
benchmark_timer_initialize();
status = sem_init( &sem1, 0, 1 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_init",
end_time,
1, /* Only executed once */
0,
0
);
}
void benchmark_sem_destroy(void)
{
long end_time;
int status;
benchmark_timer_initialize();
status = sem_destroy( &sem1 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_destroy",
end_time,
1, /* Only executed once */
0,
0
);
}
void benchmark_sem_open(bool report_time)
{
long end_time;
benchmark_timer_initialize();
n_sem1 = sem_open( "sem1", O_CREAT, 0777, 1 );
end_time = benchmark_timer_read();
if ( report_time ) {
put_time(
"sem_open (first open 'O_CREAT')",
end_time,
1, /* Only executed once */
0,
0
);
}
}
void benchmark_sem_close(bool report_time)
{
long end_time;
int status;
benchmark_timer_initialize();
status = sem_close( n_sem1 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
if ( report_time ) {
put_time(
"sem_close (named first/nested close)",
end_time,
1, /* Only executed once */
0,
0
);
}
}
void benchmark_sem_unlink(const char *message)
{
long end_time;
int status;
benchmark_timer_initialize();
status = sem_unlink( "sem1" );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
message,
end_time,
1, /* Only executed once */
0,
0
);
}
void benchmark_sem_open_second(void)
{
long end_time;
benchmark_timer_initialize();
n_sem2 = sem_open( "sem1", O_EXCL, 0777, 1 );
end_time = benchmark_timer_read();
put_time(
"sem_open (second open 'O_EXCL')",
end_time,
1, /* Only executed once */
0,
0
);
}
void benchmark_sem_close_second(void)
{
long end_time;
int status;
benchmark_timer_initialize();
status = sem_close( n_sem2 );
end_time = benchmark_timer_read();
rtems_test_assert( status == 0 );
put_time(
"sem_close (named second close)",
end_time,
1, /* Only executed once */
0,
0
);
}
void *POSIX_Init(void *argument)
{
puts( "\n\n*** POSIX TIME TEST PSXTMSEM01 ***" );
/* creating unnamed semaphore */
benchmark_sem_init();
/* destroying unnamed semaphore */
benchmark_sem_destroy();
/* opening named semaphore first time o_flag = O_CREAT */
benchmark_sem_open(true);
/* opening named semaphore second time o_flag = O_EXCL */
benchmark_sem_open_second();
/* close named semaphore first time -- does not delete */
benchmark_sem_close(true);
/* unlink named semaphore -- does not delete */
benchmark_sem_unlink("sem_unlink (does not delete)");
/* close semaphore the second time, this actually deletes it */
benchmark_sem_close_second();
/* recrate named semaphore first time o_flag = O_CREAT */
benchmark_sem_open(false);
benchmark_sem_close(false);
benchmark_sem_unlink("sem_unlink (deletes semaphore)");
puts( "*** END OF POSIX TIME TEST PSXTMSEM01 ***" );
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_MAXIMUM_POSIX_SEMAPHORES MAX_SEMS
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */

View File

@@ -0,0 +1,20 @@
#
# $Id$
#
# COPYRIGHT (c) 1989-2011.
# 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:
+ sem_init
+ sem_open (first 'O_CREAT')
+ sem_close (first)
+ sem_open (second 'O_EXCL')
+ sem_close (second)
+ sem_destroy

View File

@@ -86,7 +86,7 @@
"mq_open (second open)","psxtmsem03","psxtmtest_init_destroy",
"mq_close (close of second)","psxtmsem03","psxtmtest_init_destroy",
"mq_unlink",,,
"mq_receive available",,"psxtmtest_single",
"mq_receive - available",,"psxtmtest_single",
"mq_receive - not available, block",,"psxtmtest_blocking",
"mq_timedreceive - available",,"psxtmtest_single",
"mq_timedreceive - not available, blocks",,"psxtmtest_single",
@@ -98,13 +98,15 @@
"mq_timedsend - thread waiting, preemption",,"psxtmtest_unblocking_preempt",
"mq_notify ",,"psxtmtest_single",
,,,
"sem_init","psxtmsem01","psxtmtest_init_destroy",
"sem_destroy","psxtmsem01","psxtmtest_init_destroy",
"sem_open (first open)","psxtmsem01","psxtmtest_init_destroy",
"sem_close (close of first)","psxtmsem01","psxtmtest_init_destroy",
"sem_open (second open)","psxtmsem01","psxtmtest_init_destroy",
"sem_close (close of second)","psxtmsem01","psxtmtest_init_destroy",
"sem_wait available",,"psxtmtest_single",
"sem_init","psxtmsem01","psxtmtest_single","Yes"
"sem_destroy","psxtmsem01","psxtmtest_single","Yes"
"sem_open (first open named)","psxtmsem01","psxtmtest_single","Yes"
"sem_open (second open named)","psxtmsem01","psxtmtest_single","Yes"
"sem_close (named first/nested close)","psxtmsem01","psxtmtest_single","Yes"
"sem_unlink (does not delete)","psxtmsem01","psxtmtest_single","Yes"
"sem_close (named second close - removes)","psxtmsem01","psxtmtest_single","Yes"
"sem_unlink (deletes)","psxtmsem01","psxtmtest_single","Yes"
"sem_wait - available",,"psxtmtest_single",
"sem_wait - not available, block",,"psxtmtest_blocking",
"sem_trywait - available",,"psxtmtest_single",
"sem_trywait - not available",,"psxtmtest_single",
1 Test Case Test Template Implemented
86 mq_open (second open) psxtmsem03 psxtmtest_init_destroy
87 mq_close (close of second) psxtmsem03 psxtmtest_init_destroy
88 mq_unlink
89 mq_receive – available mq_receive - available psxtmtest_single
90 mq_receive - not available, block psxtmtest_blocking
91 mq_timedreceive - available psxtmtest_single
92 mq_timedreceive - not available, blocks psxtmtest_single
98 mq_timedsend - thread waiting, preemption psxtmtest_unblocking_preempt
99 mq_notify psxtmtest_single
100
101 sem_init psxtmsem01 psxtmtest_init_destroy psxtmtest_single Yes
102 sem_destroy psxtmsem01 psxtmtest_init_destroy psxtmtest_single Yes
103 sem_open (first open) sem_open (first open named) psxtmsem01 psxtmtest_init_destroy psxtmtest_single Yes
104 sem_close (close of first) sem_open (second open named) psxtmsem01 psxtmtest_init_destroy psxtmtest_single Yes
105 sem_open (second open) sem_close (named first/nested close) psxtmsem01 psxtmtest_init_destroy psxtmtest_single Yes
106 sem_close (close of second) sem_unlink (does not delete) psxtmsem01 psxtmtest_init_destroy psxtmtest_single Yes
107 sem_wait – available sem_close (named second close - removes) psxtmsem01 psxtmtest_single Yes
108 sem_unlink (deletes) psxtmsem01 psxtmtest_single Yes
109 sem_wait - available psxtmtest_single
110 sem_wait - not available, block psxtmtest_blocking
111 sem_trywait - available psxtmtest_single
112 sem_trywait - not available psxtmtest_single