diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/nasa_osal/configuration.xml | 137 | ||||
| -rw-r--r-- | test/nasa_osal/source/test/test_sequence_002.c | 124 | 
2 files changed, 261 insertions, 0 deletions
| diff --git a/test/nasa_osal/configuration.xml b/test/nasa_osal/configuration.xml index 69db8c2f8..6924cd1a4 100644 --- a/test/nasa_osal/configuration.xml +++ b/test/nasa_osal/configuration.xml @@ -854,6 +854,143 @@ test_assert_sequence("", "queue write errors occurred");]]></value>                    </step>
                  </steps>
                </case>
 +              <case>
 +                <brief>
 +                  <value>OS_QueueGetIdByName() errors</value>
 +                </brief>
 +                <description>
 +                  <value>Parameters checking in OS_QueueGetIdByName() is tested.</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>OS_QueueGetIdByName() is invoked with queue_id set to NULL, an error is expected.</value>
 +                    </description>
 +                    <tags>
 +                      <value />
 +                    </tags>
 +                    <code>
 +                      <value><![CDATA[int32 err; + +err = OS_QueueGetIdByName(NULL, "queue"); +test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
 +                    </code>
 +                  </step>
 +                  <step>
 +                    <description>
 +                      <value>OS_QueueGetIdByName() is invoked with queue_name set to NULL, an error is expected.</value>
 +                    </description>
 +                    <tags>
 +                      <value />
 +                    </tags>
 +                    <code>
 +                      <value><![CDATA[int32 err; + +err = OS_QueueGetIdByName(&qid, NULL); +test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
 +                    </code>
 +                  </step>
 +                  <step>
 +                    <description>
 +                      <value>OS_QueueGetIdByName() is invoked with a very long task name, an error is expected.</value>
 +                    </description>
 +                    <tags>
 +                      <value />
 +                    </tags>
 +                    <code>
 +                      <value><![CDATA[int32 err; + +err = OS_QueueGetIdByName(&qid, "very very long queue name"); +test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");]]></value>
 +                    </code>
 +                  </step>
 +                </steps>
 +              </case>
 +              <case>
 +                <brief>
 +                  <value>OS_QueueGet() with timeout</value>
 +                </brief>
 +                <description>
 +                  <value>OS_QueueGetIdByName is tested.</value>
 +                </description>
 +                <condition>
 +                  <value />
 +                </condition>
 +                <various_code>
 +                  <setup_code>
 +                    <value><![CDATA[qid = 0; +(void) OS_QueueCreate(&qid, "test queue", 2, MESSAGE_SIZE, 0);]]></value>
 +                  </setup_code>
 +                  <teardown_code>
 +                    <value><![CDATA[if (qid != 0) { +  OS_QueueDelete(qid); +}]]></value>
 +                  </teardown_code>
 +                  <local_variables>
 +                    <value><![CDATA[uint32 local_qid;
 +uint32 copied;
 +char data[MESSAGE_SIZE];]]></value>
 +                  </local_variables>
 +                </various_code>
 +                <steps>
 +                  <step>
 +                    <description>
 +                      <value>Retrieving the queue name.</value>
 +                    </description>
 +                    <tags>
 +                      <value />
 +                    </tags>
 +                    <code>
 +                      <value><![CDATA[int32 err; + +err = OS_QueueGetIdByName(&local_qid, "test queue"); +test_assert(err == OS_SUCCESS, "queue not found");]]></value>
 +                    </code>
 +                  </step>
 +                  <step>
 +                    <description>
 +                      <value>Get operation with a one second timeout, an error is expected.</value>
 +                    </description>
 +                    <tags>
 +                      <value />
 +                    </tags>
 +                    <code>
 +                      <value><![CDATA[int32 err;
 +
 +err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_Milli2Ticks(1000));
 +test_assert(err == OS_QUEUE_TIMEOUT, "unexpected error code");]]></value>
 +                    </code>
 +                  </step>
 +                  <step>
 +                    <description>
 +                      <value>Get operation in non-blocking mode, an error is expected.</value>
 +                    </description>
 +                    <tags>
 +                      <value />
 +                    </tags>
 +                    <code>
 +                      <value><![CDATA[int32 err;
 +
 +err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_CHECK);
 +test_assert(err == OS_QUEUE_EMPTY, "unexpected error code");]]></value>
 +                    </code>
 +                  </step>
 +                </steps>
 +              </case>
              </cases>
            </sequence>
          </sequences>
 diff --git a/test/nasa_osal/source/test/test_sequence_002.c b/test/nasa_osal/source/test/test_sequence_002.c index 4b9da0522..44a4fe5df 100644 --- a/test/nasa_osal/source/test/test_sequence_002.c +++ b/test/nasa_osal/source/test/test_sequence_002.c @@ -30,6 +30,8 @@   * <h2>Test Cases</h2>
   * - @subpage test_002_001
   * - @subpage test_002_002
 + * - @subpage test_002_003
 + * - @subpage test_002_004
   * .
   */
 @@ -253,6 +255,126 @@ static const testcase_t test_002_002 = {    test_002_002_execute
  };
 +/**
 + * @page test_002_003 OS_QueueGetIdByName() errors
 + *
 + * <h2>Description</h2>
 + * Parameters checking in OS_QueueGetIdByName() is tested.
 + *
 + * <h2>Test Steps</h2>
 + * - OS_QueueGetIdByName() is invoked with queue_id set to NULL, an
 + *   error is expected.
 + * - OS_QueueGetIdByName() is invoked with queue_name set to NULL, an
 + *   error is expected.
 + * - OS_QueueGetIdByName() is invoked with a very long task name, an
 + *   error is expected.
 + * .
 + */
 +
 +static void test_002_003_execute(void) {
 +
 +  /* OS_QueueGetIdByName() is invoked with queue_id set to NULL, an
 +     error is expected.*/
 +  test_set_step(1);
 +  {
 +    int32 err;
 +
 +    err = OS_QueueGetIdByName(NULL, "queue");
 +    test_assert(err == OS_INVALID_POINTER, "NULL not detected");
 +  }
 +
 +  /* OS_QueueGetIdByName() is invoked with queue_name set to NULL, an
 +     error is expected.*/
 +  test_set_step(2);
 +  {
 +    int32 err;
 +
 +    err = OS_QueueGetIdByName(&qid, NULL);
 +    test_assert(err == OS_INVALID_POINTER, "NULL not detected");
 +  }
 +
 +  /* OS_QueueGetIdByName() is invoked with a very long task name, an
 +     error is expected.*/
 +  test_set_step(3);
 +  {
 +    int32 err;
 +
 +    err = OS_QueueGetIdByName(&qid, "very very long queue name");
 +    test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");
 +  }
 +}
 +
 +static const testcase_t test_002_003 = {
 +  "OS_QueueGetIdByName() errors",
 +  NULL,
 +  NULL,
 +  test_002_003_execute
 +};
 +
 +/**
 + * @page test_002_004 OS_QueueGet() with timeout
 + *
 + * <h2>Description</h2>
 + * OS_QueueGetIdByName is tested.
 + *
 + * <h2>Test Steps</h2>
 + * - Retrieving the queue name.
 + * - Get operation with a one second timeout, an error is expected.
 + * - Get operation in non-blocking mode, an error is expected.
 + * .
 + */
 +
 +static void test_002_004_setup(void) {
 +  qid = 0;
 +  (void) OS_QueueCreate(&qid, "test queue", 2, MESSAGE_SIZE, 0);
 +}
 +
 +static void test_002_004_teardown(void) {
 +  if (qid != 0) {
 +    OS_QueueDelete(qid);
 +  }
 +}
 +
 +static void test_002_004_execute(void) {
 +  uint32 local_qid;
 +  uint32 copied;
 +  char data[MESSAGE_SIZE];
 +
 +  /* Retrieving the queue name.*/
 +  test_set_step(1);
 +  {
 +    int32 err;
 +
 +    err = OS_QueueGetIdByName(&local_qid, "test queue");
 +    test_assert(err == OS_SUCCESS, "queue not found");
 +  }
 +
 +  /* Get operation with a one second timeout, an error is expected.*/
 +  test_set_step(2);
 +  {
 +    int32 err;
 +
 +    err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_Milli2Ticks(1000));
 +    test_assert(err == OS_QUEUE_TIMEOUT, "unexpected error code");
 +  }
 +
 +  /* Get operation in non-blocking mode, an error is expected.*/
 +  test_set_step(3);
 +  {
 +    int32 err;
 +
 +    err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_CHECK);
 +    test_assert(err == OS_QUEUE_EMPTY, "unexpected error code");
 +  }
 +}
 +
 +static const testcase_t test_002_004 = {
 +  "OS_QueueGet() with timeout",
 +  test_002_004_setup,
 +  test_002_004_teardown,
 +  test_002_004_execute
 +};
 +
  /****************************************************************************
   * Exported data.
   ****************************************************************************/
 @@ -263,5 +385,7 @@ static const testcase_t test_002_002 = {  const testcase_t * const test_sequence_002[] = {
    &test_002_001,
    &test_002_002,
 +  &test_002_003,
 +  &test_002_004,
    NULL
  };
 | 
