aboutsummaryrefslogtreecommitdiffstats
path: root/test/oslib/configuration.xml
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-10-24 13:58:24 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-10-24 13:58:24 +0000
commitde3fbaebe6f00a5109f4a107372d0b059f27de51 (patch)
treecfd653584bdf76f56c2aa9e439191f781d88f5c5 /test/oslib/configuration.xml
parente0bfea5f016021d639093705b3baff1513cb066b (diff)
downloadChibiOS-de3fbaebe6f00a5109f4a107372d0b059f27de51.tar.gz
ChibiOS-de3fbaebe6f00a5109f4a107372d0b059f27de51.tar.bz2
ChibiOS-de3fbaebe6f00a5109f4a107372d0b059f27de51.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10896 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/oslib/configuration.xml')
-rw-r--r--test/oslib/configuration.xml122
1 files changed, 121 insertions, 1 deletions
diff --git a/test/oslib/configuration.xml b/test/oslib/configuration.xml
index 54f56fd90..f663afc3b 100644
--- a/test/oslib/configuration.xml
+++ b/test/oslib/configuration.xml
@@ -965,7 +965,127 @@ test_assert(p1 == NULL, "allocation not failed");]]></value>
<shared_code>
<value />
</shared_code>
- <cases />
+ <cases>
+ <case>
+ <brief>
+ <value>Objects Registry.</value>
+ </brief>
+ <description>
+ <value>This test case verifies the static objects registry.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value />
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[registered_object_t *rop;]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>Retrieving a registered object by name, must not exist.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[registered_object_t *rop;
+
+rop = chFactoryFindObject("myobj");
+test_assert(rop == NULL, "found");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Registering an object, it must not exists, must succeed.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[registered_object_t *rop;
+static uint32_t myobj = 0x55aa;
+
+rop = chFactoryRegisterObject("myobj", (void *)&myobj);
+test_assert(rop != NULL, "cannot register");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Registering an object with the same name, must fail.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[registered_object_t *rop1;
+static uint32_t myobj = 0x55aa;
+
+rop1 = chFactoryRegisterObject("myobj", (void *)&myobj);
+test_assert(rop1 == NULL, "can register");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Retrieving the registered object by name, must exist, then increasing the reference counter, finally releasing both references.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[registered_object_t *rop1, *rop2;
+
+rop1 = chFactoryFindObject("myobj");
+test_assert(rop1 != NULL, "not found");
+test_assert(*(uint32_t *)(rop1->objp) == 0x55aa, "object mismatch");
+test_assert(rop == rop1, "object reference mismatch");
+test_assert(rop1->element.refs == 2, "object reference mismatch");
+
+rop2 = (registered_object_t *)chFactoryDuplicateReference((dyn_element_t *)rop1);
+test_assert(rop1 == rop2, "object reference mismatch");
+test_assert(*(uint32_t *)(rop2->objp) == 0x55aa, "object mismatch");
+test_assert(rop1->element.refs == 3, "object reference mismatch");
+
+chFactoryReleaseObject(rop1);
+test_assert(rop->element.refs == 2, "references mismatch");
+
+chFactoryReleaseObject(rop2);
+test_assert(rop->element.refs == 1, "references mismatch");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Releasing the first reference to the object, must not trigger an assertion.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[chFactoryReleaseObject(rop);]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Retrieving the registered object by name again, must not exist.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[rop = chFactoryFindObject("myobj");
+test_assert(rop == NULL, "found");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ </cases>
</sequence>
</sequences>
</instance>