diff options
Diffstat (limited to 'testsuites')
21 files changed, 631 insertions, 319 deletions
diff --git a/testsuites/fstests/Makefile.am b/testsuites/fstests/Makefile.am index 2c2171bc54..535862b4a2 100644 --- a/testsuites/fstests/Makefile.am +++ b/testsuites/fstests/Makefile.am @@ -30,6 +30,7 @@ SUBDIRS += mrfs_fspermission SUBDIRS += mrfs_fsrdwr SUBDIRS += mrfs_fssymlink SUBDIRS += mrfs_fstime +SUBDIRS += fsnofs01 EXTRA_DIST = EXTRA_DIST += support/ramdisk_support.c diff --git a/testsuites/fstests/configure.ac b/testsuites/fstests/configure.ac index cb0626172e..ce3bdf7ebe 100644 --- a/testsuites/fstests/configure.ac +++ b/testsuites/fstests/configure.ac @@ -104,6 +104,7 @@ mrfs_fspermission/Makefile mrfs_fsrdwr/Makefile mrfs_fssymlink/Makefile mrfs_fstime/Makefile +fsnofs01/Makefile ]) AC_OUTPUT diff --git a/testsuites/fstests/fserror/test.c b/testsuites/fstests/fserror/test.c index 5e43a9e8d0..c0d59881da 100644 --- a/testsuites/fstests/fserror/test.c +++ b/testsuites/fstests/fserror/test.c @@ -312,7 +312,11 @@ static void rdwr_error (void) char *file01 = "name01"; char *databuf = "test"; char *readbuf[10]; - + int shift = sizeof(off_t) * 8 - 1; + off_t one = 1; + off_t tiny = one << shift; + off_t huge = tiny - 1; + off_t off; mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; const char *wd = __func__; @@ -342,7 +346,11 @@ static void rdwr_error (void) fd = open (file01, O_RDONLY, mode); EXPECT_ERROR (EBADF, write, fd, databuf, 10); - EXPECT_ERROR (EBADF, write, 100, readbuf, 10); + + status = close (fd); + rtems_test_assert (status == 0); + + EXPECT_ERROR (EBADF, write, fd, readbuf, 10); /* * The whence argument is not a proper value, @@ -350,14 +358,25 @@ static void rdwr_error (void) * block special file, or directory. */ + fd = open (file01, O_RDWR, mode); + EXPECT_ERROR (EINVAL, lseek, fd, -100, SEEK_END); EXPECT_ERROR (EINVAL, lseek, fd, -100, SEEK_CUR); EXPECT_ERROR (EINVAL, lseek, fd, -100, SEEK_SET); + status = ftruncate (fd, 1); + rtems_test_assert (status == 0); + EXPECT_ERROR (EOVERFLOW, lseek, fd, huge, SEEK_END); + + off = lseek (fd, 1, SEEK_SET); + rtems_test_assert (off == 1); + EXPECT_ERROR (EOVERFLOW, lseek, fd, huge, SEEK_CUR); + status = close (fd); rtems_test_assert (status == 0); - EXPECT_ERROR (EBADF, lseek, fd, -100, SEEK_SET); + EXPECT_ERROR (EBADF, lseek, fd, 0, SEEK_SET); + /* * Go back to parent directory */ diff --git a/testsuites/fstests/fsnofs01/Makefile.am b/testsuites/fstests/fsnofs01/Makefile.am new file mode 100644 index 0000000000..f92e2be7ca --- /dev/null +++ b/testsuites/fstests/fsnofs01/Makefile.am @@ -0,0 +1,20 @@ +rtems_tests_PROGRAMS = fsnofs01 +fsnofs01_SOURCES = init.c + +dist_rtems_tests_DATA = fsnofs01.scn fsnofs01.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 = $(fsnofs01_OBJECTS) +LINK_LIBS = $(fsnofs01_LDLIBS) + +fsnofs01$(EXEEXT): $(fsnofs01_OBJECTS) $(fsnofs01_DEPENDENCIES) + @rm -f fsnofs01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/fstests/fsnofs01/fsnofs01.doc b/testsuites/fstests/fsnofs01/fsnofs01.doc new file mode 100644 index 0000000000..5943345a3c --- /dev/null +++ b/testsuites/fstests/fsnofs01/fsnofs01.doc @@ -0,0 +1,11 @@ +This file describes the directives and concepts tested by this test set. + +test set name: fsnofs01 + +directives: + + TBD + +concepts: + + TBD diff --git a/testsuites/fstests/fsnofs01/fsnofs01.scn b/testsuites/fstests/fsnofs01/fsnofs01.scn new file mode 100644 index 0000000000..f4095eb344 --- /dev/null +++ b/testsuites/fstests/fsnofs01/fsnofs01.scn @@ -0,0 +1,2 @@ +*** TEST FSNOFS 1 *** +*** END OF TEST FSNOFS 1 *** diff --git a/testsuites/fstests/fsnofs01/init.c b/testsuites/fstests/fsnofs01/init.c new file mode 100644 index 0000000000..3ddc615ba2 --- /dev/null +++ b/testsuites/fstests/fsnofs01/init.c @@ -0,0 +1,364 @@ +/* + * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * 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 "tmacros.h" + +#include <sys/stat.h> +#include <sys/statvfs.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <utime.h> + +#include <rtems/libio_.h> + +static int node_count(const rtems_chain_control *chain) +{ + int count = 0; + const rtems_chain_node *current = rtems_chain_immutable_first(chain); + const rtems_chain_node *tail = rtems_chain_immutable_tail(chain); + + while (current != tail) { + ++count; + + current = rtems_chain_immutable_next(current); + } + + return count; +} + +static void rtems_test_assert_equal_to_null_loc( + const rtems_filesystem_location_info_t *local_loc +) +{ + rtems_filesystem_global_location_t *null_loc = + &rtems_filesystem_global_location_null; + + rtems_test_assert(null_loc->location.node_access == local_loc->node_access); + rtems_test_assert(null_loc->location.node_access_2 == local_loc->node_access_2); + rtems_test_assert(null_loc->location.handlers == local_loc->handlers); + rtems_test_assert(null_loc->location.ops == local_loc->ops); + rtems_test_assert(null_loc->location.mt_entry == local_loc->mt_entry); +} + +static void test_initial_values(void) +{ + rtems_filesystem_global_location_t *null_loc = + &rtems_filesystem_global_location_null; + rtems_filesystem_mount_table_entry_t *null_mt = null_loc->location.mt_entry; + rtems_chain_control *loc_chain = &null_mt->location_chain; + rtems_chain_node *loc_node = &null_loc->location.mt_entry_node; + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(rtems_chain_previous(loc_node) == rtems_chain_head(loc_chain)); + rtems_test_assert(rtems_chain_next(loc_node) == rtems_chain_tail(loc_chain)); + rtems_test_assert(null_mt->mt_point_node == null_loc); + rtems_test_assert(null_mt->mt_fs_root == null_loc); + rtems_test_assert(!null_mt->mounted); + rtems_test_assert(!null_mt->writeable); + rtems_test_assert(null_loc->reference_count == 4); +} + +static void test_location_obtain(void) +{ + rtems_filesystem_global_location_t *global_loc = NULL; + rtems_filesystem_global_location_t *null_loc = + rtems_filesystem_global_location_obtain(&global_loc); + rtems_filesystem_mount_table_entry_t *null_mt = null_loc->location.mt_entry; + rtems_chain_control *loc_chain = &null_mt->location_chain; + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 5); + + rtems_filesystem_global_location_release(null_loc); + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); +} + +static void test_null_location_obtain(void) +{ + rtems_filesystem_global_location_t *null_loc = + rtems_filesystem_global_location_obtain_null(); + rtems_filesystem_mount_table_entry_t *null_mt = null_loc->location.mt_entry; + rtems_chain_control *loc_chain = &null_mt->location_chain; + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 5); + + rtems_filesystem_global_location_release(null_loc); + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); +} + +static void test_null_location_replace(void) +{ + rtems_filesystem_global_location_t *null_loc = + &rtems_filesystem_global_location_null; + rtems_filesystem_mount_table_entry_t *null_mt = null_loc->location.mt_entry; + rtems_chain_control *loc_chain = &null_mt->location_chain; + rtems_filesystem_location_info_t local_loc; + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); + rtems_test_assert(rtems_filesystem_global_location_is_null(null_loc)); + + rtems_filesystem_location_copy(&local_loc, &null_loc->location); + + rtems_test_assert(node_count(loc_chain) == 2); + rtems_test_assert(null_loc->reference_count == 4); + + rtems_filesystem_location_detach(&local_loc); + + rtems_test_assert(node_count(loc_chain) == 2); + rtems_test_assert(null_loc->reference_count == 4); + rtems_test_assert(rtems_filesystem_location_is_null(&local_loc)); + rtems_test_assert_equal_to_null_loc(&local_loc); + + rtems_filesystem_location_free(&local_loc); + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); +} + +static void test_null_location_get_and_replace(void) +{ + rtems_filesystem_global_location_t *null_loc = + &rtems_filesystem_global_location_null; + rtems_filesystem_mount_table_entry_t *null_mt = null_loc->location.mt_entry; + rtems_chain_control *loc_chain = &null_mt->location_chain; + rtems_filesystem_location_info_t local_loc_0; + rtems_filesystem_location_info_t local_loc_1; + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); + + rtems_filesystem_location_copy(&local_loc_0, &null_loc->location); + + rtems_test_assert(node_count(loc_chain) == 2); + rtems_test_assert(null_loc->reference_count == 4); + rtems_test_assert_equal_to_null_loc(&local_loc_0); + + rtems_filesystem_location_copy_and_detach(&local_loc_1, &local_loc_0); + + rtems_test_assert(node_count(loc_chain) == 3); + rtems_test_assert(null_loc->reference_count == 4); + rtems_test_assert_equal_to_null_loc(&local_loc_0); + rtems_test_assert_equal_to_null_loc(&local_loc_1); + + rtems_filesystem_location_free(&local_loc_0); + + rtems_test_assert(node_count(loc_chain) == 2); + rtems_test_assert(null_loc->reference_count == 4); + rtems_test_assert_equal_to_null_loc(&local_loc_1); + + rtems_filesystem_location_free(&local_loc_1); + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); +} + +static void test_path_ops(void) +{ + int rv = 0; + long lrv = 0; + struct stat st; + struct statvfs stvfs; + char buf [32]; + ssize_t n = 0; + const char *path = "/"; + const struct utimbuf times; + + errno = 0; + rv = open(path, O_RDONLY); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = chdir(path); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = chroot(path); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = mknod(path, S_IFREG, 0); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = mkdir(path, 0); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = mkfifo(path, 0); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = stat(path, &st); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = lstat(path, &st); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = statvfs(path, &stvfs); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + n = readlink(path, buf, sizeof(buf)); + rtems_test_assert(n == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = chmod(path, 0); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = chown(path, 0, 0); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = lchown(path, 0, 0); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = rmdir(path); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = unlink(path); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = truncate(path, 0); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = access(path, 0); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + lrv = pathconf(path, _PC_LINK_MAX); + rtems_test_assert(lrv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = link(path, path); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = symlink(path, path); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = rename(path, path); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); + + errno = 0; + rv = utime(path, ×); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == ENXIO); +} + +static void test_user_env(void) +{ + rtems_status_code sc = RTEMS_SUCCESSFUL; + rtems_filesystem_global_location_t *null_loc = + &rtems_filesystem_global_location_null; + rtems_filesystem_mount_table_entry_t *null_mt = null_loc->location.mt_entry; + rtems_chain_control *loc_chain = &null_mt->location_chain; + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); + + sc = rtems_libio_set_private_env(); + rtems_test_assert(sc == RTEMS_UNSATISFIED); + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); + + sc = rtems_libio_share_private_env(RTEMS_SELF); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); + + sc = rtems_libio_share_private_env(rtems_task_self()); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); + + rtems_libio_use_global_env(); + + rtems_test_assert(node_count(loc_chain) == 1); + rtems_test_assert(null_loc->reference_count == 4); +} + +static void Init(rtems_task_argument arg) +{ + printk("\n\n*** TEST FSNOFS 1 ***\n"); + + rtems_libio_init(); + + test_initial_values(); + test_location_obtain(); + test_null_location_obtain(); + test_null_location_replace(); + test_null_location_get_and_replace(); + test_path_ops(); + test_user_env(); + + printk("*** END OF TEST FSNOFS 1 ***\n"); + + exit(0); +} + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/fstests/mrfs_support/fs_support.c b/testsuites/fstests/mrfs_support/fs_support.c index a9d3da125c..0eaff99d30 100644 --- a/testsuites/fstests/mrfs_support/fs_support.c +++ b/testsuites/fstests/mrfs_support/fs_support.c @@ -69,7 +69,7 @@ test_shutdown_filesystem (void) #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM #define CONFIGURE_MAXIMUM_DRIVERS 10 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 40 -#define CONFIGURE_INIT_TASK_STACK_SIZE (16 * 1024) +#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024) #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK diff --git a/testsuites/fstests/support/fstest_support.c b/testsuites/fstests/support/fstest_support.c index 239bdb91f3..9613c12a82 100644 --- a/testsuites/fstests/support/fstest_support.c +++ b/testsuites/fstests/support/fstest_support.c @@ -30,55 +30,10 @@ #include "fstest.h" #include "pmacros.h" -#define TEMP_DIR "waterbuffalo" - - /* Break out of a chroot() environment in C */ static void break_out_of_chroot(void) { - - int dir_fd; /* File descriptor to directory */ - struct stat sbuf; /* The stat() buffer */ - chdir("/"); - - if (stat(TEMP_DIR,&sbuf)<0) { - if (errno==ENOENT) { - if (mkdir(TEMP_DIR,0755)<0) { - fprintf(stderr,"Failed to create %s - %s\n", TEMP_DIR, - strerror(errno)); - exit(1); - } - } else { - fprintf(stderr,"Failed to stat %s - %s\n", TEMP_DIR, - strerror(errno)); - exit(1); - } - } else if (!S_ISDIR(sbuf.st_mode)) { - fprintf(stderr,"Error - %s is not a directory!\n",TEMP_DIR); - exit(1); - } - - if ((dir_fd=open(".",O_RDONLY))<0) { - fprintf(stderr,"Failed to open ""." - " for reading - %s\n", strerror(errno)); - exit(1); - } - - if (chroot(TEMP_DIR)<0) { - fprintf(stderr,"Failed to chroot to %s - %s\n",TEMP_DIR, - strerror(errno)); - exit(1); - } - - if (fchdir(dir_fd)<0) { - fprintf(stderr,"Failed to fchdir - %s\n", - strerror(errno)); - exit(1); - } - close(dir_fd); - chdir(".."); - chroot("."); - + chroot("/"); } /* @@ -93,8 +48,6 @@ rtems_task Init( puts( "Initializing filesystem " FILESYSTEM ); test_initialize_filesystem(); - rc=chdir(BASE_FOR_TEST); - rtems_test_assert(rc==0); rc=chroot(BASE_FOR_TEST); rtems_test_assert(rc==0); @@ -102,7 +55,6 @@ rtems_task Init( test(); break_out_of_chroot(); - chdir("/"); puts( "\n\nShutting down filesystem " FILESYSTEM ); test_shutdown_filesystem(); diff --git a/testsuites/libtests/devfs01/init.c b/testsuites/libtests/devfs01/init.c index aa7b146824..27dc8d3f97 100644 --- a/testsuites/libtests/devfs01/init.c +++ b/testsuites/libtests/devfs01/init.c @@ -22,39 +22,10 @@ rtems_task Init( rtems_task_argument argument ) { - int sc; - int size; - rtems_filesystem_location_info_t *temp_loc; - rtems_device_name_t *device_name_table; - puts( "\n\n*** TEST DEVFS01 ***" ); - puts( "devFS_Show - OK" ); - sc = devFS_Show(); - rtems_test_assert( sc == 0 ); - - /* save original node access information */ - temp_loc = &rtems_filesystem_root; - device_name_table = (rtems_device_name_t *)temp_loc->node_access; - temp_loc->node_access = NULL; - - puts( "devFS_Show - no device table - EFAULT" ); - sc = devFS_Show(); - rtems_test_assert( sc == -1 ); - rtems_test_assert( errno == EFAULT ); - - /* restore node access information */ - temp_loc->node_access = device_name_table; - - /* save original device table size information */ - size = rtems_device_table_size; - rtems_device_table_size = 0; - puts( "devFS_Show - devices - OK" ); - sc = devFS_Show(); - rtems_test_assert( sc == 0 ); - - /* restore original device table size information */ - rtems_device_table_size = size; + puts( "devFS_Show" ); + devFS_Show(); puts( "*** END OF TEST DEVFS01 ***" ); diff --git a/testsuites/libtests/devfs02/init.c b/testsuites/libtests/devfs02/init.c index f648a177cf..96febbf974 100644 --- a/testsuites/libtests/devfs02/init.c +++ b/testsuites/libtests/devfs02/init.c @@ -2,6 +2,9 @@ * COPYRIGHT (c) 1989-2010. * On-Line Applications Research Corporation (OAR). * + * Modifications to support reference counting in the file system are + * Copyright (c) 2012 embedded brains GmbH. + * * 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. @@ -10,74 +13,62 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" + #include "config.h" #endif -#include <tmacros.h> #include "test_support.h" -#include <rtems/devfs.h> + +#include <tmacros.h> #include <errno.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <rtems/devfs.h> +#include <rtems/malloc.h> + rtems_task Init( rtems_task_argument argument ) { int status; - rtems_filesystem_location_info_t *temp_loc; - rtems_device_name_t *device_name_table; - int temp_size = 0; - struct stat statbuf; + rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location; + const devFS_data *data = rootloc->mt_entry->immutable_fs_info; + devFS_data zero_count_data = { + .nodes = data->nodes, + .count = 0 + }; + void *opaque; puts( "\n\n*** TEST DEVFS02 ***" ); - puts( "Init - attempt to create a fifo - expect EINVAL" ); + puts( "Init - attempt to create a fifo - expect ENOTSUP" ); status = mkfifo( "/fifo01", 0 ); rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EINVAL ); - - /* Manipulate the root */ - puts( "Init - set the device name table to NULL" ); - temp_loc = &rtems_filesystem_root; - device_name_table = (rtems_device_name_t *)temp_loc->node_access; - temp_loc->node_access = NULL; - - puts(" Init - attempt to create a node - expect EFAULT" ); - status = mknod( "/node", S_IFBLK, 0LL ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EFAULT ); + rtems_test_assert( errno == ENOTSUP ); - /* This case actually stops at evaluation of path */ - puts( "Init - attempt to stat a node - expect EFAULT" ); - status = stat( "/", &statbuf ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EFAULT ); + /* Manipulate the device table size */ + puts( "Init - set device table size to zero" ); + rootloc->mt_entry->immutable_fs_info = &zero_count_data; - puts( "Init - attempt to open a node" ); - status = open( "/node", O_RDWR ); + puts( "Init - attempt to create a node - expect ENOSPC" ); + status = mknod( "/node", S_IFBLK, 0LL ); rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EFAULT ); + rtems_test_assert( errno == ENOSPC ); /* Now restore */ - puts( "Init - restore the device name table" ); - temp_loc->node_access = device_name_table; + puts( "Init - restore device table size" ); + rootloc->mt_entry->immutable_fs_info = data; - /* Manipulate the device table size */ - puts( "Init - set device table size to zero" ); - temp_size = rtems_device_table_size; - rtems_device_table_size = 0; + opaque = rtems_heap_greedy_allocate( 0 ); puts( "Init - attempt to create a node - expect ENOMEM" ); status = mknod( "/node", S_IFBLK, 0LL ); rtems_test_assert( status == -1 ); rtems_test_assert( errno == ENOMEM ); - /* Now restore */ - puts( "Init - restore device table size" ); - rtems_device_table_size = temp_size; + rtems_heap_greedy_free( opaque ); puts( "Init - attempt to create /node -- OK" ); status = mknod( "/node", S_IFBLK, 0LL ); diff --git a/testsuites/libtests/devfs03/init.c b/testsuites/libtests/devfs03/init.c index 07e29263c5..7660227009 100644 --- a/testsuites/libtests/devfs03/init.c +++ b/testsuites/libtests/devfs03/init.c @@ -2,6 +2,9 @@ * COPYRIGHT (c) 1989-2010. * On-Line Applications Research Corporation (OAR). * + * Modifications to support reference counting in the file system are + * Copyright (c) 2012 embedded brains GmbH. + * * 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. @@ -21,15 +24,17 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> -#include <rtems/score/heap.h> rtems_task Init( rtems_task_argument argument ) { int status; - void *alloc_ptr = (void *)0; - Heap_Information_block Info; + devFS_node nodes [1]; + devFS_data data = { + .nodes = nodes, + .count = 1 + }; puts( "\n\n*** TEST DEVFS03 ***" ); @@ -37,24 +42,31 @@ rtems_task Init( status = mkdir( "/dir01", S_IRWXU ); rtems_test_assert( status == 0 ); - puts( "Init - allocating most of workspace memory" ); - status = rtems_workspace_get_information( &Info ); - rtems_test_assert( status == true ); - status = rtems_workspace_allocate( Info.Free.largest - 4, &alloc_ptr ); - rtems_test_assert( status == true ); - - puts( "Init - mount a new fs at /dir01 - expect ENOMEM" ); + puts( "Init - mount a new fs at /dir01 - expect EINVAL" ); status = mount( NULL, "/dir01", "devfs", RTEMS_FILESYSTEM_READ_WRITE, NULL ); rtems_test_assert( status == -1 ); - rtems_test_assert( errno == ENOMEM ); + rtems_test_assert( errno == EINVAL ); - puts( "Init - freeing the workspace memory" ); - status = rtems_workspace_free( alloc_ptr ); - rtems_test_assert( status == true ); + puts( "Init - mount a new fs at /dir01 - OK" ); + status = mount( NULL, + "/dir01", + "devfs", + RTEMS_FILESYSTEM_READ_WRITE, + &data ); + rtems_test_assert( status == 0 ); + + puts( "Init - make file /dir01/dev -- expect ENOTSUP" ); + status = creat( "/dir01/dev", S_IRWXU ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOTSUP ); + + puts( "Init - unmount fs at /dir01 - OK" ); + status = unmount( "/dir01" ); + rtems_test_assert( status == 0 ); status = rmdir( "/dir01" ); rtems_test_assert( status == 0 ); @@ -69,6 +81,7 @@ rtems_task Init( #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4 #define CONFIGURE_MAXIMUM_TASKS 1 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE diff --git a/testsuites/psxtests/psxchroot01/test.c b/testsuites/psxtests/psxchroot01/test.c index a5714253b4..95a4ee10e3 100644 --- a/testsuites/psxtests/psxchroot01/test.c +++ b/testsuites/psxtests/psxchroot01/test.c @@ -1,23 +1,10 @@ /* - * This is a native test to explore how the readdir() family works. - * Newlib supports the following readdir() family members: - * - * closedir() - - * readdir() - - * scandir() - - * opendir() - - * rewinddir() - - * telldir() - BSD not in POSIX - * seekdir() - BSD not in POSIX - * - * - * seekdir() takes an offset which is a byte offset. The Linux - * implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1) - * record where DIRENT_SIZE seems to be 12 bytes. - * * COPYRIGHT (c) 1989-2010. * On-Line Applications Research Corporation (OAR). * + * Modifications to support reference counting in the file system are + * Copyright (c) 2012 embedded brains GmbH. + * * 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. @@ -37,10 +24,11 @@ #include <errno.h> #include <rtems/libio.h> #include <rtems/userenv.h> +#include <rtems/malloc.h> #include <pmacros.h> #include <rtems/libcsupport.h> -void touch( char *file ) +static void touch( char *file ) { int fd; @@ -51,7 +39,7 @@ void touch( char *file ) close( fd ); } -int fileexists( char *file ) +static int fileexists( char *file ) { int status; struct stat statbuf; @@ -77,7 +65,7 @@ int main( #endif { int status; - void *alloc_ptr = (void *)0; + void *opaque; /* * This test is the C equivalent of this sequence. #mkdir /one @@ -108,21 +96,27 @@ int main( touch( "/one/one.test" ); touch( "/one/two/two.test" ); - puts( "allocate most of memory - attempt to fail chroot - expect ENOTSUP" ); - alloc_ptr = malloc( malloc_free_space() - 4 ); - rtems_test_assert( alloc_ptr != NULL ); + puts( "chroot with bad path - expect ENOENT" ); + status = chroot( "/three" ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOENT ); - status = chroot( "/one" ); + puts( "chroot with file - expect ENOTDIR" ); + status = chroot( "/one/one.test" ); rtems_test_assert( status == -1 ); - rtems_test_assert( errno == ENOTSUP ); + rtems_test_assert( errno == ENOTDIR ); - puts( "freeing the allocated memory" ); - free( alloc_ptr ); + puts( "allocate most of memory - attempt to fail chroot - expect ENOMEM" ); + opaque = rtems_heap_greedy_allocate( + sizeof(rtems_filesystem_global_location_t) + ); - puts( "chroot with bad path - expect EFAULT" ); - status = chroot( NULL ); + status = chroot( "/one" ); rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EFAULT ); + rtems_test_assert( errno == ENOMEM ); + + puts( "freeing the allocated memory" ); + rtems_heap_greedy_free( opaque ); status = chroot( "/one" ); rtems_test_assert( status == 0 ); @@ -133,8 +127,8 @@ int main( status = fileexists( "/two/two.test" ); printf( "%s on /two/two.test\n", (status) ? "SUCCESS" : "FAILURE" ); - puts( "Reset the private environment" ); - rtems_libio_set_private_env(); + puts( "Go back to global environment" ); + rtems_libio_use_global_env(); status = fileexists( "/one/one.test" ); printf( "%s on /one/one.test\n", ( status) ? "SUCCESS" : "FAILURE" ); diff --git a/testsuites/psxtests/psxfchx01/init.c b/testsuites/psxtests/psxfchx01/init.c index 9b984cd71e..7ef030e5dc 100644 --- a/testsuites/psxtests/psxfchx01/init.c +++ b/testsuites/psxtests/psxfchx01/init.c @@ -47,7 +47,7 @@ rtems_task Init( rtems_test_assert( errno == EBADF ); puts( "Init - opening /newfile in write-mode -- OK" ); - fd = open( "/newfile", O_WRONLY | O_CREAT, S_IWUSR ); + fd = open( "/newfile", O_WRONLY | O_CREAT, S_IWUSR | S_IXUSR ); rtems_test_assert( fd != -1 ); puts( "Init - fchdir on the file descriptor - expect ENOTDIR" ); @@ -64,7 +64,7 @@ rtems_task Init( rtems_test_assert( status == 0 ); puts( "Init - opening /newfile in read-mode -- OK" ); - fd = open( "/newfile", O_RDONLY | O_CREAT, S_IRUSR); + fd = open( "/newfile", O_RDONLY | O_CREAT, S_IRUSR | S_IXUSR); rtems_test_assert( fd != -1 ); puts( "Init - fchdir on the file descriptor - expect ENOTDIR" ); diff --git a/testsuites/psxtests/psxfile01/main.c b/testsuites/psxtests/psxfile01/main.c index 8abf3a66d6..3f8d9b88e3 100644 --- a/testsuites/psxtests/psxfile01/main.c +++ b/testsuites/psxtests/psxfile01/main.c @@ -39,6 +39,7 @@ rtems_task Init( #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 6 #define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_INIT_TASK_STACK_SIZE (2 * RTEMS_MINIMUM_STACK_SIZE) #define CONFIGURE_RTEMS_INIT_TASKS_TABLE diff --git a/testsuites/psxtests/psxfile01/test.c b/testsuites/psxtests/psxfile01/test.c index 0474021967..a82303bd17 100644 --- a/testsuites/psxtests/psxfile01/test.c +++ b/testsuites/psxtests/psxfile01/test.c @@ -224,11 +224,6 @@ int main( rtems_test_assert( status == -1 ); rtems_test_assert( errno == EEXIST ); - /* test rtems_filesystem_evaluate_path by sending NULL path */ - status = chdir( NULL ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EFAULT ); - /* * Now switch gears and exercise rmdir(). */ @@ -253,11 +248,6 @@ int main( rtems_test_assert( status == -1 ); rtems_test_assert( errno == ENOENT ); - puts( "unlink /dev/tty" ); - status = unlink( "/dev/tty" ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EISDIR ); - puts( "mknod /dev/test_console" ); status = mknod( "/dev/test_console", S_IFCHR, 0LL ); rtems_test_assert( !status ); diff --git a/testsuites/psxtests/psximfs02/init.c b/testsuites/psxtests/psximfs02/init.c index 7ae97705a5..d170d4ef6f 100644 --- a/testsuites/psxtests/psximfs02/init.c +++ b/testsuites/psxtests/psximfs02/init.c @@ -22,6 +22,7 @@ #include <fcntl.h> #include <errno.h> #include <rtems/libio.h> +#include <rtems/malloc.h> #include <rtems/libcsupport.h> #if !HAVE_DECL_SETEUID @@ -34,11 +35,14 @@ rtems_task Init( ) { int status = 0; - void *alloc_ptr = (void *)0; + void *opaque; char linkname_n[20] = {0}; char linkname_p[20] = {0}; int i; struct stat stat_buf; + static const char mount_point [] = "dir01"; + static const char fs_type [] = RTEMS_FILESYSTEM_TYPE_IMFS; + static const char slink_2_name [] = "node-slink-2"; puts( "\n\n*** TEST IMFS 02 ***" ); @@ -92,27 +96,31 @@ rtems_task Init( rtems_test_assert( errno == EACCES ); puts( "Allocate most of heap" ); - alloc_ptr = malloc( malloc_free_space() - 150 ); + opaque = rtems_heap_greedy_allocate( + sizeof( rtems_filesystem_mount_table_entry_t ) + + sizeof( fs_type ) + + sizeof( rtems_filesystem_global_location_t ) + ); - puts( "Attempt to mount a fs at /dir01 -- expect ENOMEM" ); + printf( "Attempt to mount a fs at %s -- expect ENOMEM", mount_point ); status = mount( NULL, - "dir01", - "imfs", + mount_point, + fs_type, 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" ); - alloc_ptr = malloc( malloc_free_space() - 4 ); + rtems_heap_greedy_free( opaque ); puts( "Changing directory to /" ); status = chdir( "/" ); rtems_test_assert( status == 0 ); + puts( "Allocate most of heap" ); + opaque = rtems_heap_greedy_allocate( 0 ); + puts( "Attempt to create /node-link-2 for /node -- expect ENOMEM" ); status = link( "/node", "/node-link-2" ); rtems_test_assert( status == -1 ); @@ -124,23 +132,22 @@ rtems_task Init( rtems_test_assert( errno == ENOMEM ); puts( "Freeing allocated memory" ); - free( alloc_ptr ); + rtems_heap_greedy_free( opaque ); puts( "Allocate most of heap" ); - alloc_ptr = malloc( malloc_free_space() - 40 ); + opaque = rtems_heap_greedy_allocate( sizeof( slink_2_name ) ); - puts( "Attempt to create /node-slink-2 for /node -- expect ENOMEM" ); - status = symlink( "/node", "node-slink-2" ); + printf( "Attempt to create %s for /node -- expect ENOMEM", slink_2_name ); + status = symlink( "/node", slink_2_name ); rtems_test_assert( status == -1 ); rtems_test_assert( errno == ENOMEM ); puts( "Freeing allocated memory" ); - free( alloc_ptr ); + rtems_heap_greedy_free( opaque ); - puts( "Attempt to stat a hardlink -- expect ENOTSUP" ); + puts( "Attempt to stat a hardlink" ); status = lstat( "/node-link", &stat_buf ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == ENOTSUP ); + rtems_test_assert( status == 0 ); puts( "Changing euid to 10" ); status = seteuid( 10 ); diff --git a/testsuites/psxtests/psxmount/test.c b/testsuites/psxtests/psxmount/test.c index 7e1c84fcda..1e80376685 100644 --- a/testsuites/psxtests/psxmount/test.c +++ b/testsuites/psxtests/psxmount/test.c @@ -1,23 +1,10 @@ /* - * This is a native test to explore how the readdir() family works. - * Newlib supports the following readdir() family members: - * - * closedir() - - * readdir() - - * scandir() - - * opendir() - - * rewinddir() - - * telldir() - BSD not in POSIX - * seekdir() - BSD not in POSIX - * - * - * seekdir() takes an offset which is a byte offset. The Linux - * implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1) - * record where DIRENT_SIZE seems to be 12 bytes. - * * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * + * Modifications to support reference counting in the file system are + * Copyright (c) 2012 embedded brains GmbH. + * * 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. @@ -41,8 +28,6 @@ #include <rtems/libio.h> #include <pmacros.h> -extern rtems_filesystem_location_info_t rtems_filesystem_current; - DIR *directory; DIR *directory2; DIR *directory3; @@ -100,7 +85,9 @@ int main( int status; struct stat statbuf; static char mount_point_string[25] = { "/c/z/my_mount_point" }; - + static const char my_sub_fs_dir [] = "/c/y/my_mount_point/my_sub_fs_dir"; + static const char my_link [] = "/c/y/my_link"; + static const char mount_point [] = "/c/y/my_mount_point"; printf( "\n\n*** MOUNT/UNMOUNT TEST ***\n" ); @@ -293,7 +280,7 @@ int main( /* - * Verify we cannot unmount a file system while we are in it. + * Verify we can unmount a file system while we are in it. */ printf("Create and chdir to /c/y/my_mount_point/mydir\n"); @@ -303,22 +290,27 @@ int main( status = chdir( "/c/y/my_mount_point/mydir" ); rtems_test_assert( status == 0 ); - printf("unmount of /c/y/my_mount_point should fail with EBUSY\n"); + printf("unmount of /c/y/my_mount_point\n"); status = unmount( "/c/y/my_mount_point" ); + rtems_test_assert( status == 0 ); + + printf("chdir to .. should fail with ENXIO\n"); + status = chdir( ".." ); rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EBUSY ); + rtems_test_assert( errno == ENXIO ); /* - * Chdir to root and verify we can unmount the file system now. + * Chdir to root and verify we unmounted the file system now. */ printf("chdir to / and verify we can unmount /c/y/my_mount_point\n"); status = chdir( "/" ); rtems_test_assert( status == 0 ); - printf("unmount /c/y/my_mount_point \n"); - status = unmount( "/c/y/my_mount_point" ); - rtems_test_assert( status == 0 ); + printf("chdir to /c/y/my_mount_point/my_dir should fail with ENOENT\n"); + status = chdir( "/c/y/my_mount_point/mydir" ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOENT ); /* * Attempt to unmount a directory that does not exist. @@ -344,7 +336,7 @@ int main( /* * Create a file and directory then open the directory. - * Verify unmount will return EBUSY while directory is open. + * Verify unmount will return successful while directory is open. */ printf("Create and open /c/y/my_mount_point/my_file\n"); @@ -353,21 +345,34 @@ int main( status = close( fd ); rtems_test_assert( status == 0 ); - printf("\nmkdir /c/y/my_mount_point/my_dir\n"); - status = mkdir( "/c/y/my_mount_point/my_dir", 0x1c0 ); - printf("Open /c/y/my_mount_point/my_dir\n"); - directory = opendir( "/c/y/my_mount_point/my_dir" ); + printf("\nmkdir %s\n", my_sub_fs_dir ); + status = mkdir( my_sub_fs_dir, S_IRWXU ); + + printf("open %s\n", my_sub_fs_dir ); + directory = opendir( my_sub_fs_dir ); rtems_test_assert( directory ); - printf("Unmount /c/y/my_mount_point should fail with EBUSY\n"); - status = unmount( "/c/y/my_mount_point" ); + printf("mkdir %s should fail with EEXIST\n", my_sub_fs_dir ); + status = mkdir( my_sub_fs_dir, S_IRWXU ); rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EBUSY ); + rtems_test_assert( errno == EEXIST ); - printf("Close /c/y/my_mount_point/my_dir\n"); + printf("unmount %s\n", mount_point ); + status = unmount( mount_point ); + rtems_test_assert( status == 0 ); + + printf("close %s\n", my_sub_fs_dir ); status = closedir( directory ); rtems_test_assert( status == 0 ); + printf("mkdir %s\n", my_sub_fs_dir ); + status = mkdir( my_sub_fs_dir, S_IRWXU ); + rtems_test_assert( status == 0 ); + + printf("rmdir %s\n", my_sub_fs_dir ); + status = rmdir( my_sub_fs_dir ); + rtems_test_assert( status == 0 ); + /* * Attempt to unmount a directory that is not a mount point. */ @@ -378,33 +383,27 @@ int main( rtems_test_assert( errno == EACCES ); /* - * Verify a file system can not be unmounted with a mounted file system - * in it. + * Mount file system */ - printf("Mount a file system at /c/y/my_mount_point/my_dir\n"); + printf("Mount a file system at %s\n", mount_point); status = mount( "null", - "/c/y/my_mount_point/my_dir", + mount_point, "imfs", RTEMS_FILESYSTEM_READ_WRITE, NULL ); rtems_test_assert( status == 0 ); - printf("unmount /c/y/my_mount_point should fail with EBUSY\n"); - status = unmount( "/c/y/my_mount_point" ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EBUSY ); - /* * Verify you cannot create a hard link across mounted file systems. */ printf("Verify a hard link across filesystems fails with EXDEV\n"); - status = mkdir( "/c/y/my_mount_point/my_dir2", S_IRWXU ); + status = mkdir( my_sub_fs_dir, S_IRWXU ); rtems_test_assert( status == 0 ); - status = link( "/c/y/my_mount_point/my_dir2", "/c/y/my_mount_point/my_dir/my_link" ); + status = link( my_sub_fs_dir, my_link ); rtems_test_assert( status == -1 ); rtems_test_assert( errno == EXDEV ); @@ -413,13 +412,13 @@ int main( */ printf("Verify a symbolic link across file systems works\n"); - status = symlink( "/c/y/my_mount_point/my_dir2", "/c/y/my_mount_point/my_dir/my_link" ); + status = symlink( my_sub_fs_dir, my_link ); rtems_test_assert( status == 0 ); - status = stat( "/c/y/my_mount_point/my_dir/my_link", &statbuf ); + status = stat( my_link, &statbuf ); rtems_test_assert( status == 0 ); - printf("unmount /c/y/my_mount_point/my_dir\n"); - status = unmount( "/c/y/my_mount_point/my_dir" ); + printf("unmount %s\n", mount_point); + status = unmount( mount_point ); rtems_test_assert( status == 0 ); /* @@ -427,12 +426,9 @@ int main( */ printf("Verify the symbolic link now fails\n"); - status = stat( "/c/y/my_mount_point/my_dir/my_link", &statbuf ); - rtems_test_assert( status != 0 ); - - printf("unmount /c/y/my_mount_point\n"); - status = unmount( "/c/y/my_mount_point" ); - rtems_test_assert( status == 0 ); + status = stat( my_link, &statbuf ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOENT ); printf( "\n\n*** END OF MOUNT/UNMOUNT TEST ***\n" ); rtems_test_exit(0); diff --git a/testsuites/psxtests/psxreaddir/test.c b/testsuites/psxtests/psxreaddir/test.c index e3b30822c9..8ea67ccdda 100644 --- a/testsuites/psxtests/psxreaddir/test.c +++ b/testsuites/psxtests/psxreaddir/test.c @@ -230,6 +230,8 @@ int main( ) #endif { + static const char *my_file = "/b/my_file"; + int fd; int i; int status; @@ -277,14 +279,14 @@ int main( d_not = readdir( directory_not ); rtems_test_assert( d_not == 0 ); - printf("open /b/myfile\n"); - fd = open ("/b/my_file", O_CREAT, S_IRWXU); + printf("open %s\n", my_file); + fd = open (my_file, O_CREAT, S_IRWXU); rtems_test_assert( fd != -1 ); close (fd); printf("scandir a file status: "); status = scandir( - "/b/my_file", + my_file, &namelist, select1, NULL @@ -303,13 +305,13 @@ int main( status = fcntl( fd, F_GETFD, 1 ); rtems_test_assert( status == 1 ); -#if 0 - printf("fcntl F_DUPFD should return 0\n"); + printf("fcntl F_DUPFD should return a file descriptor\n"); status = fcntl( fd, F_DUPFD, 0 ); + rtems_test_assert ( status >= 0 ); + + printf("close duplicate should return 0\n"); + status = close( status ); rtems_test_assert ( status == 0 ); -#else - printf("fcntl F_DUPFD should return 0 -- skip until implemented\n"); -#endif printf("fcntl F_GETFL returns current flags\n"); status = fcntl( fd, F_GETFL, 1 ); @@ -350,16 +352,28 @@ int main( printf("Status %d\n",status); rtems_test_assert( status == -1 ); - printf("opendir and readdir /b/myfile\n"); - directory_not = opendir ("/b/my_file"); + printf("close should return 0\n"); + status = close( fd ); + rtems_test_assert ( status == 0 ); + + printf("opendir, readdir and closedir %s\n", my_file); + directory_not = opendir (my_file); + rtems_test_assert( directory_not != NULL ); d_not = readdir(directory_not); + rtems_test_assert( d_not == NULL ); + status = closedir (directory_not); + rtems_test_assert (status == 0); - printf("opendir and readdir\n"); + printf("opendir, readdir and closedir\n"); directory_not = opendir ("/a"); + rtems_test_assert( directory_not != NULL ); d_not = readdir (directory_not); + rtems_test_assert( d_not == NULL ); + status = closedir (directory_not); + rtems_test_assert (status == 0); - printf("chdir to /b/myfile\n"); - status = chdir ("/b/my_file"); + printf("chdir to %s\n", my_file); + status = chdir (my_file); rtems_test_assert (status == -1); printf( "\nPerforming stat of directory /\n"); @@ -500,6 +514,10 @@ int main( printf("Selected and Sorted Node Name: %s\n", namelist[i]->d_name ); } + printf("unlink %s should return 0\n", my_file); + status = unlink( my_file ); + rtems_test_assert ( status == 0 ); + test_across_mount(); printf( "\n\n*** END OF READDIR TEST ***\n" ); rtems_test_exit(0); diff --git a/testsuites/psxtests/psxstat/test.c b/testsuites/psxtests/psxstat/test.c index c5d344d8fc..ecc82e531b 100644 --- a/testsuites/psxtests/psxstat/test.c +++ b/testsuites/psxtests/psxstat/test.c @@ -45,7 +45,7 @@ int _lstat_r(struct _reent *, const char *, struct stat *); */ char *Files[] = { - "/////my_mount_point/dir1/\\//file1\\\\//", + "/////my_mount_point/dir1/\\//file1", "/my_mount_point/dir1/file2", "/my_mount_point/dir1/file3", "/my_mount_point/dir1/file4", @@ -60,7 +60,7 @@ char *Files[] = { */ char *Directories[] = { - "/my_mount_point/dir1", + "/my_mount_point/dir1\\\\//", "/my_mount_point/dir2", "/my_mount_point/dir3", "/my_mount_point/dir4", @@ -589,15 +589,6 @@ void Cause_faults(void) rtems_test_assert( errno == EACCES ); /* - * Check stat with a NULL buffer. - */ - - printf("Stat with a NULL buffer should fail with EFAULT\n"); - status = stat( Directories[0], NULL ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EFAULT ); - - /* * Set current to a directory with no owner permissions. * Verify it works properly. */ @@ -685,13 +676,8 @@ void Cause_faults(void) * Check rmdir, rmnod, and unlink */ - printf("rmdir %s should fail with ENOTDIR\n", Links_to_Dirs[5] ); + printf("rmdir %s\n", Links_to_Dirs[5] ); status = rmdir( Links_to_Dirs[5] ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == ENOTDIR ); - - printf("unlink %s\n", Links_to_Dirs[5] ); - status = unlink( Links_to_Dirs[5] ); rtems_test_assert( status == 0 ); printf("unlink %s should fail with ENOTEMPTY\n", Links_to_dirlinks[5] ); @@ -757,11 +743,6 @@ void Cause_faults(void) printf("Making too many hard links.\n" ); make_too_many_links( ); - printf( "pass fstat a null pointer should fail with EFAULT\n"); - status = fstat( fd, NULL ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EFAULT); - /* * The current directory MUST be restored at the end of this test. */ @@ -789,10 +770,10 @@ void test_statvfs( void ) int status = 0; struct statvfs stat; - puts( "statvfs, with invalid path - expect ENOTSUP" ); + puts( "statvfs, with invalid path - expect ENOENT" ); status = statvfs( "" , &stat ); rtems_test_assert( status == -1 ); - rtems_test_assert( errno == ENOTSUP ); + rtems_test_assert( errno == ENOENT ); puts( "create /tmp -- OK" ); status = mkdir( "/tmp", 0777 ); @@ -944,21 +925,6 @@ int main( test_statvfs(); - puts( "Exercise the reentrant version - _stat_r - expect EFAULT" ); - status = _stat_r( NULL, NULL, NULL ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EFAULT ); - - puts( "Exercise the reentrant version - _lstat_r - expect EFAULT" ); - status = _lstat_r( NULL, NULL, NULL ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EFAULT ); - - puts( "Try readlink with a bad buffer - expect EFAULT" ); - status = readlink( "/tmp", NULL, 0 ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EFAULT ); - puts( "\n\n*** END OF STAT TEST 01 ***" ); rtems_test_exit(0); } diff --git a/testsuites/sptests/spprivenv01/init.c b/testsuites/sptests/spprivenv01/init.c index 3bd6958d2b..9fb1cec6c3 100644 --- a/testsuites/sptests/spprivenv01/init.c +++ b/testsuites/sptests/spprivenv01/init.c @@ -16,6 +16,7 @@ #include <tmacros.h> #include "test_support.h" #include <rtems/libio_.h> +#include <rtems/malloc.h> #include <rtems/libcsupport.h> rtems_task task_routine( rtems_task_argument not_used ) @@ -36,8 +37,7 @@ rtems_task Init( ) { rtems_status_code sc; - bool status; - void *alloc_ptr; + void *opaque; rtems_id current_task_id; rtems_id task_id; rtems_name another_task_name; @@ -46,29 +46,24 @@ rtems_task Init( puts( "\n\n*** TEST USER ENVIRONMENT ROUTINE - 01 ***" ); puts( "Init - allocating most of heap -- OK" ); - alloc_ptr = malloc( malloc_free_space() - 4 ); - rtems_test_assert( alloc_ptr != NULL ); + opaque = rtems_heap_greedy_allocate( 0 ); puts( "Init - attempt to reset env - expect RTEMS_NO_MEMORY" ); sc = rtems_libio_set_private_env(); rtems_test_assert( sc == RTEMS_NO_MEMORY ); puts( "Init - freeing the allocated memory" ); - free( alloc_ptr ); + rtems_heap_greedy_free( opaque ); puts( "Init - allocating most of workspace memory" ); - status = rtems_workspace_get_information( &Info ); - rtems_test_assert( status == true ); - status = rtems_workspace_allocate( Info.Free.largest - 4, &alloc_ptr ); - rtems_test_assert( status == true ); + opaque = rtems_workspace_greedy_allocate( 0 ); - puts( "Init - attempt to reset env - expect RTEMS_NO_MEMORY" ); + puts( "Init - attempt to reset env - expect RTEMS_TOO_MANY" ); sc = rtems_libio_set_private_env(); - rtems_test_assert( sc == RTEMS_NO_MEMORY ); + rtems_test_assert( sc == RTEMS_TOO_MANY ); puts( "Init - freeing the workspace memory" ); - status = rtems_workspace_free( alloc_ptr ); - rtems_test_assert( status == true ); + rtems_workspace_greedy_free( opaque ); puts( "Init - creating a task name and a task -- OK" ); @@ -84,12 +79,12 @@ rtems_task Init( ); puts( "Init - starting the task_routine, to set its private environment" ); - status = rtems_task_start( task_id, task_routine, 0); - rtems_test_assert(status == 0); + sc = rtems_task_start( task_id, task_routine, 0); + rtems_test_assert( sc == RTEMS_SUCCESSFUL ); puts( "Init - attempt to share the env with another task -- Expect error" ); sc = rtems_libio_share_private_env( task_id ); - rtems_test_assert( sc == RTEMS_INVALID_ADDRESS ); + rtems_test_assert( sc == RTEMS_UNSATISFIED ); sleep( 1 ); |