diff options
Diffstat (limited to 'testsuites/validation/tc-futex-wake.c')
-rw-r--r-- | testsuites/validation/tc-futex-wake.c | 80 |
1 files changed, 28 insertions, 52 deletions
diff --git a/testsuites/validation/tc-futex-wake.c b/testsuites/validation/tc-futex-wake.c index 1d996d1d2b..baaa0daa6b 100644 --- a/testsuites/validation/tc-futex-wake.c +++ b/testsuites/validation/tc-futex-wake.c @@ -3,11 +3,11 @@ /** * @file * - * @ingroup RTEMSTestCaseNewlibReqFutexWake + * @ingroup NewlibReqFutexWake */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2021 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -62,17 +62,16 @@ #include <rtems/test.h> /** - * @defgroup RTEMSTestCaseNewlibReqFutexWake spec:/newlib/req/futex-wake + * @defgroup NewlibReqFutexWake spec:/newlib/req/futex-wake * - * @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0 + * @ingroup TestsuitesValidationNoClock0 * * @{ */ typedef enum { - NewlibReqFutexWake_Pre_Count_Negative, - NewlibReqFutexWake_Pre_Count_Partial, - NewlibReqFutexWake_Pre_Count_All, + NewlibReqFutexWake_Pre_Count_NegativeOrZero, + NewlibReqFutexWake_Pre_Count_Positive, NewlibReqFutexWake_Pre_Count_NA } NewlibReqFutexWake_Pre_Count; @@ -83,8 +82,7 @@ typedef enum { typedef enum { NewlibReqFutexWake_Post_Flush_No, - NewlibReqFutexWake_Post_Flush_Partial, - NewlibReqFutexWake_Post_Flush_All, + NewlibReqFutexWake_Post_Flush_Yes, NewlibReqFutexWake_Post_Flush_NA } NewlibReqFutexWake_Post_Flush; @@ -102,7 +100,7 @@ typedef struct { /** * @brief This member contains the thread queue test context. */ - TQContext tq_ctx;; + TQContext tq_ctx; /** * @brief This member provides the futex object. @@ -147,9 +145,8 @@ static NewlibReqFutexWake_Context NewlibReqFutexWake_Instance; static const char * const NewlibReqFutexWake_PreDesc_Count[] = { - "Negative", - "Partial", - "All", + "NegativeOrZero", + "Positive", "NA" }; @@ -185,20 +182,22 @@ static Status_Control Enqueue( TQContext *tq_ctx, TQWait wait ) return STATUS_BUILD( 0, eno ); } -static void Flush( TQContext *tq_ctx ) +static uint32_t Flush( TQContext *tq_ctx, uint32_t thread_count, bool all ) { Context *ctx; int count; - int how_many; + + (void) thread_count; ctx = ToContext( tq_ctx ); - how_many = (int) ctx->tq_ctx.how_many; - count = _Futex_Wake( &ctx->futex, 1 ); - T_eq_int( count, how_many > 0 ? 1 : 0 ); + if ( all ) { + count = _Futex_Wake( &ctx->futex, INT_MAX ); + } else { + count = _Futex_Wake( &ctx->futex, 1 ); + } - count = _Futex_Wake( &ctx->futex, INT_MAX ); - T_eq_int( count, how_many > 1 ? how_many - 1 : 0 ); + return (uint32_t) count; } static void NewlibReqFutexWake_Pre_Count_Prepare( @@ -207,29 +206,17 @@ static void NewlibReqFutexWake_Pre_Count_Prepare( ) { switch ( state ) { - case NewlibReqFutexWake_Pre_Count_Negative: { + case NewlibReqFutexWake_Pre_Count_NegativeOrZero: { /* - * While the ``count`` parameter is less than zero. + * While the ``count`` parameter is less or equal to than zero. */ /* This state is prepared by Enqueue() */ break; } - case NewlibReqFutexWake_Pre_Count_Partial: { - /* - * While the ``count`` parameter is greater than or equal to zero, while - * the ``count`` parameter is less than the count of threads enqueued on - * the thread queue of the futex object. - */ - /* This state is prepared by Flush() */ - break; - } - - case NewlibReqFutexWake_Pre_Count_All: { + case NewlibReqFutexWake_Pre_Count_Positive: { /* - * While the ``count`` parameter is greater than or equal to zero, while - * the ``count`` parameter is greater than or equal to the count of - * threads enqueued on the thread queue of the futex object. + * While the ``count`` parameter is greater than zero. */ /* This state is prepared by Flush() */ break; @@ -275,21 +262,12 @@ static void NewlibReqFutexWake_Post_Flush_Check( break; } - case NewlibReqFutexWake_Post_Flush_Partial: { + case NewlibReqFutexWake_Post_Flush_Yes: { /* * The first count threads specified by the ``count`` parameter shall be * extracted from the thread queue of the futex object in FIFO order. */ - /* This state is checked by Flush() */ - break; - } - - case NewlibReqFutexWake_Post_Flush_All: { - /* - * All threads shall be extracted from the thread queue of the futex - * object in FIFO order. - */ - ScoreTqReqFlushFifo_Run( &ctx->tq_ctx ); + ScoreTqReqFlushFifo_Run( &ctx->tq_ctx, true ); break; } @@ -355,14 +333,12 @@ NewlibReqFutexWake_Entries[] = { { 0, 0, NewlibReqFutexWake_Post_Result_Count, NewlibReqFutexWake_Post_Flush_No }, { 0, 0, NewlibReqFutexWake_Post_Result_Count, - NewlibReqFutexWake_Post_Flush_Partial }, - { 0, 0, NewlibReqFutexWake_Post_Result_Count, - NewlibReqFutexWake_Post_Flush_All } + NewlibReqFutexWake_Post_Flush_Yes } }; static const uint8_t NewlibReqFutexWake_Map[] = { - 0, 1, 2 + 0, 1 }; static size_t NewlibReqFutexWake_Scope( void *arg, char *buf, size_t n ) @@ -419,7 +395,7 @@ T_TEST_CASE_FIXTURE( NewlibReqFutexWake, &NewlibReqFutexWake_Fixture ) ctx->Map.index = 0; for ( - ctx->Map.pcs[ 0 ] = NewlibReqFutexWake_Pre_Count_Negative; + ctx->Map.pcs[ 0 ] = NewlibReqFutexWake_Pre_Count_NegativeOrZero; ctx->Map.pcs[ 0 ] < NewlibReqFutexWake_Pre_Count_NA; ++ctx->Map.pcs[ 0 ] ) { |