[PATCH v2] rtems:modify spthread01 testsuites for cond variable signal and broadcast intf rtems:making rectification according to Sebastian Huber's opinions
Gedare Bloom
gedare at rtems.org
Thu Jul 15 15:47:12 UTC 2021
The commit message should be rewritten. someone can do this on a push,
but if you send a v3 of the patch, please simplify the first line of
the commit message, like
"testsuites/sptests: add cond variable signal and broadcast to spthread01"
That should be an adequate commit message for this change anyway. If
you want to add more details though, you can do it by adding a blank
line after the first commit line, and writing it in a paragraph form
in your commit text editor.
On Wed, Jul 7, 2021 at 11:50 PM <tianye at sugon.com> wrote:
>
> From: tianye <tianye at sugon.com>
>
If you have a fuller name to provide, we do like to keep the code
author records.
> ---
> testsuites/sptests/spthread01/init.c | 86 +++++++++++++++++++++++++++++++-----
> 1 file changed, 74 insertions(+), 12 deletions(-)
>
> diff --git a/testsuites/sptests/spthread01/init.c b/testsuites/sptests/spthread01/init.c
> index 9044ca2..b64d0a5 100644
> --- a/testsuites/sptests/spthread01/init.c
> +++ b/testsuites/sptests/spthread01/init.c
> @@ -165,6 +165,7 @@ static void test_recursive_mutex(void)
> typedef struct {
> rtems_mutex mtx;
> rtems_condition_variable cnd;
> + unsigned int exeting_task_cnt;
typo: exiting
> } signal_context;
>
> static void signal_task(rtems_task_argument arg)
> @@ -173,8 +174,10 @@ static void signal_task(rtems_task_argument arg)
>
> s = (signal_context *) arg;
> rtems_mutex_lock(&s->mtx);
> - rtems_condition_variable_signal(&s->cnd);
> + rtems_condition_variable_wait(&s->cnd, &s->mtx);
> rtems_mutex_unlock(&s->mtx);
> + s->exeting_task_cnt++;
> + rtems_task_exit();
> }
>
> static void test_condition_variable(void)
> @@ -183,7 +186,9 @@ static void test_condition_variable(void)
> signal_context s;
> const char *name;
> rtems_status_code sc;
> - rtems_id id;
> + rtems_id id1;
> + rtems_id id2;
> + rtems_task_priority task_priority;
>
> name = rtems_condition_variable_get_name(&a);
> rtems_test_assert(strcmp(name, "a") == 0);
> @@ -201,34 +206,91 @@ static void test_condition_variable(void)
> name = rtems_condition_variable_get_name(&s.cnd);
> rtems_test_assert(strcmp(name, "c") == 0);
>
> - rtems_condition_variable_signal(&s.cnd);
> + s.exeting_task_cnt = 0;
> + sc = rtems_task_create(
> + rtems_build_name('C', 'O', 'D', '1'),
> + 2,
> + RTEMS_MINIMUM_STACK_SIZE,
> + RTEMS_DEFAULT_MODES,
> + RTEMS_DEFAULT_ATTRIBUTES,
> + &id1
> + );
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> + sc = rtems_task_start(id1, signal_task, (rtems_task_argument) &s);
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> + sc = rtems_task_create(
> + rtems_build_name('C', 'O', 'D', '2'),
> + 2,
> + RTEMS_MINIMUM_STACK_SIZE,
> + RTEMS_DEFAULT_MODES,
> + RTEMS_DEFAULT_ATTRIBUTES,
> + &id2
> + );
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> + sc = rtems_task_start(id2, signal_task, (rtems_task_argument) &s);
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>
> - rtems_condition_variable_broadcast(&s.cnd);
> + sc = rtems_task_set_priority(rtems_task_self(), RTEMS_MAXIMUM_PRIORITY - 1, &task_priority);
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> + sc = rtems_task_wake_after(0);
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>
> rtems_mutex_lock(&s.mtx);
> + rtems_condition_variable_signal(&s.cnd);
> + rtems_mutex_unlock(&s.mtx);
> + sc = rtems_task_wake_after(0);
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> +
> + rtems_test_assert(s.exeting_task_cnt == 1);
> + sc = rtems_task_delete(id1);
> + sc = rtems_task_delete(id2);
> + rtems_condition_variable_destroy(&s.cnd);
> + rtems_mutex_destroy(&s.mtx);
> + sc = rtems_task_set_priority(rtems_task_self(), task_priority, &task_priority);
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>
> + s.exeting_task_cnt = 0;
> sc = rtems_task_create(
> - rtems_build_name('C', 'O', 'N', 'D'),
> + rtems_build_name('C', 'O', 'D', '1'),
> 2,
> RTEMS_MINIMUM_STACK_SIZE,
> RTEMS_DEFAULT_MODES,
> RTEMS_DEFAULT_ATTRIBUTES,
> - &id
> + &id1
> );
> rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> -
> - sc = rtems_task_start(id, signal_task, (rtems_task_argument) &s);
> + sc = rtems_task_start(id1, signal_task, (rtems_task_argument) &s);
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> + sc = rtems_task_create(
> + rtems_build_name('C', 'O', 'D', '2'),
> + 2,
> + RTEMS_MINIMUM_STACK_SIZE,
> + RTEMS_DEFAULT_MODES,
> + RTEMS_DEFAULT_ATTRIBUTES,
> + &id2
> + );
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> + sc = rtems_task_start(id2, signal_task, (rtems_task_argument) &s);
> rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>
> - rtems_condition_variable_wait(&s.cnd, &s.mtx);
> -
> - sc = rtems_task_delete(id);
> + sc = rtems_task_set_priority(rtems_task_self(), RTEMS_MAXIMUM_PRIORITY - 1, &task_priority);
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> + sc = rtems_task_wake_after(0);
> rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>
> + rtems_mutex_lock(&s.mtx);
> + rtems_condition_variable_broadcast(&s.cnd);
> rtems_mutex_unlock(&s.mtx);
> + sc = rtems_task_wake_after(0);
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>
> + rtems_test_assert(s.exeting_task_cnt == 2);
> + sc = rtems_task_delete(id1);
> + sc = rtems_task_delete(id2);
> rtems_condition_variable_destroy(&s.cnd);
> rtems_mutex_destroy(&s.mtx);
> + sc = rtems_task_set_priority(rtems_task_self(), task_priority, &task_priority);
> + rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> }
>
> static void test_counting_semaphore(void)
> @@ -319,7 +381,7 @@ static void Init(rtems_task_argument arg)
> #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
> #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
>
> -#define CONFIGURE_MAXIMUM_TASKS 2
> +#define CONFIGURE_MAXIMUM_TASKS 3
>
> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
>
> --
> 1.8.3.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
More information about the devel
mailing list