diff options
author | Andrei Mozzhuhin <nopscmn@gmail.com> | 2013-05-16 11:23:46 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-05-16 11:40:41 +0200 |
commit | 56f2260008ad5425ec89bfacafe9146422c2c3a7 (patch) | |
tree | 839bc4b6cc2f7bad839ded284522b18f90d33d37 /testsuites | |
parent | shell: Fix NULL pointer access (diff) | |
download | rtems-56f2260008ad5425ec89bfacafe9146422c2c3a7.tar.bz2 |
dosfs: Add statvfs() support
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/fstests/Makefile.am | 1 | ||||
-rw-r--r-- | testsuites/fstests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/fstests/fsstatvfs/fsstatvfs.doc | 21 | ||||
-rw-r--r-- | testsuites/fstests/fsstatvfs/test.c | 88 | ||||
-rw-r--r-- | testsuites/fstests/mdosfs_fsstatvfs/Makefile.am | 30 |
5 files changed, 141 insertions, 0 deletions
diff --git a/testsuites/fstests/Makefile.am b/testsuites/fstests/Makefile.am index 516138027b..f39055ee28 100644 --- a/testsuites/fstests/Makefile.am +++ b/testsuites/fstests/Makefile.am @@ -15,6 +15,7 @@ SUBDIRS += imfs_fstime SUBDIRS += mdosfs_fserror SUBDIRS += mdosfs_fspatheval SUBDIRS += mdosfs_fsrdwr +SUBDIRS += mdosfs_fsstatvfs SUBDIRS += mdosfs_fstime SUBDIRS += mimfs_fserror SUBDIRS += mimfs_fslink diff --git a/testsuites/fstests/configure.ac b/testsuites/fstests/configure.ac index 4993beb7c5..8985464a03 100644 --- a/testsuites/fstests/configure.ac +++ b/testsuites/fstests/configure.ac @@ -91,6 +91,7 @@ imfs_fstime/Makefile mdosfs_fserror/Makefile mdosfs_fspatheval/Makefile mdosfs_fsrdwr/Makefile +mdosfs_fsstatvfs/Makefile mdosfs_fstime/Makefile mimfs_fserror/Makefile mimfs_fslink/Makefile diff --git a/testsuites/fstests/fsstatvfs/fsstatvfs.doc b/testsuites/fstests/fsstatvfs/fsstatvfs.doc new file mode 100644 index 0000000000..85c329dfd1 --- /dev/null +++ b/testsuites/fstests/fsstatvfs/fsstatvfs.doc @@ -0,0 +1,21 @@ +# COPYRIGHT (c) 2013 Andrey Mozzhuhin +# +# 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: fsstatvfs + +directives: + ++ statvfs + + + +concepts: + ++ Check that filesystem provide valid statistics + diff --git a/testsuites/fstests/fsstatvfs/test.c b/testsuites/fstests/fsstatvfs/test.c new file mode 100644 index 0000000000..88952ef156 --- /dev/null +++ b/testsuites/fstests/fsstatvfs/test.c @@ -0,0 +1,88 @@ +/* + * COPYRIGHT (c) 2013 Andrey Mozzhuhin + * + * 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 <sys/statvfs.h> +#include <string.h> +#include <fcntl.h> + +#include "fstest.h" +#include "pmacros.h" + +static void statvfs_validate(struct statvfs *stat) +{ + rtems_test_assert(stat->f_bsize > 0); + rtems_test_assert(stat->f_frsize > 0); + rtems_test_assert(stat->f_blocks > 0); + rtems_test_assert(stat->f_bfree <= stat->f_blocks); + rtems_test_assert(stat->f_bavail <= stat->f_blocks); + rtems_test_assert(stat->f_ffree <= stat->f_files); + rtems_test_assert(stat->f_favail <= stat->f_files); + rtems_test_assert(stat->f_namemax > 0); +} + +static void statvfs_test01(void) +{ + struct statvfs statbuf1, statbuf2; + int status; + int fd; + ssize_t n; + const char *databuf = "STATVFS"; + int datalen = strlen(databuf); + const char *filename = __func__; + + /* + * Get current filesystem statistics + */ + status = statvfs("/", &statbuf1); + rtems_test_assert(status == 0); + statvfs_validate(&statbuf1); + + /* + * Create one file + */ + fd = open(filename, O_CREAT | O_WRONLY, 0775); + rtems_test_assert(fd >= 0); + n = write(fd, databuf, datalen); + rtems_test_assert(n == datalen); + status = close(fd); + rtems_test_assert(status == 0); + + /* + * Get new filesystem statistics + */ + status = statvfs("/", &statbuf2); + rtems_test_assert(status == 0); + statvfs_validate(&statbuf2); + + /* + * Compare old and new statistics + */ + rtems_test_assert(statbuf1.f_bsize == statbuf2.f_bsize); + rtems_test_assert(statbuf1.f_frsize == statbuf2.f_frsize); + rtems_test_assert(statbuf1.f_blocks == statbuf2.f_blocks); + rtems_test_assert(statbuf1.f_bfree >= statbuf2.f_bfree); + rtems_test_assert(statbuf1.f_bavail >= statbuf2.f_bavail); + rtems_test_assert(statbuf1.f_ffree >= statbuf2.f_ffree); + rtems_test_assert(statbuf1.f_favail >= statbuf2.f_favail); + rtems_test_assert(statbuf1.f_namemax == statbuf2.f_namemax); +} + +/* + * These tests only get time_t value, and test + * if they are changed. Thest tests don't check atime + */ +void test(void) +{ + puts( "\n\n*** STATVFS TEST ***"); + statvfs_test01(); + puts( "*** END OF STATVFS TEST ***"); +} diff --git a/testsuites/fstests/mdosfs_fsstatvfs/Makefile.am b/testsuites/fstests/mdosfs_fsstatvfs/Makefile.am new file mode 100644 index 0000000000..bb0d2ef505 --- /dev/null +++ b/testsuites/fstests/mdosfs_fsstatvfs/Makefile.am @@ -0,0 +1,30 @@ + +rtems_tests_PROGRAMS = mdosfs_fsstatvfs +mdosfs_fsstatvfs_SOURCES = ../fsstatvfs/test.c +mdosfs_fsstatvfs_SOURCES += ../support/ramdisk_support.c +mdosfs_fsstatvfs_SOURCES += ../support/fstest_support.c +mdosfs_fsstatvfs_SOURCES += ../support/fstest_support.h +mdosfs_fsstatvfs_SOURCES += ../support/ramdisk_support.h +mdosfs_fsstatvfs_SOURCES += ../support/fstest.h +mdosfs_fsstatvfs_SOURCES += ../../psxtests/include/pmacros.h +mdosfs_fsstatvfs_SOURCES += ../mdosfs_support/fs_support.c +mdosfs_fsstatvfs_SOURCES += ../mdosfs_support/fs_config.h + +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 +AM_CPPFLAGS += -I$(top_srcdir)/mdosfs_support +AM_CPPFLAGS += -I$(top_srcdir)/../support/include +AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include + +LINK_OBJS = $(mdosfs_fsstatvfs_OBJECTS) +LINK_LIBS = $(mdosfs_fsstatvfs_LDLIBS) + +mdosfs_ffsstatvfs$(EXEEXT): $(mdosfs_fsstatvfs_OBJECTS) $(mdosfs_fsstatvfs_DEPENDENCIES) + @rm -f mdosfs_fsstatvfs$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am |