2010-07-29 Bharath Suri <bharath.s.jois@gmail.com>

PR 1642/testing
	* psximfs02/init.c, psximfs02/psximfs02.scn,
	psximfs02/psximfs02.doc, psximfs02/Makefile.am: New test added.
	* configure.ac, Makefile.am: Changes to accommodate psximfs02
	test.
This commit is contained in:
Joel Sherrill
2010-07-29 22:40:50 +00:00
parent bed8f3ea29
commit d08ba49ea2
8 changed files with 255 additions and 2 deletions

View File

@@ -1,3 +1,11 @@
2010-07-29 Bharath Suri <bharath.s.jois@gmail.com>
PR 1642/testing
* psximfs02/init.c, psximfs02/psximfs02.scn,
psximfs02/psximfs02.doc, psximfs02/Makefile.am: New test added.
* configure.ac, Makefile.am: Changes to accommodate psximfs02
test.
2010-07-29 Bharath Suri <bharath.s.jois@gmail.com>
PR 1633/testing

View File

@@ -20,8 +20,8 @@ endif
## File IO tests
SUBDIRS += psxfile01 psxfile02 psxfilelock01 psxgetrusage01 psxid01 \
psximfs01 psxreaddir psxstat psxmount psx13 psxchroot01 psxpasswd01 \
psxpasswd02 psxpipe01 psxtimes01 psxfchx01
psximfs01 psximfs02 psxreaddir psxstat psxmount psx13 psxchroot01 \
psxpasswd01 psxpasswd02 psxpipe01 psxtimes01 psxfchx01
## Until sys/uio.h is moved to libcsupport, we have to have networking
## enabled to support readv and writev. Hopefully this is a temporary

View File

@@ -94,6 +94,7 @@ psxgetrusage01/Makefile
psxhdrs/Makefile
psxid01/Makefile
psximfs01/Makefile
psximfs02/Makefile
psxintrcritical01/Makefile
psxitimer/Makefile
psxkey01/Makefile

View File

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

View File

@@ -0,0 +1,24 @@
##
## $Id$
##
rtems_tests_PROGRAMS = psximfs02
psximfs02_SOURCES = init.c
dist_rtems_tests_DATA = psximfs02.scn
dist_rtems_tests_DATA += psximfs02.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)/../support/include
LINK_OBJS = $(psximfs02_OBJECTS) $(psximfs02_LDADD)
LINK_LIBS = $(psximfs02_LDLIBS)
psximfs02$(EXEEXT): $(psximfs02_OBJECTS) $(psximfs02_DEPENDENCIES)
@rm -f psximfs02$(EXEEXT)
$(make-exe)
include $(top_srcdir)/../automake/local.am

View File

@@ -0,0 +1,153 @@
/*
* COPYRIGHT (c) 1989-2010.
* 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$
*/
#include <tmacros.h>
#include "test_support.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <rtems/libio.h>
extern Heap_Control *RTEMS_Malloc_Heap;
rtems_task Init(
rtems_task_argument argument
)
{
int status = 0;
void *alloc_ptr = (void *)0;
Heap_Information_block Info;
char linkname_n[20] = {0};
char linkname_p[20] = {0};
int i;
struct stat stat_buf;
puts( "\n\n*** TEST IMFS 02 ***" );
puts( "Creating directory /dir00" );
status = mkdir( "/dir00", S_IRWXU );
rtems_test_assert( status == 0 );
puts( "Creating directory /dir00/dir01" );
status = mkdir( "/dir00/dir01", S_IRWXU );
rtems_test_assert( status == 0 );
puts( "Changing directory to /dir00" );
status = chdir( "/dir00" );
rtems_test_assert( status == 0 );
puts( "Creating link dir01-link0 for dir01" );
status = link( "dir01", "dir01-link0" );
rtems_test_assert( status == 0 );
for( i = 1 ; ; ++i ) {
sprintf( linkname_p, "dir01-link%d", i-1 );
sprintf( linkname_n, "dir01-link%d", i );
printf( "\nCreating link %s for %s\n", linkname_n, linkname_p );
status = link( linkname_p, linkname_n );
if( status != 0 ) {
puts("Link creation failed" );
break;
}
}
puts( "Creating a regular node /node, RDONLY" );
status = mknod( "/node", S_IFREG | S_IRUSR, 0LL );
rtems_test_assert( status == 0 );
puts( "Creating link /node-link for /node" );
status = link( "/node" , "/node-link" );
rtems_test_assert( status == 0 );
puts( "Opening /node-link in WRONLY mode -- expect EACCES" );
status = open( "/node-link", O_WRONLY );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == EACCES );
puts( "Creating a symlink /node-slink for /node" );
status = symlink( "/node" , "/node-slink" );
rtems_test_assert( status == 0 );
puts( "Opening /node-slink in WRONLY mode -- expect EACCES" );
status = open( "/node-slink", O_WRONLY );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == EACCES );
puts( "Allocate most of heap" );
_Heap_Get_information( RTEMS_Malloc_Heap, &Info );
alloc_ptr = malloc( Info.Free.largest - 150 );
puts( "Attempt to mount a fs at /dir01 -- expect ENOMEM" );
status = mount( NULL,
"dir01",
"imfs",
RTEMS_FILESYSTEM_READ_WRITE,
NULL );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == ENOMEM );
puts( "Freeing allocated memory" );
free( alloc_ptr );
puts( "Allocate most of heap" );
_Heap_Get_information( RTEMS_Malloc_Heap, &Info );
alloc_ptr = malloc( Info.Free.largest - 4 );
puts( "Changing directory to /" );
status = chdir( "/" );
rtems_test_assert( status == 0 );
puts( "Attempt to create /node-link-2 for /node -- expect ENOMEM" );
status = link( "/node", "/node-link-2" );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == ENOMEM );
puts( "Attempt to create /node-slink-2 for /node -- expect ENOMEM" );
status = symlink( "/node", "node-slink-2" );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == ENOMEM );
puts( "Freeing allocated memory" );
free( alloc_ptr );
puts( "Allocate most of heap" );
alloc_ptr = malloc( Info.Free.largest - 40 );
puts( "Attempt to create /node-slink-2 for /node -- expect ENOMEM" );
status = symlink( "/node", "node-slink-2" );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == ENOMEM );
puts( "Attempt to stat a hardlink -- expect ENOTSUP" );
status = lstat( "/node-link", &stat_buf );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == ENOTSUP );
puts( "*** END OF TEST IMFS 02 ***" );
rtems_test_exit(0);
}
/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */

View File

@@ -0,0 +1,28 @@
#
# $Id$
#
# COPYRIGHT (c) 1989-2010.
# 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 file describes the directives and concepts tested by this test set.
test set name: psximfs02
directives:
+ mkdir
+ link
+ mknod
+ open
+ symlink
+ mount
+ lstat
concepts:
+ A above calls exercise the IMFS routines, mostly error paths.

View File

@@ -0,0 +1,37 @@
*** TEST IMFS 02 ***
Creating directory /dir00
Creating directory /dir00/dir01
Changing directory to /dir00
Creating link dir01-link0 for dir01
Creating link dir01-link1 for dir01-link0
Creating link dir01-link2 for dir01-link1
Creating link dir01-link3 for dir01-link2
Creating link dir01-link4 for dir01-link3
Creating link dir01-link5 for dir01-link4
Creating link dir01-link6 for dir01-link5
Creating link dir01-link7 for dir01-link6
Link creation failed
Creating a regular node /node, RDONLY
Creating link /node-link for /node
Opening /node-link in WRONLY mode -- expect EACCES
Creating a symlink /node-slink for /node
Opening /node-slink in WRONLY mode -- expect EACCES
Allocate most of heap
Attempt to mount a fs at /dir01 -- expect ENOMEM
Freeing allocated memory
Allocate most of heap
Changing directory to /
Attempt to create /node-link-2 for /node -- expect ENOMEM
Attempt to create /node-slink-2 for /node -- expect ENOMEM
Freeing allocated memory
Allocate most of heap
Attempt to create /node-slink-2 for /node -- expect ENOMEM
Attempt to stat a hardlink -- expect ENOTSUP
*** END OF TEST IMFS 02 ***