From 1dcfea82ecb4c16cade1380f23fd6f239021ebdd Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 28 Sep 2018 12:43:17 +0000 Subject: OSLIB test suite updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12305 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- test/oslib/configuration.xml | 118 +++++++++++++++++++++++ test/oslib/source/test/oslib_test_root.c | 2 +- test/oslib/source/test/oslib_test_root.h | 2 +- test/oslib/source/test/oslib_test_sequence_001.c | 2 +- test/oslib/source/test/oslib_test_sequence_001.h | 2 +- test/oslib/source/test/oslib_test_sequence_002.c | 2 +- test/oslib/source/test/oslib_test_sequence_002.h | 2 +- test/oslib/source/test/oslib_test_sequence_003.c | 2 +- test/oslib/source/test/oslib_test_sequence_003.h | 2 +- test/oslib/source/test/oslib_test_sequence_004.c | 117 +++++++++++++++++++++- test/oslib/source/test/oslib_test_sequence_004.h | 2 +- 11 files changed, 243 insertions(+), 10 deletions(-) (limited to 'test/oslib') diff --git a/test/oslib/configuration.xml b/test/oslib/configuration.xml index 11ceb09a9..7b3a6b47f 100644 --- a/test/oslib/configuration.xml +++ b/test/oslib/configuration.xml @@ -1561,6 +1561,124 @@ test_assert(dofp == NULL, "found");]]> + + + Dynamic Pipes Factory. + + + This test case verifies the dynamic pipes factory. + + + CH_CFG_FACTORY_PIPES == TRUE + + + + + + + element.refs > 0U) { + chFactoryReleasePipe(dpp); + } +}]]> + + + + + + + + + Retrieving a dynamic pipe by name, must not exist. + + + + + + + + + + + Creating a dynamic pipe it must not exists, must succeed. + + + + + + + + + + + Creating a dynamic pipe with the same name, must fail. + + + + + + + + + + + Retrieving the dynamic pipe by name, must exist, then increasing the reference counter, finally releasing both references. + + + + + + element.refs == 2, "object reference mismatch"); + +dpp2 = (dyn_pipe_t *)chFactoryDuplicateReference(&dpp1->element); +test_assert(dpp1 == dpp2, "object reference mismatch"); +test_assert(dpp2->element.refs == 3, "object reference mismatch"); + +chFactoryReleasePipe(dpp2); +test_assert(dpp1->element.refs == 2, "references mismatch"); + +chFactoryReleasePipe(dpp1); +test_assert(dpp->element.refs == 1, "references mismatch");]]> + + + + + Releasing the first reference to the dynamic pipe must not trigger an assertion. + + + + + + + + + + + Retrieving the dynamic pipe by name again, must not exist. + + + + + + + + + + diff --git a/test/oslib/source/test/oslib_test_root.c b/test/oslib/source/test/oslib_test_root.c index 2b8aae5ec..e222dcd06 100644 --- a/test/oslib/source/test/oslib_test_root.c +++ b/test/oslib/source/test/oslib_test_root.c @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/oslib/source/test/oslib_test_root.h b/test/oslib/source/test/oslib_test_root.h index 7e419375d..760ccddc8 100644 --- a/test/oslib/source/test/oslib_test_root.h +++ b/test/oslib/source/test/oslib_test_root.h @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/oslib/source/test/oslib_test_sequence_001.c b/test/oslib/source/test/oslib_test_sequence_001.c index 6f4fefc7c..74672a242 100644 --- a/test/oslib/source/test/oslib_test_sequence_001.c +++ b/test/oslib/source/test/oslib_test_sequence_001.c @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/oslib/source/test/oslib_test_sequence_001.h b/test/oslib/source/test/oslib_test_sequence_001.h index fc671846e..161c5278b 100644 --- a/test/oslib/source/test/oslib_test_sequence_001.h +++ b/test/oslib/source/test/oslib_test_sequence_001.h @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/oslib/source/test/oslib_test_sequence_002.c b/test/oslib/source/test/oslib_test_sequence_002.c index b6fa0f20e..bd661ce13 100644 --- a/test/oslib/source/test/oslib_test_sequence_002.c +++ b/test/oslib/source/test/oslib_test_sequence_002.c @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/oslib/source/test/oslib_test_sequence_002.h b/test/oslib/source/test/oslib_test_sequence_002.h index 0a3c238b3..7525db632 100644 --- a/test/oslib/source/test/oslib_test_sequence_002.h +++ b/test/oslib/source/test/oslib_test_sequence_002.h @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/oslib/source/test/oslib_test_sequence_003.c b/test/oslib/source/test/oslib_test_sequence_003.c index 0056058d1..9f623e9db 100644 --- a/test/oslib/source/test/oslib_test_sequence_003.c +++ b/test/oslib/source/test/oslib_test_sequence_003.c @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/oslib/source/test/oslib_test_sequence_003.h b/test/oslib/source/test/oslib_test_sequence_003.h index a24f0f2ea..57fc77602 100644 --- a/test/oslib/source/test/oslib_test_sequence_003.h +++ b/test/oslib/source/test/oslib_test_sequence_003.h @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/oslib/source/test/oslib_test_sequence_004.c b/test/oslib/source/test/oslib_test_sequence_004.c index 8749617fd..a053008d8 100644 --- a/test/oslib/source/test/oslib_test_sequence_004.c +++ b/test/oslib/source/test/oslib_test_sequence_004.c @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ * - @subpage oslib_test_004_003 * - @subpage oslib_test_004_004 * - @subpage oslib_test_004_005 + * - @subpage oslib_test_004_006 * . */ @@ -629,6 +630,117 @@ static const testcase_t oslib_test_004_005 = { }; #endif /* CH_CFG_FACTORY_OBJ_FIFOS == TRUE */ +#if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__) +/** + * @page oslib_test_004_006 [4.6] Dynamic Pipes Factory + * + *

Description

+ * This test case verifies the dynamic pipes factory. + * + *

Conditions

+ * This test is only executed if the following preprocessor condition + * evaluates to true: + * - CH_CFG_FACTORY_PIPES == TRUE + * . + * + *

Test Steps

+ * - [4.6.1] Retrieving a dynamic pipe by name, must not exist. + * - [4.6.2] Creating a dynamic pipe it must not exists, must succeed. + * - [4.6.3] Creating a dynamic pipe with the same name, must fail. + * - [4.6.4] Retrieving the dynamic pipe by name, must exist, then + * increasing the reference counter, finally releasing both + * references. + * - [4.6.5] Releasing the first reference to the dynamic pipe must not + * trigger an assertion. + * - [4.6.6] Retrieving the dynamic pipe by name again, must not exist. + * . + */ + +static void oslib_test_004_006_teardown(void) { + dyn_pipe_t *dpp; + + dpp = chFactoryFindPipe("mypipe"); + if (dpp != NULL) { + while (dpp->element.refs > 0U) { + chFactoryReleasePipe(dpp); + } + } +} + +static void oslib_test_004_006_execute(void) { + dyn_pipe_t *dpp; + + /* [4.6.1] Retrieving a dynamic pipe by name, must not exist.*/ + test_set_step(1); + { + dpp = chFactoryFindPipe("mypipe"); + test_assert(dpp == NULL, "found"); + } + + /* [4.6.2] Creating a dynamic pipe it must not exists, must + succeed.*/ + test_set_step(2); + { + dpp = chFactoryCreatePipe("mypipe", 16U); + test_assert(dpp != NULL, "cannot create"); + } + + /* [4.6.3] Creating a dynamic pipe with the same name, must fail.*/ + test_set_step(3); + { + dyn_pipe_t *dpp1; + + dpp1 = chFactoryCreatePipe("mypipe", 16U); + test_assert(dpp1 == NULL, "can create"); + } + + /* [4.6.4] Retrieving the dynamic pipe by name, must exist, then + increasing the reference counter, finally releasing both + references.*/ + test_set_step(4); + { + dyn_pipe_t *dpp1, *dpp2; + + dpp1 = chFactoryFindPipe("mypipe"); + test_assert(dpp1 != NULL, "not found"); + test_assert(dpp == dpp1, "object reference mismatch"); + test_assert(dpp1->element.refs == 2, "object reference mismatch"); + + dpp2 = (dyn_pipe_t *)chFactoryDuplicateReference(&dpp1->element); + test_assert(dpp1 == dpp2, "object reference mismatch"); + test_assert(dpp2->element.refs == 3, "object reference mismatch"); + + chFactoryReleasePipe(dpp2); + test_assert(dpp1->element.refs == 2, "references mismatch"); + + chFactoryReleasePipe(dpp1); + test_assert(dpp->element.refs == 1, "references mismatch"); + } + + /* [4.6.5] Releasing the first reference to the dynamic pipe must not + trigger an assertion.*/ + test_set_step(5); + { + chFactoryReleasePipe(dpp); + } + + /* [4.6.6] Retrieving the dynamic pipe by name again, must not + exist.*/ + test_set_step(6); + { + dpp = chFactoryFindPipe("mypipe"); + test_assert(dpp == NULL, "found"); + } +} + +static const testcase_t oslib_test_004_006 = { + "Dynamic Pipes Factory", + NULL, + oslib_test_004_006_teardown, + oslib_test_004_006_execute +}; +#endif /* CH_CFG_FACTORY_PIPES == TRUE */ + /**************************************************************************** * Exported data. ****************************************************************************/ @@ -651,6 +763,9 @@ const testcase_t * const oslib_test_sequence_004_array[] = { #endif #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__) &oslib_test_004_005, +#endif +#if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__) + &oslib_test_004_006, #endif NULL }; diff --git a/test/oslib/source/test/oslib_test_sequence_004.h b/test/oslib/source/test/oslib_test_sequence_004.h index 48be4123e..c301863f2 100644 --- a/test/oslib/source/test/oslib_test_sequence_004.h +++ b/test/oslib/source/test/oslib_test_sequence_004.h @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. -- cgit v1.2.3