mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-23 19:30:26 +08:00
2010-08-16 Alin Rus <alin.codejunkie@gmail.com>
* Makefile.am, configure.ac: Add psxaio01/, psxaio02/. * psxaio01/Makefile.am, psxaio01/init.c, psxaio01/psxaio01.scn, psxaio01/system.h: New. * psxaio02/Makefile.am, psxaio02/init.c, psxaio02/psxaio02.scn, psxaio02/system.h: New.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2010-08-16 Alin Rus <alin.codejunkie@gmail.com>
|
||||
|
||||
* Makefile.am, configure.ac: Add psxaio01/, psxaio02/.
|
||||
* psxaio01/Makefile.am, psxaio01/init.c, psxaio01/psxaio01.scn,
|
||||
psxaio01/system.h: New.
|
||||
* psxaio02/Makefile.am, psxaio02/init.c, psxaio02/psxaio02.scn,
|
||||
psxaio02/system.h: New.
|
||||
|
||||
2010-08-10 Bharath Suri <bharath.s.jois@gmail.com>
|
||||
|
||||
PR 1598/testing
|
||||
|
||||
@@ -7,7 +7,7 @@ ACLOCAL_AMFLAGS = -I ../aclocal
|
||||
SUBDIRS = psxclock
|
||||
if HAS_POSIX
|
||||
SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
|
||||
psx10 psx11 psx12 psx13 psx14 psxalarm01 \
|
||||
psx10 psx11 psx12 psx13 psx14 psxaio01 psxaio02 psxalarm01 \
|
||||
psxautoinit01 psxautoinit02 psxbarrier01 \
|
||||
psxcancel psxcancel01 psxcleanup psxcleanup01 \
|
||||
psxcond01 psxenosys psxkey01 psxkey02 psxkey03 \
|
||||
|
||||
@@ -72,6 +72,8 @@ psx11/Makefile
|
||||
psx12/Makefile
|
||||
psx13/Makefile
|
||||
psx14/Makefile
|
||||
psxaio01/Makefile
|
||||
psxaio02/Makefile
|
||||
psxalarm01/Makefile
|
||||
psxautoinit01/Makefile
|
||||
psxautoinit02/Makefile
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
MANAGERS = all
|
||||
|
||||
rtems_tests_PROGRAMS = psxaio01
|
||||
psxaio01_SOURCES = init.c system.h ../include/pmacros.h
|
||||
|
||||
dist_rtems_tests_DATA = psxaio01.scn
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
psxaio01_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/include
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
|
||||
LINK_OBJS = $(psxaio01_OBJECTS) $(psxaio01_LDADD)
|
||||
LINK_LIBS = $(psxaio01_LDLIBS)
|
||||
|
||||
psxaio01$(EXEEXT): $(psxaio01_OBJECTS) $(psxaio01_DEPENDENCIES)
|
||||
@rm -f psxaio01$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright 2010, Alin Rus <alin.codejunkie@gmail.com>
|
||||
*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
#include "system.h"
|
||||
#include <rtems.h>
|
||||
#include "tmacros.h"
|
||||
#include <rtems/posix/aio_misc.h>
|
||||
#include <aio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sched.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define BUFSIZE 512
|
||||
#define WRONG_FD 404
|
||||
|
||||
struct aiocb *
|
||||
create_aiocb (void)
|
||||
{
|
||||
struct aiocb *aiocbp;
|
||||
|
||||
aiocbp = malloc (sizeof (struct aiocb));
|
||||
memset (aiocbp, 0, sizeof (struct aiocb));
|
||||
aiocbp->aio_buf = malloc (BUFSIZE * sizeof (char));
|
||||
aiocbp->aio_nbytes = BUFSIZE;
|
||||
aiocbp->aio_offset = 0;
|
||||
aiocbp->aio_reqprio = 0;
|
||||
aiocbp->aio_fildes = open ("aio_fildes", O_RDWR | O_CREAT);
|
||||
|
||||
return aiocbp;
|
||||
}
|
||||
|
||||
void
|
||||
free_aiocb (struct aiocb *aiocbp)
|
||||
{
|
||||
free ((char*) aiocbp->aio_buf);
|
||||
free (aiocbp);
|
||||
}
|
||||
|
||||
void *
|
||||
POSIX_Init (void *argument)
|
||||
{
|
||||
int result, policy;
|
||||
struct aiocb *aiocbp;
|
||||
rtems_status_code status;
|
||||
struct sched_param param;
|
||||
|
||||
puts ("\n\n*** POSIX AIO TEST 01 ***");
|
||||
|
||||
puts ("\n*** POSIX aio_write() test ***");
|
||||
|
||||
/* Request canceled */
|
||||
puts ("Init: aio_write - ECANCELED");
|
||||
|
||||
aiocbp = create_aiocb ();
|
||||
aio_write (aiocbp);
|
||||
aio_cancel (aiocbp->aio_fildes, aiocbp);
|
||||
result = aio_return (aiocbp);
|
||||
rtems_test_assert (result != -1);
|
||||
status = aio_error (aiocbp);
|
||||
rtems_test_assert (status != ECANCELED);
|
||||
free_aiocb (aiocbp);
|
||||
|
||||
/* Successfull added request to queue */
|
||||
puts ("Init: aio_write - SUCCESSFUL");
|
||||
aiocbp = create_aiocb ();
|
||||
aiocbp->aio_fildes = WRONG_FD;
|
||||
status = aio_write (aiocbp);
|
||||
rtems_test_assert (!status);
|
||||
|
||||
pthread_getschedparam (pthread_self (), &policy, ¶m);
|
||||
policy = SCHED_RR;
|
||||
param.sched_priority = 30;
|
||||
pthread_setschedparam (pthread_self (), policy, ¶m);
|
||||
sleep (1);
|
||||
|
||||
while (aio_error (aiocbp) == EINPROGRESS);
|
||||
|
||||
/* Bad file descriptor */
|
||||
puts ("Init: aio_write() - EBADF ");
|
||||
|
||||
result = aio_return (aiocbp);
|
||||
rtems_test_assert (result != -1);
|
||||
status = aio_error (aiocbp);
|
||||
rtems_test_assert (status != EBADF);
|
||||
free_aiocb (aiocbp);
|
||||
|
||||
/* Invalid offset */
|
||||
puts ("Init: aio_write() - EINVAL [aio_offset]");
|
||||
|
||||
aiocbp = create_aiocb ();
|
||||
aiocbp->aio_offset = -1;
|
||||
aio_write (aiocbp);
|
||||
sleep (1);
|
||||
|
||||
while (aio_error (aiocbp) == EINPROGRESS);
|
||||
|
||||
result = aio_return (aiocbp);
|
||||
rtems_test_assert (result != -1);
|
||||
status = aio_error (aiocbp);
|
||||
rtems_test_assert (status != EINVAL);
|
||||
free_aiocb (aiocbp);
|
||||
|
||||
/* Invalid request priority */
|
||||
puts ("Init: aio_write() - EINVAL [aio_reqprio]");
|
||||
|
||||
aiocbp = create_aiocb ();
|
||||
aiocbp->aio_reqprio = AIO_PRIO_DELTA_MAX + 1;
|
||||
aio_write (aiocbp);
|
||||
sleep (1);
|
||||
|
||||
while (aio_error (aiocbp) == EINPROGRESS);
|
||||
|
||||
result = aio_return (aiocbp);
|
||||
rtems_test_assert (result != -1);
|
||||
status = aio_error (aiocbp);
|
||||
rtems_test_assert (status != EINVAL);
|
||||
free_aiocb (aiocbp);
|
||||
|
||||
/* aio_nbytes > 0 and aio_offset >= SEEK_END */
|
||||
puts ("Init: aio_write() - EFBIG");
|
||||
aiocbp = create_aiocb ();
|
||||
aiocbp->aio_nbytes = 1;
|
||||
aiocbp->aio_offset = lseek (aiocbp->aio_fildes, 0, SEEK_END) + 1;
|
||||
aio_write (aiocbp);
|
||||
sleep (1);
|
||||
|
||||
while (aio_error (aiocbp) == EINPROGRESS);
|
||||
|
||||
result = aio_return (aiocbp);
|
||||
rtems_test_assert (result != -1);
|
||||
status = aio_error (aiocbp);
|
||||
rtems_test_assert (status != EFBIG);
|
||||
free_aiocb (aiocbp);
|
||||
|
||||
puts ("*** END OF POSIX AIO TEST 01 ***");
|
||||
|
||||
rtems_test_exit (0);
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2010, Alin Rus <alin.codejunkie@gmail.com>
|
||||
*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
/* functions */
|
||||
|
||||
#include <pmacros.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <sched.h>
|
||||
|
||||
void *POSIX_Init (void *argument);
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 20
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 20
|
||||
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 20
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
|
||||
#define CONFIGURE_STACK_CHECKER_ENABLED
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 10
|
||||
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 10
|
||||
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 10
|
||||
#define CONFIGURE_MAXIMUM_POSIX_KEYS 10
|
||||
|
||||
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
||||
#define CONFIGURE_EXTRA_TASK_STACKS (10 * RTEMS_MINIMUM_STACK_SIZE)
|
||||
#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE (10 * RTEMS_MINIMUM_STACK_SIZE)
|
||||
|
||||
|
||||
#define CONFIGURE_MALLOC_STATISTICS
|
||||
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
|
||||
/* global variables */
|
||||
TEST_EXTERN pthread_t Init_id;
|
||||
|
||||
/* end of include file */
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
MANAGERS = all
|
||||
|
||||
rtems_tests_PROGRAMS = psxaio02
|
||||
psxaio02_SOURCES = init.c system.h ../include/pmacros.h
|
||||
|
||||
dist_rtems_tests_DATA = psxaio02.scn
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
psxaio02_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/include
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
|
||||
LINK_OBJS = $(psxaio02_OBJECTS) $(psxaio02_LDADD)
|
||||
LINK_LIBS = $(psxaio02_LDLIBS)
|
||||
|
||||
psxaio02$(EXEEXT): $(psxaio02_OBJECTS) $(psxaio02_DEPENDENCIES)
|
||||
@rm -f psxaio02$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright 2010, Alin Rus <alin.codejunkie@gmail.com>
|
||||
*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
#include "system.h"
|
||||
#include <rtems.h>
|
||||
#include "tmacros.h"
|
||||
#include <rtems/posix/aio_misc.h>
|
||||
#include <aio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sched.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define BUFSIZE 512
|
||||
#define WRONG_FD 404
|
||||
|
||||
struct aiocb *
|
||||
create_aiocb (void)
|
||||
{
|
||||
struct aiocb *aiocbp;
|
||||
|
||||
aiocbp = malloc (sizeof (struct aiocb));
|
||||
memset (aiocbp, 0, sizeof (struct aiocb));
|
||||
aiocbp->aio_buf = malloc (BUFSIZE * sizeof (char));
|
||||
aiocbp->aio_nbytes = BUFSIZE;
|
||||
aiocbp->aio_offset = 0;
|
||||
aiocbp->aio_reqprio = 0;
|
||||
aiocbp->aio_fildes = open ("aio_fildes", O_RDWR | O_CREAT);
|
||||
|
||||
return aiocbp;
|
||||
}
|
||||
|
||||
void
|
||||
free_aiocb (struct aiocb *aiocbp)
|
||||
{
|
||||
free ((char*) aiocbp->aio_buf);
|
||||
free (aiocbp);
|
||||
}
|
||||
|
||||
void *
|
||||
POSIX_Init (void *argument)
|
||||
{
|
||||
int result, policy;
|
||||
struct aiocb *aiocbp;
|
||||
rtems_status_code status;
|
||||
struct sched_param param;
|
||||
|
||||
puts ("\n\n*** POSIX AIO TEST 02 ***");
|
||||
|
||||
puts ("\n*** POSIX aio_read() test ***");
|
||||
|
||||
/* Request canceled */
|
||||
puts ("Init: aio_read - ECANCELED");
|
||||
|
||||
aiocbp = create_aiocb ();
|
||||
aio_read (aiocbp);
|
||||
aio_cancel (aiocbp->aio_fildes, aiocbp);
|
||||
result = aio_return (aiocbp);
|
||||
rtems_test_assert (result != -1);
|
||||
status = aio_error (aiocbp);
|
||||
rtems_test_assert (status != ECANCELED);
|
||||
free_aiocb (aiocbp);
|
||||
|
||||
/* Successfull added request to queue */
|
||||
puts ("Init: aio_read - SUCCESSFUL");
|
||||
aiocbp = create_aiocb ();
|
||||
aiocbp->aio_fildes = WRONG_FD;
|
||||
status = aio_read (aiocbp);
|
||||
rtems_test_assert (!status);
|
||||
|
||||
pthread_getschedparam (pthread_self (), &policy, ¶m);
|
||||
policy = SCHED_RR;
|
||||
param.sched_priority = 30;
|
||||
pthread_setschedparam (pthread_self (), policy, ¶m);
|
||||
sleep (1);
|
||||
|
||||
while (aio_error (aiocbp) == EINPROGRESS);
|
||||
|
||||
/* Bad file descriptor */
|
||||
puts ("Init: aio_read() - EBADF ");
|
||||
|
||||
result = aio_return (aiocbp);
|
||||
rtems_test_assert (result != -1);
|
||||
status = aio_error (aiocbp);
|
||||
rtems_test_assert (status != EBADF);
|
||||
free_aiocb (aiocbp);
|
||||
|
||||
/* Invalid offset */
|
||||
puts ("Init: aio_read() - EINVAL [aio_offset]");
|
||||
|
||||
aiocbp = create_aiocb ();
|
||||
aiocbp->aio_offset = -1;
|
||||
aio_read (aiocbp);
|
||||
sleep (1);
|
||||
|
||||
while (aio_error (aiocbp) == EINPROGRESS);
|
||||
|
||||
result = aio_return (aiocbp);
|
||||
rtems_test_assert (result != -1);
|
||||
status = aio_error (aiocbp);
|
||||
rtems_test_assert (status != EINVAL);
|
||||
free_aiocb (aiocbp);
|
||||
|
||||
/* Invalid request priority */
|
||||
puts ("Init: aio_read() - EINVAL [aio_reqprio]");
|
||||
|
||||
aiocbp = create_aiocb ();
|
||||
aiocbp->aio_reqprio = AIO_PRIO_DELTA_MAX + 1;
|
||||
aio_read (aiocbp);
|
||||
sleep (1);
|
||||
|
||||
while (aio_error (aiocbp) == EINPROGRESS);
|
||||
|
||||
result = aio_return (aiocbp);
|
||||
rtems_test_assert (result != -1);
|
||||
status = aio_error (aiocbp);
|
||||
rtems_test_assert (status != EINVAL);
|
||||
free_aiocb (aiocbp);
|
||||
|
||||
/* aio_nbytes > 0 && aio_nbytes + aio_offset > max offset of aio_fildes */
|
||||
puts ("Init: aio_read() - OVERFLOW");
|
||||
aiocbp = create_aiocb ();
|
||||
aiocbp->aio_nbytes = 10;
|
||||
aiocbp->aio_offset = lseek (aiocbp->aio_fildes, 0, SEEK_END);
|
||||
aio_read (aiocbp);
|
||||
sleep (1);
|
||||
|
||||
while (aio_error (aiocbp) == EINPROGRESS);
|
||||
|
||||
result = aio_return (aiocbp);
|
||||
rtems_test_assert (result != -1);
|
||||
status = aio_error (aiocbp);
|
||||
rtems_test_assert (status != EFBIG);
|
||||
free_aiocb (aiocbp);
|
||||
|
||||
puts ("*** END OF POSIX AIO TEST 01 ***");
|
||||
|
||||
rtems_test_exit (0);
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2010, Alin Rus <alin.codejunkie@gmail.com>
|
||||
*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
/* functions */
|
||||
|
||||
#include <pmacros.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <sched.h>
|
||||
|
||||
void *POSIX_Init (void *argument);
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 20
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 20
|
||||
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 20
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
|
||||
#define CONFIGURE_STACK_CHECKER_ENABLED
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 10
|
||||
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 10
|
||||
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 10
|
||||
#define CONFIGURE_MAXIMUM_POSIX_KEYS 10
|
||||
|
||||
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
||||
#define CONFIGURE_EXTRA_TASK_STACKS (10 * RTEMS_MINIMUM_STACK_SIZE)
|
||||
#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE (10 * RTEMS_MINIMUM_STACK_SIZE)
|
||||
|
||||
|
||||
#define CONFIGURE_MALLOC_STATISTICS
|
||||
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
|
||||
/* global variables */
|
||||
TEST_EXTERN pthread_t Init_id;
|
||||
|
||||
/* end of include file */
|
||||
Reference in New Issue
Block a user