summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-03-13 15:20:20 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-03-21 16:14:44 +0100
commitc38f1fcf8f0fab90785b0aec4361d53673bbc864 (patch)
tree31ad825a1aa3e12afb966fcbdefd3be534da0c61 /testsuites
parentdosfs: Fix msdos_utf8_normalize_and_fold() (diff)
downloadrtems-c38f1fcf8f0fab90785b0aec4361d53673bbc864.tar.bz2
dosfs: Fix fat_file_write()
Remove forced overwrite which leads to file data corruption. The logic to determine a forced overwrite was fundamentally broken. For simplity, disable this feature. Close #2622.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/fstests/Makefile.am1
-rw-r--r--testsuites/fstests/configure.ac1
-rw-r--r--testsuites/fstests/fsdosfsname02/Makefile.am19
-rw-r--r--testsuites/fstests/fsdosfsname02/fsdosfsname02.doc11
-rw-r--r--testsuites/fstests/fsdosfsname02/fsdosfsname02.scn2
-rw-r--r--testsuites/fstests/fsdosfsname02/init.c118
-rw-r--r--testsuites/fstests/fsdosfswrite01/init.c26
7 files changed, 172 insertions, 6 deletions
diff --git a/testsuites/fstests/Makefile.am b/testsuites/fstests/Makefile.am
index 930fbd7254..07c3ba54c1 100644
--- a/testsuites/fstests/Makefile.am
+++ b/testsuites/fstests/Makefile.am
@@ -5,6 +5,7 @@ _SUBDIRS += fsimfsconfig03
_SUBDIRS += fsimfsconfig02
_SUBDIRS += fsimfsconfig01
_SUBDIRS += fsdosfsname01
+_SUBDIRS += fsdosfsname02
_SUBDIRS += fsdosfswrite01
_SUBDIRS += fsdosfsformat01
_SUBDIRS += fsfseeko01
diff --git a/testsuites/fstests/configure.ac b/testsuites/fstests/configure.ac
index f0bbaafdbd..7fcaf277c6 100644
--- a/testsuites/fstests/configure.ac
+++ b/testsuites/fstests/configure.ac
@@ -81,6 +81,7 @@ fsimfsconfig03/Makefile
fsimfsconfig02/Makefile
fsimfsconfig01/Makefile
fsdosfsname01/Makefile
+fsdosfsname02/Makefile
fsdosfswrite01/Makefile
fsdosfsformat01/Makefile
fsfseeko01/Makefile
diff --git a/testsuites/fstests/fsdosfsname02/Makefile.am b/testsuites/fstests/fsdosfsname02/Makefile.am
new file mode 100644
index 0000000000..d3fdc5ce15
--- /dev/null
+++ b/testsuites/fstests/fsdosfsname02/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = fsdosfsname02
+fsdosfsname02_SOURCES = init.c
+
+dist_rtems_tests_DATA = fsdosfsname02.scn fsdosfsname02.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 = $(fsdosfsname02_OBJECTS)
+LINK_LIBS = $(fsdosfsname02_LDLIBS)
+
+fsdosfsname02$(EXEEXT): $(fsdosfsname02_OBJECTS) $(fsdosfsname02_DEPENDENCIES)
+ @rm -f fsdosfsname02$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/fstests/fsdosfsname02/fsdosfsname02.doc b/testsuites/fstests/fsdosfsname02/fsdosfsname02.doc
new file mode 100644
index 0000000000..079c2ae8b1
--- /dev/null
+++ b/testsuites/fstests/fsdosfsname02/fsdosfsname02.doc
@@ -0,0 +1,11 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: fsdosfsname02
+
+directives:
+
+ - msdos_add_file()
+
+concepts:
+
+ - Ensure that directory entries accross cluster boundaries work.
diff --git a/testsuites/fstests/fsdosfsname02/fsdosfsname02.scn b/testsuites/fstests/fsdosfsname02/fsdosfsname02.scn
new file mode 100644
index 0000000000..116c6671a4
--- /dev/null
+++ b/testsuites/fstests/fsdosfsname02/fsdosfsname02.scn
@@ -0,0 +1,2 @@
+*** BEGIN OF TEST FSDOSFSNAME 2 ***
+*** END OF TEST FSDOSFSNAME 2 ***
diff --git a/testsuites/fstests/fsdosfsname02/init.c b/testsuites/fstests/fsdosfsname02/init.c
new file mode 100644
index 0000000000..0496ca00a4
--- /dev/null
+++ b/testsuites/fstests/fsdosfsname02/init.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2017 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 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.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <rtems/dosfs.h>
+#include <rtems/ramdisk.h>
+
+#include "tmacros.h"
+
+const char rtems_test_name[] = "FSDOSFSNAME 2";
+
+#define RAMDISK_PATH "/dev/rda"
+
+#define MOUNT_PATH "/mnt"
+
+static const char * const dir_paths[] = {
+ MOUNT_PATH "/cpukit",
+ MOUNT_PATH "/cpukit/or1k-exception-frame-print.c",
+ MOUNT_PATH "/cpukit/preinstall.am",
+ MOUNT_PATH "/cpukit/Makefile.in",
+ MOUNT_PATH "/cpukit/Makefile.am",
+ MOUNT_PATH "/cpukit/rtems",
+ MOUNT_PATH "/cpukit/or1k-context-switch.S",
+ MOUNT_PATH "/cpukit/or1k-exception-default.c",
+ MOUNT_PATH "/cpukit/or1k-context-initialize.c",
+ MOUNT_PATH "/cpukit/or1k-context-volatile-clobber.S",
+ MOUNT_PATH "/cpukit/or1k-context-validate.S",
+ MOUNT_PATH "/cpukit/or1k-exception-handler-low.S",
+ MOUNT_PATH "/cpukit/cpu.c"
+};
+
+static void test(void)
+{
+ int rv;
+ size_t i;
+
+ rv = msdos_format(RAMDISK_PATH, NULL);
+ rtems_test_assert(rv == 0);
+
+ rv = mount_and_make_target_path(
+ RAMDISK_PATH,
+ MOUNT_PATH,
+ RTEMS_FILESYSTEM_TYPE_DOSFS,
+ RTEMS_FILESYSTEM_READ_WRITE,
+ NULL
+ );
+ rtems_test_assert(rv == 0);
+
+ for (i = 0; i < RTEMS_ARRAY_SIZE(dir_paths); ++i) {
+ rv = mkdir(dir_paths[i], S_IRWXU | S_IRWXG | S_IRWXO);
+ rtems_test_assert(rv == 0);
+ }
+
+ for (i = RTEMS_ARRAY_SIZE(dir_paths); i > 0; --i) {
+ rv = unlink(dir_paths[i - 1]);
+ rtems_test_assert(rv == 0);
+ }
+}
+
+static void Init(rtems_task_argument arg)
+{
+ TEST_BEGIN();
+
+ test();
+
+ TEST_END();
+ rtems_test_exit(0);
+}
+
+rtems_ramdisk_config rtems_ramdisk_configuration[] = {
+ { .block_size = 512, .block_num = 64 }
+};
+
+size_t rtems_ramdisk_configuration_size = RTEMS_ARRAY_SIZE(rtems_ramdisk_configuration);
+
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
+
+#define CONFIGURE_APPLICATION_EXTRA_DRIVERS RAMDISK_DRIVER_TABLE_ENTRY
+
+#define CONFIGURE_FILESYSTEM_DOSFS
+
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
+
+#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE 512
+#define CONFIGURE_BDBUF_BUFFER_MIN_SIZE 512
+#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE 512
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+#define CONFIGURE_MAXIMUM_SEMAPHORES 1
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/fstests/fsdosfswrite01/init.c b/testsuites/fstests/fsdosfswrite01/init.c
index 9ca1a2ab65..ba72507552 100644
--- a/testsuites/fstests/fsdosfswrite01/init.c
+++ b/testsuites/fstests/fsdosfswrite01/init.c
@@ -125,7 +125,7 @@ static void test_normal_file_write(
const char *mount_dir,
const char *file_name )
{
- static const rtems_blkdev_stats complete_block_stats = {
+ static const rtems_blkdev_stats complete_existing_block_stats = {
.read_hits = 0,
.read_misses = 0,
.read_ahead_transfers = 0,
@@ -135,14 +135,24 @@ static void test_normal_file_write(
.write_blocks = 1,
.write_errors = 0
};
- static const rtems_blkdev_stats new_block_stats = {
- .read_hits = 8,
+ static const rtems_blkdev_stats complete_new_block_stats = {
+ .read_hits = 3,
.read_misses = 2,
.read_ahead_transfers = 0,
.read_blocks = 2,
.read_errors = 0,
.write_transfers = 1,
- .write_blocks = 4,
+ .write_blocks = 3,
+ .write_errors = 0
+ };
+ static const rtems_blkdev_stats partial_new_block_stats = {
+ .read_hits = 3,
+ .read_misses = 3,
+ .read_ahead_transfers = 0,
+ .read_blocks = 3,
+ .read_errors = 0,
+ .write_transfers = 1,
+ .write_blocks = 3,
.write_errors = 0
};
@@ -174,17 +184,21 @@ static void test_normal_file_write(
num_bytes = write( fd, cluster_buf, cluster_size );
rtems_test_assert( (ssize_t) cluster_size == num_bytes );
- check_block_stats( dev_name, mount_dir, &complete_block_stats );
+ check_block_stats( dev_name, mount_dir, &complete_existing_block_stats );
reset_block_stats( dev_name, mount_dir );
+ /* Write a complete cluster into a new file space */
num_bytes = write( fd, cluster_buf, cluster_size );
rtems_test_assert( (ssize_t) cluster_size == num_bytes );
+ check_block_stats( dev_name, mount_dir, &complete_new_block_stats );
+ reset_block_stats( dev_name, mount_dir );
+
/* Write a new partial cluster into a new file space */
num_bytes = write( fd, cluster_buf, 1 );
rtems_test_assert( num_bytes == 1 );
- check_block_stats( dev_name, mount_dir, &new_block_stats );
+ check_block_stats( dev_name, mount_dir, &partial_new_block_stats );
rv = close( fd );
rtems_test_assert( 0 == rv );