summaryrefslogtreecommitdiffstats
path: root/testsuites/fstests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testsuites/fstests/fsbdpart01/init.c2
-rw-r--r--testsuites/fstests/fsclose01/init.c2
-rw-r--r--testsuites/fstests/fsdosfsformat01/init.c2
-rw-r--r--testsuites/fstests/fsdosfsname01/create_files.cs2
-rwxr-xr-xtestsuites/fstests/fsdosfsname01/create_image.sh2
-rw-r--r--testsuites/fstests/fsdosfsname01/image_bin_le_multibyte.h2
-rw-r--r--testsuites/fstests/fsdosfsname01/image_bin_le_singlebyte.h2
-rw-r--r--testsuites/fstests/fsdosfsname01/init.c2
-rw-r--r--testsuites/fstests/fsdosfsname02/init.c2
-rw-r--r--testsuites/fstests/fsdosfssync01/init.c2
-rw-r--r--testsuites/fstests/fsdosfswrite01/init.c2
-rw-r--r--testsuites/fstests/fsfseeko01/init.c2
-rw-r--r--testsuites/fstests/fsimfsconfig01/init.c2
-rw-r--r--testsuites/fstests/fsimfsconfig02/init.c2
-rw-r--r--testsuites/fstests/fsimfsconfig03/init.c2
-rw-r--r--testsuites/fstests/fsimfsgeneric01/init.c2
-rw-r--r--testsuites/fstests/fsjffs2empty01/fsjffs2empty01.doc11
-rw-r--r--testsuites/fstests/fsjffs2empty01/fsjffs2empty01.scn6
-rw-r--r--testsuites/fstests/fsjffs2empty01/init.c245
-rw-r--r--testsuites/fstests/fsjffs2gc01/init.c2
-rw-r--r--testsuites/fstests/fsnofs01/init.c2
-rw-r--r--testsuites/fstests/fsrofs01/init.c2
-rw-r--r--testsuites/fstests/jffs2_nand_support/fs_config.h33
-rw-r--r--testsuites/fstests/jffs2_nand_support/fs_support.c257
-rw-r--r--testsuites/fstests/jffs2_support/fs_config.h2
-rw-r--r--testsuites/fstests/jffs2_support/fs_support.c4
-rw-r--r--testsuites/fstests/tftpfs/init.c63
-rw-r--r--testsuites/fstests/tftpfs/tftpfs_interactions.c2
-rw-r--r--testsuites/fstests/tftpfs/tftpfs_interactions.h2
-rw-r--r--testsuites/fstests/tftpfs/tftpfs_udp_network_fake.c2
-rw-r--r--testsuites/fstests/tftpfs/tftpfs_udp_network_fake.h4
31 files changed, 584 insertions, 85 deletions
diff --git a/testsuites/fstests/fsbdpart01/init.c b/testsuites/fstests/fsbdpart01/init.c
index 1133e7b1c9..634604f9ca 100644
--- a/testsuites/fstests/fsbdpart01/init.c
+++ b/testsuites/fstests/fsbdpart01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2012 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsclose01/init.c b/testsuites/fstests/fsclose01/init.c
index ac461c66be..c425fa67c2 100644
--- a/testsuites/fstests/fsclose01/init.c
+++ b/testsuites/fstests/fsclose01/init.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012, 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2012, 2020 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsdosfsformat01/init.c b/testsuites/fstests/fsdosfsformat01/init.c
index 1fe39d1d06..876d9c2f58 100644
--- a/testsuites/fstests/fsdosfsformat01/init.c
+++ b/testsuites/fstests/fsdosfsformat01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2012 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsdosfsname01/create_files.cs b/testsuites/fstests/fsdosfsname01/create_files.cs
index 3f16aefc04..3cce61435b 100644
--- a/testsuites/fstests/fsdosfsname01/create_files.cs
+++ b/testsuites/fstests/fsdosfsname01/create_files.cs
@@ -14,7 +14,7 @@
*/
/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2013 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsdosfsname01/create_image.sh b/testsuites/fstests/fsdosfsname01/create_image.sh
index bd14baaae4..d37762e509 100755
--- a/testsuites/fstests/fsdosfsname01/create_image.sh
+++ b/testsuites/fstests/fsdosfsname01/create_image.sh
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: BSD-2-Clause
#
-# Copyright (c) 2013 embedded brains GmbH.
+# Copyright (c) 2013 embedded brains GmbH & Co. KG
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsdosfsname01/image_bin_le_multibyte.h b/testsuites/fstests/fsdosfsname01/image_bin_le_multibyte.h
index 7b9e931528..3e74ae63a7 100644
--- a/testsuites/fstests/fsdosfsname01/image_bin_le_multibyte.h
+++ b/testsuites/fstests/fsdosfsname01/image_bin_le_multibyte.h
@@ -9,7 +9,7 @@
*/
/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2013 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsdosfsname01/image_bin_le_singlebyte.h b/testsuites/fstests/fsdosfsname01/image_bin_le_singlebyte.h
index 0e089d7f6d..eb71832354 100644
--- a/testsuites/fstests/fsdosfsname01/image_bin_le_singlebyte.h
+++ b/testsuites/fstests/fsdosfsname01/image_bin_le_singlebyte.h
@@ -9,7 +9,7 @@
*/
/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2013 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsdosfsname01/init.c b/testsuites/fstests/fsdosfsname01/init.c
index 75854dee17..16fe6e9f84 100644
--- a/testsuites/fstests/fsdosfsname01/init.c
+++ b/testsuites/fstests/fsdosfsname01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2012, 2013 embedded brains GmbH. All rights reserved.
+ * Copyright (C) 2012, 2013 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsdosfsname02/init.c b/testsuites/fstests/fsdosfsname02/init.c
index 9a8256c9a6..3ff878c997 100644
--- a/testsuites/fstests/fsdosfsname02/init.c
+++ b/testsuites/fstests/fsdosfsname02/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2017 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2017 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsdosfssync01/init.c b/testsuites/fstests/fsdosfssync01/init.c
index 1fe8177fba..b4e8c08a7e 100644
--- a/testsuites/fstests/fsdosfssync01/init.c
+++ b/testsuites/fstests/fsdosfssync01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2012 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsdosfswrite01/init.c b/testsuites/fstests/fsdosfswrite01/init.c
index 54089835f7..15928cbcf0 100644
--- a/testsuites/fstests/fsdosfswrite01/init.c
+++ b/testsuites/fstests/fsdosfswrite01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2012 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsfseeko01/init.c b/testsuites/fstests/fsfseeko01/init.c
index 3aef821d39..01bf024d95 100644
--- a/testsuites/fstests/fsfseeko01/init.c
+++ b/testsuites/fstests/fsfseeko01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2012 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsimfsconfig01/init.c b/testsuites/fstests/fsimfsconfig01/init.c
index 04acdd2b79..bd994c895c 100644
--- a/testsuites/fstests/fsimfsconfig01/init.c
+++ b/testsuites/fstests/fsimfsconfig01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2015 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsimfsconfig02/init.c b/testsuites/fstests/fsimfsconfig02/init.c
index ce36292119..87f226f8dc 100644
--- a/testsuites/fstests/fsimfsconfig02/init.c
+++ b/testsuites/fstests/fsimfsconfig02/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2015 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsimfsconfig03/init.c b/testsuites/fstests/fsimfsconfig03/init.c
index d5a5485d1a..2fe37f3b6e 100644
--- a/testsuites/fstests/fsimfsconfig03/init.c
+++ b/testsuites/fstests/fsimfsconfig03/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2015 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsimfsgeneric01/init.c b/testsuites/fstests/fsimfsgeneric01/init.c
index 28c52bf12d..3a3bbc60d8 100644
--- a/testsuites/fstests/fsimfsgeneric01/init.c
+++ b/testsuites/fstests/fsimfsgeneric01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (C) 2012, 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2012, 2020 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsjffs2empty01/fsjffs2empty01.doc b/testsuites/fstests/fsjffs2empty01/fsjffs2empty01.doc
new file mode 100644
index 0000000000..2ad886a1fb
--- /dev/null
+++ b/testsuites/fstests/fsjffs2empty01/fsjffs2empty01.doc
@@ -0,0 +1,11 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: fsjffs2empty01
+
+directives:
+
+ - JFFS2 implementation
+
+concepts:
+
+ - Ensure that the JFFS2 library can remount a filesystem where every block has been written to and all files have been deleted.
diff --git a/testsuites/fstests/fsjffs2empty01/fsjffs2empty01.scn b/testsuites/fstests/fsjffs2empty01/fsjffs2empty01.scn
new file mode 100644
index 0000000000..56dca74761
--- /dev/null
+++ b/testsuites/fstests/fsjffs2empty01/fsjffs2empty01.scn
@@ -0,0 +1,6 @@
+*** BEGIN OF TEST FSJFFS2EMPTY 1 ***
+Initializing filesystem JFFS2
+
+
+Shutting down filesystem JFFS2
+*** END OF TEST FSJFFS2EMPTY 1 ***
diff --git a/testsuites/fstests/fsjffs2empty01/init.c b/testsuites/fstests/fsjffs2empty01/init.c
new file mode 100644
index 0000000000..3232ea8fde
--- /dev/null
+++ b/testsuites/fstests/fsjffs2empty01/init.c
@@ -0,0 +1,245 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2024 On-Line Applications Research (OAR)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <tmacros.h>
+
+#include <rtems.h>
+#include <rtems/jffs2.h>
+#include <rtems/libio.h>
+
+#define BLOCK_SIZE (16UL * 1024UL)
+
+#define FLASH_SIZE (8UL * BLOCK_SIZE)
+
+const char rtems_test_name[] = "FSJFFS2EMPTY 1";
+
+#define BASE_FOR_TEST "/mnt"
+static char big[] = BASE_FOR_TEST "/big";
+
+static char keg[523];
+
+static void init_keg(void)
+{
+ uint32_t v = 123;
+
+ for (size_t i = 0; i < sizeof(keg); ++i) {
+ v = v * 1664525 + 1013904223;
+ keg[i] = (uint8_t) (v >> 23);
+ }
+}
+
+static void create_big_file(void)
+{
+ int rv;
+ int fd = open(&big[0], O_WRONLY | O_TRUNC | O_CREAT,
+ S_IRWXU | S_IRWXG | S_IRWXO);
+ rtems_test_assert(fd >= 0);
+
+ for (int i = 0; i < 100; ++i) {
+ ssize_t n = write(fd, &keg[0], sizeof(keg));
+ rtems_test_assert(n == (ssize_t) sizeof(keg));
+ }
+
+ rv = close(fd);
+ rtems_test_assert(rv == 0);
+}
+
+static void remove_big_file(void)
+{
+ int rv = unlink(&big[0]);
+ rtems_test_assert(rv == 0);
+}
+
+typedef struct {
+ rtems_jffs2_flash_control super;
+ unsigned char area[FLASH_SIZE];
+} flash_control;
+
+static unsigned char *get_flash_chunk(rtems_jffs2_flash_control *super,
+ uint32_t offset)
+{
+ return &((flash_control *) super)->area[offset];
+}
+
+static int flash_read(
+ rtems_jffs2_flash_control *super,
+ uint32_t offset,
+ unsigned char *buffer,
+ size_t size_of_buffer
+)
+{
+ unsigned char *chunk = get_flash_chunk(super, 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
+)
+{
+ unsigned char *chunk = get_flash_chunk(super, offset);
+
+ for (size_t 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
+)
+{
+ unsigned char *chunk = get_flash_chunk(super, 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 void test_initialize_filesystem(void)
+{
+ int rv = mount(
+ NULL,
+ BASE_FOR_TEST,
+ RTEMS_FILESYSTEM_TYPE_JFFS2,
+ RTEMS_FILESYSTEM_READ_WRITE,
+ &mount_data
+ );
+ rtems_test_assert(rv == 0);
+}
+
+static void test_shutdown_filesystem(void)
+{
+ int rv = unmount(BASE_FOR_TEST);
+ rtems_test_assert(rv == 0);
+}
+
+static rtems_task Init(
+ rtems_task_argument ignored)
+{
+ int rv;
+
+ TEST_BEGIN();
+
+ erase_all();
+
+ rv = mkdir(BASE_FOR_TEST, S_IRWXU | S_IRWXG | S_IRWXO);
+ rtems_test_assert(rv == 0);
+
+ puts( "Initializing JFFS2 filesystem" );
+ test_initialize_filesystem();
+
+ init_keg();
+
+ /*
+ * Ensure that jiffies != 0, to use most likely path in
+ * jffs2_mark_node_obsolete(). Without this the failure only happens
+ * intermittently.
+ */
+ while (rtems_clock_get_ticks_since_boot() == 0) {
+ /* Wait */
+ }
+
+ /*
+ * This must be done in 2 parts because the FS is only so large and all blocks
+ * must be written to.
+ */
+ create_big_file();
+ remove_big_file();
+
+ create_big_file();
+ remove_big_file();
+
+ puts( "\n\nShutting down JFFS2 filesystem");
+ test_shutdown_filesystem();
+
+ puts( "Initializing JFFS2 filesystem again" );
+ test_initialize_filesystem();
+
+ puts( "\n\nShutting down JFFS2 filesystem again" );
+ test_shutdown_filesystem();
+
+ TEST_END();
+ rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
+
+#define CONFIGURE_FILESYSTEM_JFFS2
+
+#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 40
+
+#define CONFIGURE_MAXIMUM_TASKS 2
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
+#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
+
+#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/fsjffs2gc01/init.c b/testsuites/fstests/fsjffs2gc01/init.c
index a72636927d..4d29373b90 100644
--- a/testsuites/fstests/fsjffs2gc01/init.c
+++ b/testsuites/fstests/fsjffs2gc01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2016 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2016 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsnofs01/init.c b/testsuites/fstests/fsnofs01/init.c
index 0d11fea284..b1c1488168 100644
--- a/testsuites/fstests/fsnofs01/init.c
+++ b/testsuites/fstests/fsnofs01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2012 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/fsrofs01/init.c b/testsuites/fstests/fsrofs01/init.c
index 5c4dd7e8db..0af88879d9 100644
--- a/testsuites/fstests/fsrofs01/init.c
+++ b/testsuites/fstests/fsrofs01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2012 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/jffs2_nand_support/fs_config.h b/testsuites/fstests/jffs2_nand_support/fs_config.h
new file mode 100644
index 0000000000..548f5203e6
--- /dev/null
+++ b/testsuites/fstests/jffs2_nand_support/fs_config.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2023 On-Line Applications Research (OAR)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __JFFS2_SUPPORT_h
+#define __JFFS2_SUPPORT_h
+
+#define FILESYSTEM "JFFS2"
+
+#endif
diff --git a/testsuites/fstests/jffs2_nand_support/fs_support.c b/testsuites/fstests/jffs2_nand_support/fs_support.c
new file mode 100644
index 0000000000..9e7c965735
--- /dev/null
+++ b/testsuites/fstests/jffs2_nand_support/fs_support.c
@@ -0,0 +1,257 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2023 On-Line Applications Research (OAR)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <tmacros.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 FLASH_PAGE_SIZE (1024UL)
+/* Out of Band/Spare area size is per-page */
+#define FLASH_PAGE_OOB_SIZE (32UL)
+
+#define PAGES_PER_BLOCK (16UL)
+#define BLOCKS_PER_DEVICE (8UL)
+
+#define FLASH_OOB_SIZE (BLOCKS_PER_DEVICE * PAGES_PER_BLOCK * FLASH_PAGE_OOB_SIZE)
+#define FLASH_BLOCK_SIZE (PAGES_PER_BLOCK * FLASH_PAGE_SIZE)
+#define FLASH_SIZE (BLOCKS_PER_DEVICE * FLASH_BLOCK_SIZE)
+
+typedef struct {
+ rtems_jffs2_flash_control super;
+ unsigned char area[FLASH_SIZE];
+ unsigned char oob[FLASH_OOB_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);
+ uint32_t page_index = offset / FLASH_PAGE_SIZE;
+ uint32_t oob_offset = page_index * FLASH_PAGE_OOB_SIZE;
+ unsigned char *chunk = &self->area[offset];
+ unsigned char *oobchunk = &self->oob[oob_offset];
+
+ memset(chunk, 0xff, FLASH_BLOCK_SIZE);
+ memset(oobchunk, 0xff, PAGES_PER_BLOCK * FLASH_PAGE_OOB_SIZE);
+
+ return 0;
+}
+
+static int flash_read_oob(
+ rtems_jffs2_flash_control *super,
+ uint32_t offset,
+ uint8_t *buffer,
+ uint32_t size_of_buffer
+)
+{
+ flash_control *self = get_flash_control(super);
+ uint32_t page_index = offset / FLASH_PAGE_SIZE;
+ uint32_t oob_offset = page_index * FLASH_PAGE_OOB_SIZE;
+ unsigned char *chunk = &self->oob[oob_offset];
+
+ memcpy(buffer, chunk, size_of_buffer);
+
+ return 0;
+}
+
+static int flash_write_oob(
+ rtems_jffs2_flash_control *super,
+ uint32_t offset,
+ uint8_t *buffer,
+ uint32_t size_of_buffer
+)
+{
+ flash_control *self = get_flash_control(super);
+ uint32_t page_index = offset / FLASH_PAGE_SIZE;
+ uint32_t oob_offset = page_index * FLASH_PAGE_OOB_SIZE;
+ unsigned char *chunk = &self->oob[oob_offset];
+ size_t i;
+
+ for (i = 0; i < size_of_buffer; ++i) {
+ chunk[i] &= buffer[i];
+ }
+
+ return 0;
+}
+
+static int flash_block_is_bad(
+ rtems_jffs2_flash_control *super,
+ uint32_t orig_offset,
+ bool *bad
+)
+{
+ *bad = false;
+ return 0;
+}
+
+static int flash_block_mark_bad(
+ rtems_jffs2_flash_control *super,
+ uint32_t orig_offset
+)
+{
+ return 0;
+}
+
+static uint32_t flash_get_oob_size(
+ rtems_jffs2_flash_control *super
+)
+{
+ return FLASH_PAGE_OOB_SIZE;
+}
+
+static flash_control flash_instance = {
+ .super = {
+ .block_size = FLASH_BLOCK_SIZE,
+ .flash_size = FLASH_SIZE,
+ .read = flash_read,
+ .write = flash_write,
+ .erase = flash_erase,
+ .block_is_bad = flash_block_is_bad,
+ .block_mark_bad = flash_block_mark_bad,
+ .oob_read = flash_read_oob,
+ .oob_write = flash_write_oob,
+ .get_oob_size = flash_get_oob_size,
+ .write_size = FLASH_PAGE_SIZE
+ }
+};
+
+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);
+ memset(&flash_instance.oob[0], 0xff, FLASH_OOB_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_SIMPLE_CONSOLE_DRIVER
+
+#define CONFIGURE_FILESYSTEM_JFFS2
+
+#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 40
+
+#define CONFIGURE_MAXIMUM_TASKS 2
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
+#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
+
+#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/jffs2_support/fs_config.h b/testsuites/fstests/jffs2_support/fs_config.h
index 8740898294..fd334d7b38 100644
--- a/testsuites/fstests/jffs2_support/fs_config.h
+++ b/testsuites/fstests/jffs2_support/fs_config.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2013 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/jffs2_support/fs_support.c b/testsuites/fstests/jffs2_support/fs_support.c
index 2aa04a27c6..fba1c4aaa6 100644
--- a/testsuites/fstests/jffs2_support/fs_support.c
+++ b/testsuites/fstests/jffs2_support/fs_support.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2013 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -163,7 +163,7 @@ void test_shutdown_filesystem(void)
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 40
-#define CONFIGURE_MAXIMUM_TASKS 1
+#define CONFIGURE_MAXIMUM_TASKS 2
#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
diff --git a/testsuites/fstests/tftpfs/init.c b/testsuites/fstests/tftpfs/init.c
index fe18476ef3..38e429f11e 100644
--- a/testsuites/fstests/tftpfs/init.c
+++ b/testsuites/fstests/tftpfs/init.c
@@ -14,7 +14,7 @@
*/
/*
- * Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2022 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -42,6 +42,7 @@
#include "config.h"
#endif
+#include <stdio.h>
#include <stdlib.h> /* malloc(), free() */
#include <ctype.h> /* isprint() */
#include <errno.h>
@@ -919,7 +920,7 @@ T_TEST_CASE( tftp_read_null_buffer )
*/
T_TEST_CASE( tftp_write_null_tftp_handle )
{
- char data_buffer[10];
+ char data_buffer[10] = { 0 };
ssize_t res;
res = tftp_write(
@@ -6895,65 +6896,11 @@ T_TEST_CASE_FIXTURE( OACK_with_surplus_option, &fixture_large_blocksize )
T_no_more_interactions();
}
-/*
- * Test suite and configuration
- */
-
const char rtems_test_name[] = "TFTPFS";
-static char buffer[ 512 ];
-
-static const T_action actions[] = {
- T_report_hash_sha256,
- T_check_task_context,
- T_check_file_descriptors,
- T_check_rtems_barriers,
- T_check_rtems_extensions,
- T_check_rtems_message_queues,
- T_check_rtems_partitions,
- T_check_rtems_periods,
- T_check_rtems_regions,
- T_check_rtems_semaphores,
- T_check_rtems_tasks,
- T_check_rtems_timers,
- T_check_posix_keys
-};
-
-static const T_config config = {
- .name = rtems_test_name,
- .buf = buffer,
- .buf_size = sizeof( buffer ),
- .putchar = T_putchar_default,
- .verbosity = RTEMS_TEST_VERBOSITY,
- .now = T_now_clock,
- .allocate = T_memory_allocate,
- .deallocate = T_memory_deallocate,
- .action_count = T_ARRAY_SIZE( actions ),
- .actions = actions
-};
-
static void Init( rtems_task_argument argument )
{
- (void) argument;
- int exit_code;
-
- /*
- * It would be much easier to simply use
- * rtems_test_run( argument, TEST_STATE );
- * instead of all the code below and the variables
- * buffer, actions, config
- * above. Yet, rtems_test_run() sets the verbosity always to
- * T_VERBOSE and this would produce plenty of output.
- */
- rtems_test_begin( rtems_test_name, TEST_STATE );
- T_register();
- exit_code = T_main( &config );
-
- if ( exit_code == 0 ) {
- rtems_test_end( rtems_test_name );
- }
-
- rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, (uint32_t) exit_code );
+ rtems_test_run( argument, TEST_STATE );
}
/*
@@ -6968,7 +6915,7 @@ static void Init( rtems_task_argument argument )
*/
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
-#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 1
diff --git a/testsuites/fstests/tftpfs/tftpfs_interactions.c b/testsuites/fstests/tftpfs/tftpfs_interactions.c
index ad05978b17..9ab026c5da 100644
--- a/testsuites/fstests/tftpfs/tftpfs_interactions.c
+++ b/testsuites/fstests/tftpfs/tftpfs_interactions.c
@@ -22,7 +22,7 @@
*/
/*
- * Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2022 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/tftpfs/tftpfs_interactions.h b/testsuites/fstests/tftpfs/tftpfs_interactions.h
index f320f685d3..732a542e99 100644
--- a/testsuites/fstests/tftpfs/tftpfs_interactions.h
+++ b/testsuites/fstests/tftpfs/tftpfs_interactions.h
@@ -12,7 +12,7 @@
*/
/*
- * Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2022 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/tftpfs/tftpfs_udp_network_fake.c b/testsuites/fstests/tftpfs/tftpfs_udp_network_fake.c
index 201e87f0db..995ae05fe0 100644
--- a/testsuites/fstests/tftpfs/tftpfs_udp_network_fake.c
+++ b/testsuites/fstests/tftpfs/tftpfs_udp_network_fake.c
@@ -21,7 +21,7 @@
*/
/*
- * Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2022 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/testsuites/fstests/tftpfs/tftpfs_udp_network_fake.h b/testsuites/fstests/tftpfs/tftpfs_udp_network_fake.h
index 2c5860882f..0a852353ad 100644
--- a/testsuites/fstests/tftpfs/tftpfs_udp_network_fake.h
+++ b/testsuites/fstests/tftpfs/tftpfs_udp_network_fake.h
@@ -12,7 +12,7 @@
*/
/*
- * Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2022 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -52,7 +52,7 @@ extern "C" {
/**
* @defgroup RTEMSTestSuiteTestsTFTPFS Test suite for libtftpsfs tests
*
- * @ingroup RTEMSTestSuites
+ * @ingroup RTEMSTestSuitesFilesystem
*
* @brief This test suite provides a tests for libtftpfs.
*