aboutsummaryrefslogtreecommitdiffstats
path: root/test/oslib/configuration.xml
diff options
context:
space:
mode:
Diffstat (limited to 'test/oslib/configuration.xml')
-rw-r--r--test/oslib/configuration.xml118
1 files changed, 118 insertions, 0 deletions
diff --git a/test/oslib/configuration.xml b/test/oslib/configuration.xml
index e7ffca0a0..292d0198f 100644
--- a/test/oslib/configuration.xml
+++ b/test/oslib/configuration.xml
@@ -1207,6 +1207,124 @@ test_assert(dbp == NULL, "found");]]></value>
</step>
</steps>
</case>
+ <case>
+ <brief>
+ <value>Dynamic Semaphores Factory.</value>
+ </brief>
+ <description>
+ <value>This test case verifies the dynamic semaphores factory.</value>
+ </description>
+ <condition>
+ <value>CH_CFG_FACTORY_SEMAPHORES == TRUE</value>
+ </condition>
+ <various_code>
+ <setup_code>
+ <value />
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[dyn_semaphore_t *dsp;
+
+dsp = chFactoryFindSemaphore("mysem");
+if (dsp != NULL) {
+ while (dsp->element.refs > 0U) {
+ chFactoryReleaseSemaphore(dsp);
+ }
+}]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[dyn_semaphore_t *dsp;]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>Retrieving a dynamic semaphore by name, must not exist.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[dsp = chFactoryFindSemaphore("mysem");
+test_assert(dsp == NULL, "found");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Creating a dynamic semaphore it must not exists, must succeed.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[dsp = chFactoryCreateSemaphore("mysem", 0);
+test_assert(dsp != NULL, "cannot create");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Creating a dynamic semaphore with the same name, must fail.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[dyn_semaphore_t *dsp1;
+
+dsp1 = chFactoryCreateSemaphore("mysem", 0);
+test_assert(dsp1 == NULL, "can create");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Retrieving the dynamic semaphore by name, must exist, then increasing the reference counter, finally releasing both references.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[dyn_semaphore_t *dsp1, *dsp2;
+
+dsp1 = chFactoryFindSemaphore("mysem");
+test_assert(dsp1 != NULL, "not found");
+test_assert(dsp == dsp1, "object reference mismatch");
+test_assert(dsp1->element.refs == 2, "object reference mismatch");
+
+dsp2 = (dyn_semaphore_t *)chFactoryDuplicateReference((dyn_element_t *)dsp1);
+test_assert(dsp1 == dsp2, "object reference mismatch");
+test_assert(dsp2->element.refs == 3, "object reference mismatch");
+
+chFactoryReleaseSemaphore(dsp2);
+test_assert(dsp1->element.refs == 2, "references mismatch");
+
+chFactoryReleaseSemaphore(dsp1);
+test_assert(dsp->element.refs == 1, "references mismatch");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Releasing the first reference to the dynamic semaphore must not trigger an assertion.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[chFactoryReleaseSemaphore(dsp);]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Retrieving the dynamic semaphore by name again, must not exist.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[dsp = chFactoryFindSemaphore("mysem");
+test_assert(dsp == NULL, "found");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
</cases>
</sequence>
</sequences>