[PATCH 5/5 v2] JFFS2: New tests
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Sep 16 09:01:03 UTC 2013
---
testsuites/fstests/Makefile.am | 7 +
testsuites/fstests/configure.ac | 7 +
testsuites/fstests/jffs2_fserror/Makefile.am | 31 ++++
testsuites/fstests/jffs2_fslink/Makefile.am | 31 ++++
testsuites/fstests/jffs2_fspatheval/Makefile.am | 31 ++++
testsuites/fstests/jffs2_fspermission/Makefile.am | 31 ++++
testsuites/fstests/jffs2_fsrdwr/Makefile.am | 31 ++++
testsuites/fstests/jffs2_fssymlink/Makefile.am | 31 ++++
testsuites/fstests/jffs2_fstime/Makefile.am | 31 ++++
testsuites/fstests/jffs2_support/fs_config.h | 20 +++
testsuites/fstests/jffs2_support/fs_support.c | 160 +++++++++++++++++++++
11 files changed, 411 insertions(+), 0 deletions(-)
create mode 100644 testsuites/fstests/jffs2_fserror/Makefile.am
create mode 100644 testsuites/fstests/jffs2_fslink/Makefile.am
create mode 100644 testsuites/fstests/jffs2_fspatheval/Makefile.am
create mode 100644 testsuites/fstests/jffs2_fspermission/Makefile.am
create mode 100644 testsuites/fstests/jffs2_fsrdwr/Makefile.am
create mode 100644 testsuites/fstests/jffs2_fssymlink/Makefile.am
create mode 100644 testsuites/fstests/jffs2_fstime/Makefile.am
create mode 100644 testsuites/fstests/jffs2_support/fs_config.h
create mode 100644 testsuites/fstests/jffs2_support/fs_support.c
diff --git a/testsuites/fstests/Makefile.am b/testsuites/fstests/Makefile.am
index bfc8ebd..ed87f1b 100644
--- a/testsuites/fstests/Makefile.am
+++ b/testsuites/fstests/Makefile.am
@@ -13,6 +13,13 @@ SUBDIRS += imfs_fspermission
SUBDIRS += imfs_fsrdwr
SUBDIRS += imfs_fssymlink
SUBDIRS += imfs_fstime
+SUBDIRS += jffs2_fserror
+SUBDIRS += jffs2_fslink
+SUBDIRS += jffs2_fspatheval
+SUBDIRS += jffs2_fspermission
+SUBDIRS += jffs2_fsrdwr
+SUBDIRS += jffs2_fssymlink
+SUBDIRS += jffs2_fstime
SUBDIRS += mdosfs_fserror
SUBDIRS += mdosfs_fspatheval
SUBDIRS += mdosfs_fsrdwr
diff --git a/testsuites/fstests/configure.ac b/testsuites/fstests/configure.ac
index bd28b31..571f428 100644
--- a/testsuites/fstests/configure.ac
+++ b/testsuites/fstests/configure.ac
@@ -89,6 +89,13 @@ imfs_fspermission/Makefile
imfs_fsrdwr/Makefile
imfs_fssymlink/Makefile
imfs_fstime/Makefile
+jffs2_fserror/Makefile
+jffs2_fslink/Makefile
+jffs2_fspatheval/Makefile
+jffs2_fspermission/Makefile
+jffs2_fsrdwr/Makefile
+jffs2_fssymlink/Makefile
+jffs2_fstime/Makefile
mdosfs_fserror/Makefile
mdosfs_fspatheval/Makefile
mdosfs_fsrdwr/Makefile
diff --git a/testsuites/fstests/jffs2_fserror/Makefile.am b/testsuites/fstests/jffs2_fserror/Makefile.am
new file mode 100644
index 0000000..de14c06
--- /dev/null
+++ b/testsuites/fstests/jffs2_fserror/Makefile.am
@@ -0,0 +1,31 @@
+
+rtems_tests_PROGRAMS = jffs2_fserror
+jffs2_fserror_SOURCES = ../fserror/test.c
+jffs2_fserror_SOURCES += ../support/fstest_support.c
+jffs2_fserror_SOURCES += ../support/fstest_support.h
+jffs2_fserror_SOURCES += ../support/fstest.h
+jffs2_fserror_SOURCES += ../../psxtests/include/pmacros.h
+jffs2_fserror_SOURCES += ../jffs2_support/fs_support.c
+jffs2_fserror_SOURCES += ../jffs2_support/fs_config.h
+
+#dist_rtems_tests_DATA = jffs2_fserror.scn
+#dist_rtems_tests_DATA += jffs2_fserror.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/support
+AM_CPPFLAGS += -I$(top_srcdir)/jffs2_support
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include
+
+LINK_OBJS = $(jffs2_fserror_OBJECTS)
+LINK_LIBS = $(jffs2_fserror_LDLIBS)
+
+jffs2_fserror$(EXEEXT): $(jffs2_fserror_OBJECTS) $(jffs2_fserror_DEPENDENCIES)
+ @rm -f jffs2_fserror$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/fstests/jffs2_fslink/Makefile.am b/testsuites/fstests/jffs2_fslink/Makefile.am
new file mode 100644
index 0000000..f4965b1
--- /dev/null
+++ b/testsuites/fstests/jffs2_fslink/Makefile.am
@@ -0,0 +1,31 @@
+
+rtems_tests_PROGRAMS = jffs2_fslink
+jffs2_fslink_SOURCES = ../fslink/test.c
+jffs2_fslink_SOURCES += ../support/fstest_support.c
+jffs2_fslink_SOURCES += ../support/fstest_support.h
+jffs2_fslink_SOURCES += ../support/fstest.h
+jffs2_fslink_SOURCES += ../../psxtests/include/pmacros.h
+jffs2_fslink_SOURCES += ../jffs2_support/fs_support.c
+jffs2_fslink_SOURCES += ../jffs2_support/fs_config.h
+
+#dist_rtems_tests_DATA = jffs2_fslink.scn
+#dist_rtems_tests_DATA += jffs2_fslink.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/support
+AM_CPPFLAGS += -I$(top_srcdir)/jffs2_support
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include
+
+LINK_OBJS = $(jffs2_fslink_OBJECTS)
+LINK_LIBS = $(jffs2_fslink_LDLIBS)
+
+jffs2_fslink$(EXEEXT): $(jffs2_fslink_OBJECTS) $(jffs2_fslink_DEPENDENCIES)
+ @rm -f jffs2_fslink$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/fstests/jffs2_fspatheval/Makefile.am b/testsuites/fstests/jffs2_fspatheval/Makefile.am
new file mode 100644
index 0000000..79aa527
--- /dev/null
+++ b/testsuites/fstests/jffs2_fspatheval/Makefile.am
@@ -0,0 +1,31 @@
+
+rtems_tests_PROGRAMS = jffs2_fspatheval
+jffs2_fspatheval_SOURCES = ../fspatheval/test.c
+jffs2_fspatheval_SOURCES += ../support/fstest_support.c
+jffs2_fspatheval_SOURCES += ../support/fstest_support.h
+jffs2_fspatheval_SOURCES += ../support/fstest.h
+jffs2_fspatheval_SOURCES += ../../psxtests/include/pmacros.h
+jffs2_fspatheval_SOURCES += ../jffs2_support/fs_support.c
+jffs2_fspatheval_SOURCES += ../jffs2_support/fs_config.h
+
+#dist_rtems_tests_DATA = jffs2_fspatheval.scn
+#dist_rtems_tests_DATA += jffs2_fspatheval.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/support
+AM_CPPFLAGS += -I$(top_srcdir)/jffs2_support
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include
+
+LINK_OBJS = $(jffs2_fspatheval_OBJECTS)
+LINK_LIBS = $(jffs2_fspatheval_LDLIBS)
+
+jffs2_fspatheval$(EXEEXT): $(jffs2_fspatheval_OBJECTS) $(jffs2_fspatheval_DEPENDENCIES)
+ @rm -f jffs2_fspatheval$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/fstests/jffs2_fspermission/Makefile.am b/testsuites/fstests/jffs2_fspermission/Makefile.am
new file mode 100644
index 0000000..6e482c5
--- /dev/null
+++ b/testsuites/fstests/jffs2_fspermission/Makefile.am
@@ -0,0 +1,31 @@
+
+rtems_tests_PROGRAMS = jffs2_fspermission
+jffs2_fspermission_SOURCES = ../fspermission/test.c
+jffs2_fspermission_SOURCES += ../support/fstest_support.c
+jffs2_fspermission_SOURCES += ../support/fstest_support.h
+jffs2_fspermission_SOURCES += ../support/fstest.h
+jffs2_fspermission_SOURCES += ../../psxtests/include/pmacros.h
+jffs2_fspermission_SOURCES += ../jffs2_support/fs_support.c
+jffs2_fspermission_SOURCES += ../jffs2_support/fs_config.h
+
+#dist_rtems_tests_DATA = jffs2_fspermission.scn
+#dist_rtems_tests_DATA += jffs2_fspermission.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/support
+AM_CPPFLAGS += -I$(top_srcdir)/jffs2_support
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include
+
+LINK_OBJS = $(jffs2_fspermission_OBJECTS)
+LINK_LIBS = $(jffs2_fspermission_LDLIBS)
+
+jffs2_fspermission$(EXEEXT): $(jffs2_fspermission_OBJECTS) $(jffs2_fspermission_DEPENDENCIES)
+ @rm -f jffs2_fspermission$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/fstests/jffs2_fsrdwr/Makefile.am b/testsuites/fstests/jffs2_fsrdwr/Makefile.am
new file mode 100644
index 0000000..2f5ba70
--- /dev/null
+++ b/testsuites/fstests/jffs2_fsrdwr/Makefile.am
@@ -0,0 +1,31 @@
+
+rtems_tests_PROGRAMS = jffs2_fsrdwr
+jffs2_fsrdwr_SOURCES = ../fsrdwr/init.c
+jffs2_fsrdwr_SOURCES += ../support/fstest_support.c
+jffs2_fsrdwr_SOURCES += ../support/fstest_support.h
+jffs2_fsrdwr_SOURCES += ../support/fstest.h
+jffs2_fsrdwr_SOURCES += ../../psxtests/include/pmacros.h
+jffs2_fsrdwr_SOURCES += ../jffs2_support/fs_support.c
+jffs2_fsrdwr_SOURCES += ../jffs2_support/fs_config.h
+
+#dist_rtems_tests_DATA = jffs2_fsrdwr.scn
+#dist_rtems_tests_DATA += jffs2_fsrdwr.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/support
+AM_CPPFLAGS += -I$(top_srcdir)/jffs2_support
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include
+
+LINK_OBJS = $(jffs2_fsrdwr_OBJECTS)
+LINK_LIBS = $(jffs2_fsrdwr_LDLIBS)
+
+jffs2_fsrdwr$(EXEEXT): $(jffs2_fsrdwr_OBJECTS) $(jffs2_fsrdwr_DEPENDENCIES)
+ @rm -f jffs2_fsrdwr$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/fstests/jffs2_fssymlink/Makefile.am b/testsuites/fstests/jffs2_fssymlink/Makefile.am
new file mode 100644
index 0000000..860ad18
--- /dev/null
+++ b/testsuites/fstests/jffs2_fssymlink/Makefile.am
@@ -0,0 +1,31 @@
+
+rtems_tests_PROGRAMS = jffs2_fssymlink
+jffs2_fssymlink_SOURCES = ../fssymlink/test.c
+jffs2_fssymlink_SOURCES += ../support/fstest_support.c
+jffs2_fssymlink_SOURCES += ../support/fstest_support.h
+jffs2_fssymlink_SOURCES += ../support/fstest.h
+jffs2_fssymlink_SOURCES += ../../psxtests/include/pmacros.h
+jffs2_fssymlink_SOURCES += ../jffs2_support/fs_support.c
+jffs2_fssymlink_SOURCES += ../jffs2_support/fs_config.h
+
+#dist_rtems_tests_DATA = jffs2_fssymlink.scn
+#dist_rtems_tests_DATA += jffs2_fssymlink.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/support
+AM_CPPFLAGS += -I$(top_srcdir)/jffs2_support
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include
+
+LINK_OBJS = $(jffs2_fssymlink_OBJECTS)
+LINK_LIBS = $(jffs2_fssymlink_LDLIBS)
+
+jffs2_fssymlink$(EXEEXT): $(jffs2_fssymlink_OBJECTS) $(jffs2_fssymlink_DEPENDENCIES)
+ @rm -f jffs2_fssymlink$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/fstests/jffs2_fstime/Makefile.am b/testsuites/fstests/jffs2_fstime/Makefile.am
new file mode 100644
index 0000000..2ac64b6
--- /dev/null
+++ b/testsuites/fstests/jffs2_fstime/Makefile.am
@@ -0,0 +1,31 @@
+
+rtems_tests_PROGRAMS = jffs2_fstime
+jffs2_fstime_SOURCES = ../fstime/test.c
+jffs2_fstime_SOURCES += ../support/fstest_support.c
+jffs2_fstime_SOURCES += ../support/fstest_support.h
+jffs2_fstime_SOURCES += ../support/fstest.h
+jffs2_fstime_SOURCES += ../../psxtests/include/pmacros.h
+jffs2_fstime_SOURCES += ../jffs2_support/fs_support.c
+jffs2_fstime_SOURCES += ../jffs2_support/fs_config.h
+
+#dist_rtems_tests_DATA = jffs2_fstime.scn
+#dist_rtems_tests_DATA += jffs2_fstime.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/support
+AM_CPPFLAGS += -I$(top_srcdir)/jffs2_support
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include
+
+LINK_OBJS = $(jffs2_fstime_OBJECTS)
+LINK_LIBS = $(jffs2_fstime_LDLIBS)
+
+jffs2_fstime$(EXEEXT): $(jffs2_fstime_OBJECTS) $(jffs2_fstime_DEPENDENCIES)
+ @rm -f jffs2_fstime$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/fstests/jffs2_support/fs_config.h b/testsuites/fstests/jffs2_support/fs_config.h
new file mode 100644
index 0000000..e23c2d1
--- /dev/null
+++ b/testsuites/fstests/jffs2_support/fs_config.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <info at 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.
+ */
+
+#ifndef __JFFS2_SUPPORT_h
+#define __JFFS2_SUPPORT_h
+
+#define FILESYSTEM "JFFS2"
+
+#endif
diff --git a/testsuites/fstests/jffs2_support/fs_support.c b/testsuites/fstests/jffs2_support/fs_support.c
new file mode 100644
index 0000000..3148d0d
--- /dev/null
+++ b/testsuites/fstests/jffs2_support/fs_support.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <info at 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 "pmacros.h"
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <string.h>
+
+#include <rtems/jffs2.h>
+#include <rtems/libio.h>
+#include <rtems/libcsupport.h>
+
+#include "fstest.h"
+#include "fstest_support.h"
+
+#define BLOCK_SIZE (16UL * 1024UL)
+
+#define FLASH_SIZE (8UL * BLOCK_SIZE)
+
+typedef struct {
+ rtems_jffs2_flash_control super;
+ unsigned char area[FLASH_SIZE];
+} flash_control;
+
+static flash_control *get_flash_control(rtems_jffs2_flash_control *super)
+{
+ return (flash_control *) super;
+}
+
+static int flash_read(
+ rtems_jffs2_flash_control *super,
+ uint32_t offset,
+ unsigned char *buffer,
+ size_t size_of_buffer
+)
+{
+ flash_control *self = get_flash_control(super);
+ unsigned char *chunk = &self->area[offset];
+
+ memcpy(buffer, chunk, size_of_buffer);
+
+ return 0;
+}
+
+static int flash_write(
+ rtems_jffs2_flash_control *super,
+ uint32_t offset,
+ const unsigned char *buffer,
+ size_t size_of_buffer
+)
+{
+ flash_control *self = get_flash_control(super);
+ unsigned char *chunk = &self->area[offset];
+ size_t i;
+
+ for (i = 0; i < size_of_buffer; ++i) {
+ chunk[i] &= buffer[i];
+ }
+
+ return 0;
+}
+
+static int flash_erase(
+ rtems_jffs2_flash_control *super,
+ uint32_t offset
+)
+{
+ flash_control *self = get_flash_control(super);
+ unsigned char *chunk = &self->area[offset];
+
+ memset(chunk, 0xff, BLOCK_SIZE);
+
+ return 0;
+}
+
+static flash_control flash_instance = {
+ .super = {
+ .block_size = BLOCK_SIZE,
+ .flash_size = FLASH_SIZE,
+ .read = flash_read,
+ .write = flash_write,
+ .erase = flash_erase
+ }
+};
+
+static rtems_jffs2_compressor_control compressor_instance = {
+ .compress = rtems_jffs2_compressor_rtime_compress,
+ .decompress = rtems_jffs2_compressor_rtime_decompress
+};
+
+static const rtems_jffs2_mount_data mount_data = {
+ .flash_control = &flash_instance.super,
+ .compressor_control = &compressor_instance
+};
+
+static void erase_all(void)
+{
+ memset(&flash_instance.area[0], 0xff, FLASH_SIZE);
+}
+
+static rtems_resource_snapshot before_mount;
+
+void test_initialize_filesystem(void)
+{
+ int rv;
+
+ erase_all();
+
+ rv = mkdir(BASE_FOR_TEST, S_IRWXU | S_IRWXG | S_IRWXO);
+ rtems_test_assert(rv == 0);
+
+ rtems_resource_snapshot_take(&before_mount);
+
+ rv = mount(
+ NULL,
+ BASE_FOR_TEST,
+ RTEMS_FILESYSTEM_TYPE_JFFS2,
+ RTEMS_FILESYSTEM_READ_WRITE,
+ &mount_data
+ );
+ rtems_test_assert(rv == 0);
+}
+
+void test_shutdown_filesystem(void)
+{
+ int rv = unmount(BASE_FOR_TEST);
+ rtems_test_assert(rv == 0);
+ rtems_test_assert(rtems_resource_snapshot_check(&before_mount));
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+#define CONFIGURE_FILESYSTEM_JFFS2
+
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 40
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
--
1.7.7
More information about the devel
mailing list