aboutsummaryrefslogtreecommitdiffstats
path: root/test/nil/source
diff options
context:
space:
mode:
Diffstat (limited to 'test/nil/source')
-rw-r--r--test/nil/source/test/test_root.c64
-rw-r--r--test/nil/source/test/test_root.h14
-rw-r--r--test/nil/source/test/test_sequence_001.c2
-rw-r--r--test/nil/source/test/test_sequence_001.h2
-rw-r--r--test/nil/source/test/test_sequence_002.c6
-rw-r--r--test/nil/source/test/test_sequence_002.h2
-rw-r--r--test/nil/source/test/test_sequence_003.c2
-rw-r--r--test/nil/source/test/test_sequence_003.h2
-rw-r--r--test/nil/source/test/test_sequence_004.c10
-rw-r--r--test/nil/source/test/test_sequence_004.h2
-rw-r--r--test/nil/source/test/test_sequence_005.c137
-rw-r--r--test/nil/source/test/test_sequence_005.h2
12 files changed, 177 insertions, 68 deletions
diff --git a/test/nil/source/test/test_root.c b/test/nil/source/test/test_root.c
index f261965cb..1516898c5 100644
--- a/test/nil/source/test/test_root.c
+++ b/test/nil/source/test/test_root.c
@@ -61,38 +61,38 @@ const testcase_t * const *test_suite[] = {
/* Shared code. */
/*===========================================================================*/
-semaphore_t gsem1, gsem2;
-thread_reference_t gtr1;
-
-/*
- * Support thread.
- */
-THD_WORKING_AREA(wa_test_support, 128);
-THD_FUNCTION(test_support, arg) {
-#if CH_CFG_USE_EVENTS == TRUE
- thread_t *tp = (thread_t *)arg;
-#else
- (void)arg;
-#endif
-
- /* Initializing global resources.*/
- chSemObjectInit(&gsem1, 0);
- chSemObjectInit(&gsem2, 0);
-
- while (true) {
- chSysLock();
- if (chSemGetCounterI(&gsem1) < 0)
- chSemSignalI(&gsem1);
- chSemResetI(&gsem2, 0);
- chThdResumeI(&gtr1, MSG_OK);
-#if CH_CFG_USE_EVENTS == TRUE
- chEvtSignalI(tp, 0x55);
-#endif
- chSchRescheduleS();
- chSysUnlock();
-
- chThdSleepMilliseconds(250);
- }
+semaphore_t gsem1, gsem2;
+thread_reference_t gtr1;
+
+/*
+ * Support thread.
+ */
+THD_WORKING_AREA(wa_test_support, 128);
+THD_FUNCTION(test_support, arg) {
+#if CH_CFG_USE_EVENTS == TRUE
+ thread_t *tp = (thread_t *)arg;
+#else
+ (void)arg;
+#endif
+
+ /* Initializing global resources.*/
+ chSemObjectInit(&gsem1, 0);
+ chSemObjectInit(&gsem2, 0);
+
+ while (true) {
+ chSysLock();
+ if (chSemGetCounterI(&gsem1) < 0)
+ chSemSignalI(&gsem1);
+ chSemResetI(&gsem2, 0);
+ chThdResumeI(&gtr1, MSG_OK);
+#if CH_CFG_USE_EVENTS == TRUE
+ chEvtSignalI(tp, 0x55);
+#endif
+ chSchRescheduleS();
+ chSysUnlock();
+
+ chThdSleepMilliseconds(250);
+ }
}
/** @} */
diff --git a/test/nil/source/test/test_root.h b/test/nil/source/test/test_root.h
index ce6d8d457..ee0c42d0b 100644
--- a/test/nil/source/test/test_root.h
+++ b/test/nil/source/test/test_root.h
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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.
@@ -48,12 +48,12 @@ extern "C" {
/* Shared definitions. */
/*===========================================================================*/
-#define TEST_SUITE_NAME "ChibiOS/NIL Test Suite"
-
-extern semaphore_t gsem1, gsem2;
-extern thread_reference_t gtr1;
-extern THD_WORKING_AREA(wa_test_support, 128);
-
+#define TEST_SUITE_NAME "ChibiOS/NIL Test Suite"
+
+extern semaphore_t gsem1, gsem2;
+extern thread_reference_t gtr1;
+extern THD_WORKING_AREA(wa_test_support, 128);
+
THD_FUNCTION(test_support, arg);
#endif /* _SPC5_TEST_ROOT_H_ */
diff --git a/test/nil/source/test/test_sequence_001.c b/test/nil/source/test/test_sequence_001.c
index 858930775..4be1c4785 100644
--- a/test/nil/source/test/test_sequence_001.c
+++ b/test/nil/source/test/test_sequence_001.c
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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/nil/source/test/test_sequence_001.h b/test/nil/source/test/test_sequence_001.h
index 9ba5dc4be..83ef96518 100644
--- a/test/nil/source/test/test_sequence_001.h
+++ b/test/nil/source/test/test_sequence_001.h
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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/nil/source/test/test_sequence_002.c b/test/nil/source/test/test_sequence_002.c
index 946b6d05e..bd626683b 100644
--- a/test/nil/source/test/test_sequence_002.c
+++ b/test/nil/source/test/test_sequence_002.c
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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.
@@ -38,8 +38,8 @@
* Shared code.
****************************************************************************/
-#include "ch.h"
-
+#include "ch.h"
+
static semaphore_t sem1;
/****************************************************************************
diff --git a/test/nil/source/test/test_sequence_002.h b/test/nil/source/test/test_sequence_002.h
index b408f96f4..bd7b6c764 100644
--- a/test/nil/source/test/test_sequence_002.h
+++ b/test/nil/source/test/test_sequence_002.h
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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/nil/source/test/test_sequence_003.c b/test/nil/source/test/test_sequence_003.c
index e0ae074e8..b58bd3b69 100644
--- a/test/nil/source/test/test_sequence_003.c
+++ b/test/nil/source/test/test_sequence_003.c
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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/nil/source/test/test_sequence_003.h b/test/nil/source/test/test_sequence_003.h
index ca7045528..587acc5de 100644
--- a/test/nil/source/test/test_sequence_003.h
+++ b/test/nil/source/test/test_sequence_003.h
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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/nil/source/test/test_sequence_004.c b/test/nil/source/test/test_sequence_004.c
index 4cddf5fe4..6cf37b289 100644
--- a/test/nil/source/test/test_sequence_004.c
+++ b/test/nil/source/test/test_sequence_004.c
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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.
@@ -38,10 +38,10 @@
* Shared code.
****************************************************************************/
-#define ALLOWED_DELAY MS2ST(5)
-#define MB_SIZE 4
-
-static msg_t mb_buffer[MB_SIZE];
+#define ALLOWED_DELAY MS2ST(5)
+#define MB_SIZE 4
+
+static msg_t mb_buffer[MB_SIZE];
static MAILBOX_DECL(mb1, mb_buffer, MB_SIZE);
/****************************************************************************
diff --git a/test/nil/source/test/test_sequence_004.h b/test/nil/source/test/test_sequence_004.h
index 4e0e48f6a..3ecaa4259 100644
--- a/test/nil/source/test/test_sequence_004.h
+++ b/test/nil/source/test/test_sequence_004.h
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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/nil/source/test/test_sequence_005.c b/test/nil/source/test/test_sequence_005.c
index 9d14cfdb6..fa3fc8eab 100644
--- a/test/nil/source/test/test_sequence_005.c
+++ b/test/nil/source/test/test_sequence_005.c
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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.
@@ -29,6 +29,8 @@
*
* <h2>Test Cases</h2>
* - @subpage test_005_001
+ * - @subpage test_005_002
+ * - @subpage test_005_003
* .
*/
@@ -36,17 +38,18 @@
* Shared code.
****************************************************************************/
-#define MEMORY_POOL_SIZE 4
-
-static uint32_t objects[MEMORY_POOL_SIZE];
-static MEMORYPOOL_DECL(mp1, sizeof (uint32_t), NULL);
-
-static void *null_provider(size_t size, unsigned align) {
-
- (void)size;
- (void)align;
-
- return NULL;
+#define MEMORY_POOL_SIZE 4
+
+static uint32_t objects[MEMORY_POOL_SIZE];
+static MEMORYPOOL_DECL(mp1, sizeof (uint32_t), NULL);
+static GUARDEDMEMORYPOOL_DECL(gmp1, sizeof (uint32_t));
+
+static void *null_provider(size_t size, unsigned align) {
+
+ (void)size;
+ (void)align;
+
+ return NULL;
}
/****************************************************************************
@@ -54,7 +57,7 @@ static void *null_provider(size_t size, unsigned align) {
****************************************************************************/
/**
- * @page test_005_001 Loading and empting the memory pool
+ * @page test_005_001 Loading and empting a memory pool
*
* <h2>Description</h2>
* The memory pool functionality is tested by loading and empting it,
@@ -128,12 +131,116 @@ static void test_005_001_execute(void) {
}
static const testcase_t test_005_001 = {
- "Loading and empting the memory pool",
+ "Loading and empting a memory pool",
test_005_001_setup,
NULL,
test_005_001_execute
};
+/**
+ * @page test_005_002 Loading and empting a guarded memory pool without waiting
+ *
+ * <h2>Description</h2>
+ * The memory pool functionality is tested by loading and empting it,
+ * all conditions are tested.
+ *
+ * <h2>Test Steps</h2>
+ * - Adding the objects to the pool using chGuardedPoolLoadArray().
+ * - Emptying the pool using chGuardedPoolAllocTimeout().
+ * - Now must be empty.
+ * - Adding the objects to the pool using chGuardedPoolFree().
+ * - Emptying the pool using chGuardedPoolAllocTimeout() again.
+ * - Now must be empty again.
+ * .
+ */
+
+static void test_005_002_setup(void) {
+ chGuardedPoolObjectInit(&gmp1, sizeof (uint32_t));
+}
+
+static void test_005_002_execute(void) {
+ unsigned i;
+
+ /* Adding the objects to the pool using chGuardedPoolLoadArray().*/
+ test_set_step(1);
+ {
+ chGuardedPoolLoadArray(&gmp1, objects, MEMORY_POOL_SIZE);
+ }
+
+ /* Emptying the pool using chGuardedPoolAllocTimeout().*/
+ test_set_step(2);
+ {
+ for (i = 0; i < MEMORY_POOL_SIZE; i++)
+ test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty");
+ }
+
+ /* Now must be empty.*/
+ test_set_step(3);
+ {
+ test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");
+ }
+
+ /* Adding the objects to the pool using chGuardedPoolFree().*/
+ test_set_step(4);
+ {
+ for (i = 0; i < MEMORY_POOL_SIZE; i++)
+ chGuardedPoolFree(&gmp1, &objects[i]);
+ }
+
+ /* Emptying the pool using chGuardedPoolAllocTimeout() again.*/
+ test_set_step(5);
+ {
+ for (i = 0; i < MEMORY_POOL_SIZE; i++)
+ test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty");
+ }
+
+ /* Now must be empty again.*/
+ test_set_step(6);
+ {
+ test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");
+ }
+}
+
+static const testcase_t test_005_002 = {
+ "Loading and empting a guarded memory pool without waiting",
+ test_005_002_setup,
+ NULL,
+ test_005_002_execute
+};
+
+/**
+ * @page test_005_003 Guarded Memory Pools timeout
+ *
+ * <h2>Description</h2>
+ * The timeout features for the Guarded Memory Pools is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - Trying to allocate with 100mS timeout, must fail because the pool
+ * is empty.
+ * .
+ */
+
+static void test_005_003_setup(void) {
+ chGuardedPoolObjectInit(&gmp1, sizeof (uint32_t));
+}
+
+static void test_005_003_execute(void) {
+
+ /* Trying to allocate with 100mS timeout, must fail because the pool
+ is empty.*/
+ test_set_step(1);
+ {
+ test_assert(chGuardedPoolAllocTimeout(&gmp1, MS2ST(100)) == NULL, "list not empty");
+ }
+}
+
+static const testcase_t test_005_003 = {
+ "Guarded Memory Pools timeout",
+ test_005_003_setup,
+ NULL,
+ test_005_003_execute
+};
+
/****************************************************************************
* Exported data.
****************************************************************************/
@@ -143,5 +250,7 @@ static const testcase_t test_005_001 = {
*/
const testcase_t * const test_sequence_005[] = {
&test_005_001,
+ &test_005_002,
+ &test_005_003,
NULL
};
diff --git a/test/nil/source/test/test_sequence_005.h b/test/nil/source/test/test_sequence_005.h
index a6d54f033..4cb8e1db0 100644
--- a/test/nil/source/test/test_sequence_005.h
+++ b/test/nil/source/test/test_sequence_005.h
@@ -1,5 +1,5 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2015 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.