aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-11-14 13:18:59 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-11-14 13:18:59 +0000
commited415bb76f7563346a3f9b0ba3ef45f9a6898afb (patch)
tree3444e6eb788fe8be4b98d22ea7cf96a1806d6a9a /test
parent1935d28be9747aac18d9338fb1444514d257a51a (diff)
downloadChibiOS-ed415bb76f7563346a3f9b0ba3ef45f9a6898afb.tar.gz
ChibiOS-ed415bb76f7563346a3f9b0ba3ef45f9a6898afb.tar.bz2
ChibiOS-ed415bb76f7563346a3f9b0ba3ef45f9a6898afb.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10998 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test')
-rw-r--r--test/mfs/configuration.xml613
1 files changed, 308 insertions, 305 deletions
diff --git a/test/mfs/configuration.xml b/test/mfs/configuration.xml
index e51d568f4..20f7362b7 100644
--- a/test/mfs/configuration.xml
+++ b/test/mfs/configuration.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<SPC5-Config version="1.0.0">
- <application name="ChibiOS/NIL Test Suite" version="1.0.0" standalone="true" locked="false">
+ <application name="ChibiOS/HAL MFS Test Suite" version="1.0.0" standalone="true" locked="false">
<description>Test Specification for ChibiOS/HAL MFS Complex Driver.</description>
<component id="org.chibios.spc5.components.portable.generic_startup">
<component id="org.chibios.spc5.components.portable.chibios_unitary_tests_engine" />
@@ -35,10 +35,10 @@
</description>
<global_data_and_code>
<code_prefix>
- <value>nil_</value>
+ <value>mfs_</value>
</code_prefix>
<global_definitions>
- <value><![CDATA[#define TEST_SUITE_NAME "ChibiOS/NIL Test Suite"
+ <value><![CDATA[#define TEST_SUITE_NAME "ChibiOS/HAL MFS Test Suite"
#define TEST_REPORT_HOOK_HEADER test_print_port_info();
@@ -114,56 +114,59 @@ THD_FUNCTION(test_support, arg) {
<description>
<value>The APIs are tested for functionality, correct cases and expected error cases are tested.</value>
</description>
+ <condition>
+ <value />
+ </condition>
<shared_code>
- <value><![CDATA[#include <string.h>
-#include "key_storage.h"
-
-static const uint8_t pattern1[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
-};
-
-static const uint8_t pattern2[] = {
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
-};
-
-static const uint8_t pattern3[] = {
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57
-};
-
-static const uint8_t pattern512[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
+ <value><![CDATA[#include <string.h>
+#include "key_storage.h"
+
+static const uint8_t pattern1[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
+};
+
+static const uint8_t pattern2[] = {
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
+};
+
+static const uint8_t pattern3[] = {
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57
+};
+
+static const uint8_t pattern512[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
};]]></value>
</shared_code>
<cases>
@@ -197,12 +200,12 @@ static const uint8_t pattern512[] = {
<value />
</tags>
<code>
- <value><![CDATA[bool result;
-
-ks_lld_init();
-result = ks_lld_block_erase(KS_BLOCK0);
-test_assert(!result, "Block 0 erase failure");
-result = ks_lld_block_erase(KS_BLOCK1);
+ <value><![CDATA[bool result;
+
+ks_lld_init();
+result = ks_lld_block_erase(KS_BLOCK0);
+test_assert(!result, "Block 0 erase failure");
+result = ks_lld_block_erase(KS_BLOCK1);
test_assert(!result, "Block 1 erase failure");]]></value>
</code>
</step>
@@ -214,9 +217,9 @@ test_assert(!result, "Block 1 erase failure");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksInit();
+ <value><![CDATA[kserror_t error;
+
+error = ksInit();
test_assert(error == KS_NOERROR, "initialization error with erased flash");]]></value>
</code>
</step>
@@ -228,9 +231,9 @@ test_assert(error == KS_NOERROR, "initialization error with erased flash");]]></
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksInit();
+ <value><![CDATA[kserror_t error;
+
+error = ksInit();
test_assert(error == KS_NOERROR, "initialization error with initialized flash");]]></value>
</code>
</step>
@@ -266,15 +269,15 @@ test_assert(error == KS_NOERROR, "initialization error with initialized flash");
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-kskey_t key;
-size_t size;
-uint8_t *keyp;
-
-for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_KEY_NOT_FOUND,
- "found a key that should not exists");
+ <value><![CDATA[kserror_t error;
+kskey_t key;
+size_t size;
+uint8_t *keyp;
+
+for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_KEY_NOT_FOUND,
+ "found a key that should not exists");
}]]></value>
</code>
</step>
@@ -298,7 +301,7 @@ for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
<value><![CDATA[ksDeinit();]]></value>
</teardown_code>
<local_variables>
- <value><![CDATA[size_t size;
+ <value><![CDATA[size_t size;
uint8_t *keyp;]]></value>
</local_variables>
</various_code>
@@ -311,7 +314,7 @@ uint8_t *keyp;]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error = ksGetKey(0, &size, &keyp);
+ <value><![CDATA[kserror_t error = ksGetKey(0, &size, &keyp);
test_assert(error == KS_KEY_NOT_FOUND, "key was already present");]]></value>
</code>
</step>
@@ -323,13 +326,13 @@ test_assert(error == KS_KEY_NOT_FOUND, "key was already present");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksWriteKey(0, sizeof(pattern1), pattern1);
-test_assert(error == KS_NOERROR, "error creating the key");
-error = ksGetKey(0, &size, &keyp);
-test_assert(error == KS_NOERROR, "key not found");
-test_assert(size == sizeof(pattern1), "unexpected key length");
+ <value><![CDATA[kserror_t error;
+
+error = ksWriteKey(0, sizeof(pattern1), pattern1);
+test_assert(error == KS_NOERROR, "error creating the key");
+error = ksGetKey(0, &size, &keyp);
+test_assert(error == KS_NOERROR, "key not found");
+test_assert(size == sizeof(pattern1), "unexpected key length");
test_assert(memcmp(pattern1, keyp, size) == 0, "wrong key content");]]></value>
</code>
</step>
@@ -341,13 +344,13 @@ test_assert(memcmp(pattern1, keyp, size) == 0, "wrong key content");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksWriteKey(0, sizeof(pattern2), pattern2);
-test_assert(error == KS_NOERROR, "error updating the key");
-error = ksGetKey(0, &size, &keyp);
-test_assert(error == KS_NOERROR, "key not found");
-test_assert(size == sizeof(pattern2), "unexpected key length");
+ <value><![CDATA[kserror_t error;
+
+error = ksWriteKey(0, sizeof(pattern2), pattern2);
+test_assert(error == KS_NOERROR, "error updating the key");
+error = ksGetKey(0, &size, &keyp);
+test_assert(error == KS_NOERROR, "key not found");
+test_assert(size == sizeof(pattern2), "unexpected key length");
test_assert(memcmp(pattern2, keyp, size) == 0, "wrong key content");]]></value>
</code>
</step>
@@ -359,13 +362,13 @@ test_assert(memcmp(pattern2, keyp, size) == 0, "wrong key content");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksWriteKey(0, sizeof(pattern3), pattern3);
-test_assert(error == KS_NOERROR, "error updating the key");
-error = ksGetKey(0, &size, &keyp);
-test_assert(error == KS_NOERROR, "key not found");
-test_assert(size == sizeof(pattern3), "unexpected key length");
+ <value><![CDATA[kserror_t error;
+
+error = ksWriteKey(0, sizeof(pattern3), pattern3);
+test_assert(error == KS_NOERROR, "error updating the key");
+error = ksGetKey(0, &size, &keyp);
+test_assert(error == KS_NOERROR, "key not found");
+test_assert(size == sizeof(pattern3), "unexpected key length");
test_assert(memcmp(pattern3, keyp, size) == 0, "wrong key content");]]></value>
</code>
</step>
@@ -377,11 +380,11 @@ test_assert(memcmp(pattern3, keyp, size) == 0, "wrong key content");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksEraseKey(0);
-test_assert(error == KS_NOERROR, "error erasing the key");
-error = ksGetKey(0, &size, &keyp);
+ <value><![CDATA[kserror_t error;
+
+error = ksEraseKey(0);
+test_assert(error == KS_NOERROR, "error erasing the key");
+error = ksGetKey(0, &size, &keyp);
test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
</code>
</step>
@@ -399,8 +402,8 @@ test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
</condition>
<various_code>
<setup_code>
- <value><![CDATA[ks_lld_block_erase(KS_BLOCK0);
-ks_lld_block_erase(KS_BLOCK1);
+ <value><![CDATA[ks_lld_block_erase(KS_BLOCK0);
+ks_lld_block_erase(KS_BLOCK1);
ksInit();]]></value>
</setup_code>
<teardown_code>
@@ -419,13 +422,13 @@ ksInit();]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksWriteKey(0, sizeof(pattern1), pattern1);
-test_assert(error == KS_NOERROR, "error creating the key");
-error = ksWriteKey(1, sizeof(pattern2), pattern2);
-test_assert(error == KS_NOERROR, "error creating the key");
-error = ksWriteKey(2, sizeof(pattern3), pattern3);
+ <value><![CDATA[kserror_t error;
+
+error = ksWriteKey(0, sizeof(pattern1), pattern1);
+test_assert(error == KS_NOERROR, "error creating the key");
+error = ksWriteKey(1, sizeof(pattern2), pattern2);
+test_assert(error == KS_NOERROR, "error creating the key");
+error = ksWriteKey(2, sizeof(pattern3), pattern3);
test_assert(error == KS_NOERROR, "error creating the key");]]></value>
</code>
</step>
@@ -437,17 +440,17 @@ test_assert(error == KS_NOERROR, "error creating the key");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-error = ksErase();
-test_assert(error == KS_NOERROR, "storage erase error");
-error = ksGetKey(0, &size, &keyp);
-test_assert(error == KS_KEY_NOT_FOUND, "key 0 still present");
-error = ksGetKey(1, &size, &keyp);
-test_assert(error == KS_KEY_NOT_FOUND, "key 1 still present");
-error = ksGetKey(2, &size, &keyp);
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+error = ksErase();
+test_assert(error == KS_NOERROR, "storage erase error");
+error = ksGetKey(0, &size, &keyp);
+test_assert(error == KS_KEY_NOT_FOUND, "key 0 still present");
+error = ksGetKey(1, &size, &keyp);
+test_assert(error == KS_KEY_NOT_FOUND, "key 1 still present");
+error = ksGetKey(2, &size, &keyp);
test_assert(error == KS_KEY_NOT_FOUND, "key 2 still present");]]></value>
</code>
</step>
@@ -465,7 +468,7 @@ test_assert(error == KS_KEY_NOT_FOUND, "key 2 still present");]]></value>
</condition>
<various_code>
<setup_code>
- <value><![CDATA[ksInit();
+ <value><![CDATA[ksInit();
ksErase();]]></value>
</setup_code>
<teardown_code>
@@ -484,21 +487,21 @@ ksErase();]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-for (key = 0; key < kmax; key++) {
- kserror_t error;
- size_t size;
- uint8_t *keyp;
-
- error = ksWriteKey(key, sizeof(pattern512), pattern512);
- test_assert(error == KS_NOERROR, "error creating the key");
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_NOERROR, "key not found");
- test_assert(size == sizeof(pattern512), "unexpected key length");
- test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+ <value><![CDATA[kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+for (key = 0; key < kmax; key++) {
+ kserror_t error;
+ size_t size;
+ uint8_t *keyp;
+
+ error = ksWriteKey(key, sizeof(pattern512), pattern512);
+ test_assert(error == KS_NOERROR, "error creating the key");
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_NOERROR, "key not found");
+ test_assert(size == sizeof(pattern512), "unexpected key length");
+ test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
}]]></value>
</code>
</step>
@@ -510,11 +513,11 @@ for (key = 0; key < kmax; key++) {
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-error = ksWriteKey(kmax, sizeof(pattern512), pattern512);
+ <value><![CDATA[kserror_t error;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+error = ksWriteKey(kmax, sizeof(pattern512), pattern512);
test_assert(error == KS_OUT_OF_MEM, "creation didn't fail");]]></value>
</code>
</step>
@@ -526,33 +529,33 @@ test_assert(error == KS_OUT_OF_MEM, "creation didn't fail");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t remaining;
-
-remaining = KS_LLD_BLOCK0_ADDRESS + KS_LLD_BLOCKS_SIZE - (size_t)ks.free_next;
-test_assert(remaining >= sizeof(kskeyheader_t), "not enough space");
-test_assert((remaining & KS_LLD_PAGE_SIZE) == 0, "unaligned space");
-
-if (remaining > sizeof(kskeyheader_t) * 2) {
- error = ksWriteKey(KS_CFG_NUM_KEYS - 1,
- remaining - (sizeof(kskeyheader_t) * 2),
- pattern512);
- test_assert(error == KS_NOERROR, "error filling remaining space");
-}
-else {
- if (remaining == sizeof(kskeyheader_t) * 2) {
- error = ksEraseKey(1);
- test_assert(error == KS_NOERROR, "error filling remaining space");
- }
- error = ksEraseKey(0);
- test_assert(error == KS_NOERROR, "error filling remaining space");
-}
-
-remaining = KS_LLD_BLOCK0_ADDRESS + KS_LLD_BLOCKS_SIZE - (size_t)ks.free_next;
-test_assert(remaining == 0, "remaining space not zero");
-
-ksDeinit();
-error = ksInit();
+ <value><![CDATA[kserror_t error;
+size_t remaining;
+
+remaining = KS_LLD_BLOCK0_ADDRESS + KS_LLD_BLOCKS_SIZE - (size_t)ks.free_next;
+test_assert(remaining >= sizeof(kskeyheader_t), "not enough space");
+test_assert((remaining & KS_LLD_PAGE_SIZE) == 0, "unaligned space");
+
+if (remaining > sizeof(kskeyheader_t) * 2) {
+ error = ksWriteKey(KS_CFG_NUM_KEYS - 1,
+ remaining - (sizeof(kskeyheader_t) * 2),
+ pattern512);
+ test_assert(error == KS_NOERROR, "error filling remaining space");
+}
+else {
+ if (remaining == sizeof(kskeyheader_t) * 2) {
+ error = ksEraseKey(1);
+ test_assert(error == KS_NOERROR, "error filling remaining space");
+ }
+ error = ksEraseKey(0);
+ test_assert(error == KS_NOERROR, "error filling remaining space");
+}
+
+remaining = KS_LLD_BLOCK0_ADDRESS + KS_LLD_BLOCKS_SIZE - (size_t)ks.free_next;
+test_assert(remaining == 0, "remaining space not zero");
+
+ksDeinit();
+error = ksInit();
test_assert(error == KS_NOERROR, "initialization error");]]></value>
</code>
</step>
@@ -570,7 +573,7 @@ test_assert(error == KS_NOERROR, "initialization error");]]></value>
</condition>
<various_code>
<setup_code>
- <value><![CDATA[ksInit();
+ <value><![CDATA[ksInit();
ksErase();]]></value>
</setup_code>
<teardown_code>
@@ -589,21 +592,21 @@ ksErase();]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-for (key = 0; key < kmax; key++) {
- kserror_t error;
- size_t size;
- uint8_t *keyp;
-
- error = ksWriteKey(key, sizeof(pattern512), pattern512);
- test_assert(error == KS_NOERROR, "error creating the key");
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_NOERROR, "key not found");
- test_assert(size == sizeof(pattern512), "unexpected key length");
- test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+ <value><![CDATA[kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+for (key = 0; key < kmax; key++) {
+ kserror_t error;
+ size_t size;
+ uint8_t *keyp;
+
+ error = ksWriteKey(key, sizeof(pattern512), pattern512);
+ test_assert(error == KS_NOERROR, "error creating the key");
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_NOERROR, "key not found");
+ test_assert(size == sizeof(pattern512), "unexpected key length");
+ test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
}]]></value>
</code>
</step>
@@ -615,13 +618,13 @@ for (key = 0; key < kmax; key++) {
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-error = ksEraseKey(16);
-test_assert(error == KS_NOERROR, "error erasing the key");
-error = ksGetKey(16, &size, &keyp);
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+error = ksEraseKey(16);
+test_assert(error == KS_NOERROR, "error erasing the key");
+error = ksGetKey(16, &size, &keyp);
test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
</code>
</step>
@@ -633,19 +636,19 @@ test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-test_assert(ks.header->fields.instance == 1, "not first instance");
-error = ksWriteKey(16, sizeof(pattern512), pattern512);
-test_assert(error == KS_WARNING, "error creating the key");
-test_assert(ks.header->fields.instance == 2, "not second instance");
-error = ksGetKey(16, &size, &keyp);
-test_assert(error == KS_NOERROR, "key not found");
-test_assert(size == sizeof(pattern512), "unexpected key length");
-test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
-test_assert(ks.block == KS_BLOCK1, "unexpected block");
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+test_assert(ks.header->fields.instance == 1, "not first instance");
+error = ksWriteKey(16, sizeof(pattern512), pattern512);
+test_assert(error == KS_WARNING, "error creating the key");
+test_assert(ks.header->fields.instance == 2, "not second instance");
+error = ksGetKey(16, &size, &keyp);
+test_assert(error == KS_NOERROR, "key not found");
+test_assert(size == sizeof(pattern512), "unexpected key length");
+test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+test_assert(ks.block == KS_BLOCK1, "unexpected block");
test_assert(ks_lld_is_block_erased(KS_BLOCK0) == true, "block 0 not erased");]]></value>
</code>
</step>
@@ -657,25 +660,25 @@ test_assert(ks_lld_is_block_erased(KS_BLOCK0) == true, "block 0 not erased");]]>
<value />
</tags>
<code>
- <value><![CDATA[kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
- kserror_t error;
- size_t size;
- uint8_t *keyp;
-
- if (key < kmax) {
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_NOERROR, "key not found");
- test_assert(size == sizeof(pattern512), "unexpected key length");
- test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
- }
- else {
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_KEY_NOT_FOUND, "found unexpected key");
- }
+ <value><![CDATA[kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
+ kserror_t error;
+ size_t size;
+ uint8_t *keyp;
+
+ if (key < kmax) {
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_NOERROR, "key not found");
+ test_assert(size == sizeof(pattern512), "unexpected key length");
+ test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+ }
+ else {
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_KEY_NOT_FOUND, "found unexpected key");
+ }
}]]></value>
</code>
</step>
@@ -687,13 +690,13 @@ for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-error = ksEraseKey(16);
-test_assert(error == KS_NOERROR, "error erasing the key");
-error = ksGetKey(16, &size, &keyp);
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+error = ksEraseKey(16);
+test_assert(error == KS_NOERROR, "error erasing the key");
+error = ksGetKey(16, &size, &keyp);
test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
</code>
</step>
@@ -705,19 +708,19 @@ test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-test_assert(ks.header->fields.instance == 2, "not second instance");
-error = ksWriteKey(16, sizeof(pattern512), pattern512);
-test_assert(error == KS_WARNING, "error creating the key");
-test_assert(ks.header->fields.instance == 3, "not third instance");
-error = ksGetKey(16, &size, &keyp);
-test_assert(error == KS_NOERROR, "key not found");
-test_assert(size == sizeof(pattern512), "unexpected key length");
-test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
-test_assert(ks.block == KS_BLOCK0, "unexpected block");
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+test_assert(ks.header->fields.instance == 2, "not second instance");
+error = ksWriteKey(16, sizeof(pattern512), pattern512);
+test_assert(error == KS_WARNING, "error creating the key");
+test_assert(ks.header->fields.instance == 3, "not third instance");
+error = ksGetKey(16, &size, &keyp);
+test_assert(error == KS_NOERROR, "key not found");
+test_assert(size == sizeof(pattern512), "unexpected key length");
+test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+test_assert(ks.block == KS_BLOCK0, "unexpected block");
test_assert(ks_lld_is_block_erased(KS_BLOCK1) == true, "block 0 not erased");]]></value>
</code>
</step>
@@ -729,25 +732,25 @@ test_assert(ks_lld_is_block_erased(KS_BLOCK1) == true, "block 0 not erased");]]>
<value />
</tags>
<code>
- <value><![CDATA[kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
- kserror_t error;
- size_t size;
- uint8_t *keyp;
-
- if (key < kmax) {
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_NOERROR, "key not found");
- test_assert(size == sizeof(pattern512), "unexpected key length");
- test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
- }
- else {
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_KEY_NOT_FOUND, "found unexpected key");
- }
+ <value><![CDATA[kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
+ kserror_t error;
+ size_t size;
+ uint8_t *keyp;
+
+ if (key < kmax) {
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_NOERROR, "key not found");
+ test_assert(size == sizeof(pattern512), "unexpected key length");
+ test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+ }
+ else {
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_KEY_NOT_FOUND, "found unexpected key");
+ }
}]]></value>
</code>
</step>
@@ -765,7 +768,7 @@ for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
</condition>
<various_code>
<setup_code>
- <value><![CDATA[ksInit();
+ <value><![CDATA[ksInit();
ksErase();]]></value>
</setup_code>
<teardown_code>
@@ -784,21 +787,21 @@ ksErase();]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-for (key = 0; key < kmax; key++) {
- kserror_t error;
- size_t size;
- uint8_t *keyp;
-
- error = ksWriteKey(key, sizeof(pattern512), pattern512);
- test_assert(error == KS_NOERROR, "error creating the key");
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_NOERROR, "key not found");
- test_assert(size == sizeof(pattern512), "unexpected key length");
- test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+ <value><![CDATA[kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+for (key = 0; key < kmax; key++) {
+ kserror_t error;
+ size_t size;
+ uint8_t *keyp;
+
+ error = ksWriteKey(key, sizeof(pattern512), pattern512);
+ test_assert(error == KS_NOERROR, "error creating the key");
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_NOERROR, "key not found");
+ test_assert(size == sizeof(pattern512), "unexpected key length");
+ test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
}]]></value>
</code>
</step>
@@ -810,21 +813,21 @@ for (key = 0; key < kmax; key++) {
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-kskey_t n = ((KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) -
- (kmax * (sizeof(kskeyheader_t) + sizeof(pattern512)))) /
- sizeof(kskeyheader_t);
-
-for (key = 0; key < n; key++) {
- error = ksEraseKey(key);
- test_assert(error == KS_NOERROR, "error erasing the key");
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_KEY_NOT_FOUND, "key not erased");
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+kskey_t n = ((KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) -
+ (kmax * (sizeof(kskeyheader_t) + sizeof(pattern512)))) /
+ sizeof(kskeyheader_t);
+
+for (key = 0; key < n; key++) {
+ error = ksEraseKey(key);
+ test_assert(error == KS_NOERROR, "error erasing the key");
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_KEY_NOT_FOUND, "key not erased");
}]]></value>
</code>
</step>
@@ -836,17 +839,17 @@ for (key = 0; key < n; key++) {
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-test_assert(ks.header->fields.instance == 1, "not first instance");
-error = ksEraseKey(16);
-test_assert(error == KS_WARNING, "error erasing the key");
-test_assert(ks.header->fields.instance == 2, "not second instance");
-error = ksGetKey(16, &size, &keyp);
-test_assert(error == KS_KEY_NOT_FOUND, "key not erased");
-test_assert(ks.block == KS_BLOCK1, "unexpected block");
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+test_assert(ks.header->fields.instance == 1, "not first instance");
+error = ksEraseKey(16);
+test_assert(error == KS_WARNING, "error erasing the key");
+test_assert(ks.header->fields.instance == 2, "not second instance");
+error = ksGetKey(16, &size, &keyp);
+test_assert(error == KS_KEY_NOT_FOUND, "key not erased");
+test_assert(ks.block == KS_BLOCK1, "unexpected block");
test_assert(ks_lld_is_block_erased(KS_BLOCK0) == true, "block 0 not erased");]]></value>
</code>
</step>