diff options
| author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-02-11 09:59:20 +0000 | 
|---|---|---|
| committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-02-11 09:59:20 +0000 | 
| commit | 4541bd732acf21e30f40f5b6c991172e2e350cb0 (patch) | |
| tree | 26f67ddc4cf7c6d57b37272f8c015f3479555661 /test | |
| parent | 47f0e8fb7f337b65f848bf4cd59577d3967d0862 (diff) | |
| download | ChibiOS-4541bd732acf21e30f40f5b6c991172e2e350cb0.tar.gz ChibiOS-4541bd732acf21e30f40f5b6c991172e2e350cb0.tar.bz2 ChibiOS-4541bd732acf21e30f40f5b6c991172e2e350cb0.zip  | |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6700 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test')
| -rw-r--r-- | test/nil/test_root.c | 2 | ||||
| -rw-r--r-- | test/nil/test_root.h | 1 | ||||
| -rw-r--r-- | test/nil/test_sequence_002.c | 87 | 
3 files changed, 85 insertions, 5 deletions
diff --git a/test/nil/test_root.c b/test/nil/test_root.c index cd3c8b681..49c1d7862 100644 --- a/test/nil/test_root.c +++ b/test/nil/test_root.c @@ -44,6 +44,7 @@ const testcase_t * const *test_suite[] = {  /*===========================================================================*/
  semaphore_t gsem1, gsem2;
 +thread_reference_t gtr1;
  /*
   * Support thread.
 @@ -63,6 +64,7 @@ THD_FUNCTION(test_support, arg) {      if (chSemGetCounterI(&gsem1) < 0)
        chSemSignalI(&gsem1);
      chSemResetI(&gsem2, 0);
 +    chThdResumeI(>r1, MSG_OK);
      chSchRescheduleS();
      chSysUnlock();
 diff --git a/test/nil/test_root.h b/test/nil/test_root.h index 51a100922..f3ae952d6 100644 --- a/test/nil/test_root.h +++ b/test/nil/test_root.h @@ -48,6 +48,7 @@ extern const testcase_t * const *test_suite[];  extern "C" {
  #endif
    extern semaphore_t gsem1, gsem2;
 +  extern thread_reference_t gtr1;
    extern THD_WORKING_AREA(wa_test_support, 128);
    THD_FUNCTION(test_support, arg);
  #ifdef __cplusplus
 diff --git a/test/nil/test_sequence_002.c b/test/nil/test_sequence_002.c index 9fa425c18..ddb6379ff 100644 --- a/test/nil/test_sequence_002.c +++ b/test/nil/test_sequence_002.c @@ -38,6 +38,7 @@   ****************************************************************************/
  static semaphore_t sem1;
 +static thread_reference_t tr1;
  /****************************************************************************
   * Test cases.
 @@ -86,7 +87,7 @@ static void test_002_001_execute(void) {      test_assert_lock(chSemGetCounterI(&sem1) == 0,
                       "wrong counter value");
      test_assert(MSG_OK == msg,
 -                "wrong timeout message");
 +                "wrong returned message");
    }
    /* The function chSemSignal() is invoked, after return the counter
 @@ -128,6 +129,12 @@ static const testcase_t test_002_001 = {   * None.
   *
   * <h2>Test Steps</h2>
 + * - The function chSemWait() is invoked, after return the counter and
 + *   the returned message are tested. The semaphore is signaled by another
 + *   thread.
 + * - The function chSemWait() is invoked, after return the counter and
 + *   the returned message are tested. The semaphore is reset by another
 + *   thread.
   * .
   */
 @@ -154,7 +161,7 @@ static void test_002_002_execute(void) {      test_assert_lock(chSemGetCounterI(&gsem1) == 0,
                       "wrong counter value");
      test_assert(MSG_OK == msg,
 -                "wrong timeout message");
 +                "wrong returned message");
    }
    /* The function chSemWait() is invoked, after return the counter and
 @@ -168,7 +175,7 @@ static void test_002_002_execute(void) {      test_assert_lock(chSemGetCounterI(&gsem2) == 0,
                       "wrong counter value");
      test_assert(MSG_RESET == msg,
 -                "wrong timeout message");
 +                "wrong returned message");
    }
  }
 @@ -225,9 +232,9 @@ static void test_002_003_execute(void) {                  "wrong timeout message");
    }
 -  /* The function chSemWait() is invoked, after return the system
 +  /* The function chSemWaitTimeout() is invoked, after return the system
       time, the counter and the returned message are tested.*/
 -  test_set_step(1);
 +  test_set_step(2);
    {
      time = chVTGetSystemTimeX();
      msg = chSemWaitTimeout(&sem1, 100);
 @@ -249,6 +256,73 @@ static const testcase_t test_002_003 = {  };
  #endif /* TRUE */
 +#if TRUE || defined(__DOXYGEN__)
 +/**
 + * @page test_002_004 Suspend and Resume functionality
 + *
 + * <h2>Description</h2>
 + * The functionality of chThdSuspendTimeoutS() and chThdResumeI() is
 + * tested.
 + *
 + * <h2>Conditions</h2>
 + * None.
 + *
 + * <h2>Test Steps</h2>
 + * - The function chThdSuspendTimeoutS() is invoked, the thread is
 + *   remotely resumed with message @p MSG_OK. On return the message
 + *   and the state of the reference are tested.
 + * - The function chThdSuspendTimeoutS() is invoked, the thread is
 + *   not resumed so a timeout must occur. On return the message
 + *   and the state of the reference are tested.
 + * .
 + */
 +
 +static void test_002_004_setup(void) {
 +
 +  tr1 = NULL;
 +}
 +
 +static void test_002_004_execute(void) {
 +  systime_t time;
 +  msg_t msg;
 +
 +  /* The function chThdSuspendTimeoutS() is invoked, the thread is
 +     remotely resumed with message @p MSG_OK. On return the message
 +     and the state of the reference are tested.*/
 +  test_set_step(1);
 +  {
 +    msg = chThdSuspendTimeoutS(>r1, TIME_INFINITE);
 +    test_assert(NULL == gtr1,
 +                "not NULL");
 +    test_assert(MSG_OK == msg,
 +                "wrong returned message");
 +  }
 +
 +  /* The function chThdSuspendTimeoutS() is invoked, the thread is
 +     not resumed so a timeout must occur. On return the message
 +     and the state of the reference are tested.*/
 +  test_set_step(2);
 +  {
 +    time = chVTGetSystemTimeX();
 +    msg = chThdSuspendTimeoutS(>r1, 100);
 +    test_assert_time_window(time + 100,
 +                            time + 100 + 1,
 +                            "out of time window");
 +    test_assert(NULL == gtr1,
 +                "not NULL");
 +    test_assert(MSG_TIMEOUT == msg,
 +                "wrong returned message");
 +  }
 +}
 +
 +static const testcase_t test_002_004 = {
 +  "suspend and resume functionality",
 +  test_002_004_setup,
 +  NULL,
 +  test_002_004_execute
 +};
 +#endif /* TRUE */
 +
   /****************************************************************************
   * Exported data.
   ****************************************************************************/
 @@ -266,5 +340,8 @@ const testcase_t * const test_sequence_002[] = {  #if TRUE || defined(__DOXYGEN__)
    &test_002_003,
  #endif
 +#if TRUE || defined(__DOXYGEN__)
 +  &test_002_004,
 +#endif
    NULL
  };
  | 
