diff options
Diffstat (limited to 'testsuites/fstests')
-rw-r--r-- | testsuites/fstests/Makefile.am | 1 | ||||
-rw-r--r-- | testsuites/fstests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/fstests/fserror/test.c | 25 | ||||
-rw-r--r-- | testsuites/fstests/fsnofs01/Makefile.am | 20 | ||||
-rw-r--r-- | testsuites/fstests/fsnofs01/fsnofs01.doc | 11 | ||||
-rw-r--r-- | testsuites/fstests/fsnofs01/fsnofs01.scn | 2 | ||||
-rw-r--r-- | testsuites/fstests/fsnofs01/init.c | 364 | ||||
-rw-r--r-- | testsuites/fstests/mrfs_support/fs_support.c | 2 | ||||
-rw-r--r-- | testsuites/fstests/support/fstest_support.c | 50 |
9 files changed, 423 insertions, 53 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(); |