aboutsummaryrefslogtreecommitdiffstats
path: root/test/mfs
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-11-17 13:02:26 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-11-17 13:02:26 +0000
commited7adbc766d817a6915c1279fc9dbe2f7c0f4567 (patch)
tree23b227ac9fb99cc8369022b2a6b7b4724cf49d43 /test/mfs
parentdc52593ffb76e180d880b44b6d8277a053eb6c1a (diff)
downloadChibiOS-ed7adbc766d817a6915c1279fc9dbe2f7c0f4567.tar.gz
ChibiOS-ed7adbc766d817a6915c1279fc9dbe2f7c0f4567.tar.bz2
ChibiOS-ed7adbc766d817a6915c1279fc9dbe2f7c0f4567.zip
More MFS tests.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11029 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/mfs')
-rw-r--r--test/mfs/configuration.xml146
-rw-r--r--test/mfs/mfs_test.mk3
-rw-r--r--test/mfs/source/test/mfs_test_root.c2
-rw-r--r--test/mfs/source/test/mfs_test_root.h1
-rw-r--r--test/mfs/source/test/mfs_test_sequence_001.c4
-rw-r--r--test/mfs/source/test/mfs_test_sequence_002.c180
-rw-r--r--test/mfs/source/test/mfs_test_sequence_002.h27
7 files changed, 359 insertions, 4 deletions
diff --git a/test/mfs/configuration.xml b/test/mfs/configuration.xml
index c715b6b93..bb2533c80 100644
--- a/test/mfs/configuration.xml
+++ b/test/mfs/configuration.xml
@@ -731,7 +731,7 @@ test_assert(bank_verify_erased(MFS_BANK_1) == FLASH_NO_ERROR, "bank 1 not erased
</step>
<step>
<description>
- <value>Checking for all records in the new bank, MFS_NO_ERROR is expected for each key.</value>
+ <value>Checking for all records in the new bank, MFS_NO_ERROR is expected for each record.</value>
</description>
<tags>
<value />
@@ -865,6 +865,150 @@ test_assert(bank_verify_erased(MFS_BANK_0) == FLASH_NO_ERROR, "bank 0 not erased
</case>
</cases>
</sequence>
+ <sequence>
+ <type index="0">
+ <value>Internal Tests</value>
+ </type>
+ <brief>
+ <value>API Invalid Cases tests.</value>
+ </brief>
+ <description>
+ <value>This test sequence tests the error coded returned by the various APIs when called when the system is not initialized.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <shared_code>
+ <value><![CDATA[#include "mfs.h"]]></value>
+ </shared_code>
+ <cases>
+ <case>
+ <brief>
+ <value>Initialization error from APIs.</value>
+ </brief>
+ <description>
+ <value>The API functions are invoked without prior initialization.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value />
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>The function mfsErase() is called, MFS_ERR_INV_STATE is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[mfs_error_t err = mfsErase(&mfs1);
+test_assert(err == MFS_ERR_INV_STATE, "mfsErase() returned wrong status");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>The function mfsWriteRecord() is called, MFS_ERR_INV_STATE is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[mfs_error_t err = mfsWriteRecord(&mfs1, 1, 16, mfs_buffer);
+test_assert(err == MFS_ERR_INV_STATE, "mfsWriteRecord() returned wrong status");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>The function mfsEraseRecord() is called, MFS_ERR_INV_STATE is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[mfs_error_t err = mfsEraseRecord(&mfs1, 1);
+test_assert(err == MFS_ERR_INV_STATE, "mfsEraseRecord() returned wrong status");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>The function mfsReadRecord() is called, MFS_ERR_INV_STATE is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[size_t size = sizeof mfs_buffer;
+mfs_error_t err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
+test_assert(err == MFS_ERR_INV_STATE, "mfsReadRecord() returned wrong status");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>The function mfsPerformGarbageCollection() is called, MFS_ERR_INV_STATE is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[mfs_error_t err = mfsPerformGarbageCollection(&mfs1);
+test_assert(err == MFS_ERR_INV_STATE, "mfsPerformGarbageCollection() returned wrong status");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>Erasing non existing record.</value>
+ </brief>
+ <description>
+ <value>An erase operation is attempted on an non-existing record.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[mfsStart(&mfs1, &mfscfg1);
+mfsErase(&mfs1);]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[mfsStop(&mfs1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>Record one is erased, the error MFS_ERR_NOT_FOUND is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[mfs_error_t err;
+
+err = mfsEraseRecord(&mfs1, 1);
+test_assert(err != MFS_NO_ERROR, "record was present");
+test_assert(err == MFS_ERR_NOT_FOUND, "invalid error code");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ </cases>
+ </sequence>
</sequences>
</instance>
</instances>
diff --git a/test/mfs/mfs_test.mk b/test/mfs/mfs_test.mk
index fda8965c3..ae6fbf6a2 100644
--- a/test/mfs/mfs_test.mk
+++ b/test/mfs/mfs_test.mk
@@ -1,6 +1,7 @@
# List of all the ChibiOS/HAL MFS test files.
TESTSRC += ${CHIBIOS}/test/mfs/source/test/mfs_test_root.c \
- ${CHIBIOS}/test/mfs/source/test/mfs_test_sequence_001.c
+ ${CHIBIOS}/test/mfs/source/test/mfs_test_sequence_001.c \
+ ${CHIBIOS}/test/mfs/source/test/mfs_test_sequence_002.c
# Required include directories
TESTINC += ${CHIBIOS}/test/mfs/source/test
diff --git a/test/mfs/source/test/mfs_test_root.c b/test/mfs/source/test/mfs_test_root.c
index 3f38c99dd..27d5efb59 100644
--- a/test/mfs/source/test/mfs_test_root.c
+++ b/test/mfs/source/test/mfs_test_root.c
@@ -22,6 +22,7 @@
*
* <h2>Test Sequences</h2>
* - @subpage mfs_test_sequence_001
+ * - @subpage mfs_test_sequence_002
* .
*/
@@ -44,6 +45,7 @@
*/
const testsequence_t * const mfs_test_suite_array[] = {
&mfs_test_sequence_001,
+ &mfs_test_sequence_002,
NULL
};
diff --git a/test/mfs/source/test/mfs_test_root.h b/test/mfs/source/test/mfs_test_root.h
index 18c12ee8f..51577e6a7 100644
--- a/test/mfs/source/test/mfs_test_root.h
+++ b/test/mfs/source/test/mfs_test_root.h
@@ -25,6 +25,7 @@
#include "ch_test.h"
#include "mfs_test_sequence_001.h"
+#include "mfs_test_sequence_002.h"
#if !defined(__DOXYGEN__)
diff --git a/test/mfs/source/test/mfs_test_sequence_001.c b/test/mfs/source/test/mfs_test_sequence_001.c
index c0cc35730..d6ee2fe42 100644
--- a/test/mfs/source/test/mfs_test_sequence_001.c
+++ b/test/mfs/source/test/mfs_test_sequence_001.c
@@ -507,7 +507,7 @@ static const testcase_t mfs_test_001_005 = {
* MFS_WARN_GC is expected, MFS object state is checked for
* correctness after the operation.
* - [1.6.7] Checking for all records in the new bank, MFS_NO_ERROR is
- * expected for each key.
+ * expected for each record.
* .
*/
@@ -643,7 +643,7 @@ static void mfs_test_001_006_execute(void) {
}
/* [1.6.7] Checking for all records in the new bank, MFS_NO_ERROR is
- expected for each key.*/
+ expected for each record.*/
test_set_step(7);
{
mfs_id_t id;
diff --git a/test/mfs/source/test/mfs_test_sequence_002.c b/test/mfs/source/test/mfs_test_sequence_002.c
new file mode 100644
index 000000000..973760518
--- /dev/null
+++ b/test/mfs/source/test/mfs_test_sequence_002.c
@@ -0,0 +1,180 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "hal.h"
+#include "mfs_test_root.h"
+
+/**
+ * @file mfs_test_sequence_002.c
+ * @brief Test Sequence 002 code.
+ *
+ * @page mfs_test_sequence_002 [2] API Invalid Cases tests
+ *
+ * File: @ref mfs_test_sequence_002.c
+ *
+ * <h2>Description</h2>
+ * This test sequence tests the error coded returned by the various
+ * APIs when called when the system is not initialized.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage mfs_test_002_001
+ * - @subpage mfs_test_002_002
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+#include "mfs.h"
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+/**
+ * @page mfs_test_002_001 [2.1] Initialization error from APIs
+ *
+ * <h2>Description</h2>
+ * The API functions are invoked without prior initialization.
+ *
+ * <h2>Test Steps</h2>
+ * - [2.1.1] The function mfsErase() is called, MFS_ERR_INV_STATE is
+ * expected.
+ * - [2.1.2] The function mfsWriteRecord() is called, MFS_ERR_INV_STATE
+ * is expected.
+ * - [2.1.3] The function mfsEraseRecord() is called, MFS_ERR_INV_STATE
+ * is expected.
+ * - [2.1.4] The function mfsReadRecord() is called, MFS_ERR_INV_STATE
+ * is expected.
+ * - [2.1.5] The function mfsPerformGarbageCollection() is called,
+ * MFS_ERR_INV_STATE is expected.
+ * .
+ */
+
+static void mfs_test_002_001_execute(void) {
+
+ /* [2.1.1] The function mfsErase() is called, MFS_ERR_INV_STATE is
+ expected.*/
+ test_set_step(1);
+ {
+ mfs_error_t err = mfsErase(&mfs1);
+ test_assert(err == MFS_ERR_INV_STATE, "mfsErase() returned wrong status");
+ }
+
+ /* [2.1.2] The function mfsWriteRecord() is called, MFS_ERR_INV_STATE
+ is expected.*/
+ test_set_step(2);
+ {
+ mfs_error_t err = mfsWriteRecord(&mfs1, 1, 16, mfs_buffer);
+ test_assert(err == MFS_ERR_INV_STATE, "mfsWriteRecord() returned wrong status");
+ }
+
+ /* [2.1.3] The function mfsEraseRecord() is called, MFS_ERR_INV_STATE
+ is expected.*/
+ test_set_step(3);
+ {
+ mfs_error_t err = mfsEraseRecord(&mfs1, 1);
+ test_assert(err == MFS_ERR_INV_STATE, "mfsEraseRecord() returned wrong status");
+ }
+
+ /* [2.1.4] The function mfsReadRecord() is called, MFS_ERR_INV_STATE
+ is expected.*/
+ test_set_step(4);
+ {
+ size_t size = sizeof mfs_buffer;
+ mfs_error_t err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
+ test_assert(err == MFS_ERR_INV_STATE, "mfsReadRecord() returned wrong status");
+ }
+
+ /* [2.1.5] The function mfsPerformGarbageCollection() is called,
+ MFS_ERR_INV_STATE is expected.*/
+ test_set_step(5);
+ {
+ mfs_error_t err = mfsPerformGarbageCollection(&mfs1);
+ test_assert(err == MFS_ERR_INV_STATE, "mfsPerformGarbageCollection() returned wrong status");
+ }
+}
+
+static const testcase_t mfs_test_002_001 = {
+ "Initialization error from APIs",
+ NULL,
+ NULL,
+ mfs_test_002_001_execute
+};
+
+/**
+ * @page mfs_test_002_002 [2.2] Erasing non existing record
+ *
+ * <h2>Description</h2>
+ * An erase operation is attempted on an non-existing record.
+ *
+ * <h2>Test Steps</h2>
+ * - [2.2.1] Record one is erased, the error MFS_ERR_NOT_FOUND is
+ * expected.
+ * .
+ */
+
+static void mfs_test_002_002_setup(void) {
+ mfsStart(&mfs1, &mfscfg1);
+ mfsErase(&mfs1);
+}
+
+static void mfs_test_002_002_teardown(void) {
+ mfsStop(&mfs1);
+}
+
+static void mfs_test_002_002_execute(void) {
+
+ /* [2.2.1] Record one is erased, the error MFS_ERR_NOT_FOUND is
+ expected.*/
+ test_set_step(1);
+ {
+ mfs_error_t err;
+
+ err = mfsEraseRecord(&mfs1, 1);
+ test_assert(err != MFS_NO_ERROR, "record was present");
+ test_assert(err == MFS_ERR_NOT_FOUND, "invalid error code");
+ }
+}
+
+static const testcase_t mfs_test_002_002 = {
+ "Erasing non existing record",
+ mfs_test_002_002_setup,
+ mfs_test_002_002_teardown,
+ mfs_test_002_002_execute
+};
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Array of test cases.
+ */
+const testcase_t * const mfs_test_sequence_002_array[] = {
+ &mfs_test_002_001,
+ &mfs_test_002_002,
+ NULL
+};
+
+/**
+ * @brief API Invalid Cases tests.
+ */
+const testsequence_t mfs_test_sequence_002 = {
+ "API Invalid Cases tests",
+ mfs_test_sequence_002_array
+};
diff --git a/test/mfs/source/test/mfs_test_sequence_002.h b/test/mfs/source/test/mfs_test_sequence_002.h
new file mode 100644
index 000000000..d451e5d5a
--- /dev/null
+++ b/test/mfs/source/test/mfs_test_sequence_002.h
@@ -0,0 +1,27 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file mfs_test_sequence_002.h
+ * @brief Test Sequence 002 header.
+ */
+
+#ifndef MFS_TEST_SEQUENCE_002_H
+#define MFS_TEST_SEQUENCE_002_H
+
+extern const testsequence_t mfs_test_sequence_002;
+
+#endif /* MFS_TEST_SEQUENCE_002_H */