AWS IoT Device SDK C: Task Pool
Task pool library
Return to main page ↑
iot_tests_taskpool.c File Reference

Tests for task pool. More...

#include "iot_config.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "iot_init.h"
#include "platform/iot_threads.h"
#include "platform/iot_clock.h"
#include "private/iot_taskpool_internal.h"
#include "iot_taskpool.h"
#include "unity_fixture.h"

Data Structures

struct  JobUserContext_t
 A simple user context to prove all callbacks are called. More...
 
struct  JobBlockingUserContext_t
 A simple user context to prove the taskpool grows as expected. More...
 

Macros

#define IOT_TASKPOOL_TEST_JOB_CONTEXT_INITIALIZER   { .counter = 0 };
 The initializer for the user context.
 
#define TEST_TASKPOOL_ITERATIONS   ( 200 )
 Number of iterations for each test loop.
 
#define TEST_TASKPOOL_WORK_ITEM_DURATION_MAX   ( 55 )
 Define the stress job max duration time (emulated duration).
 
#define TEST_TASKPOOL_LONG_JOBS_NUMBER   3
 Define the number of long running jobs.
 
#define TEST_TASKPOOL_NUMBER_OF_JOBS   4
 Define the number of running jobs to grow the taskpool for.
 
#define TEST_TASKPOOL_NUMBER_OF_THREADS   ( TEST_TASKPOOL_NUMBER_OF_JOBS - 1 )
 Define the number of threads to grow the taskpool to.
 
#define TEST_TASKPOOL_MAX_THREADS   7
 Define the number of threads to grow the taskpool to.
 
#define ONE_HOUR_FROM_NOW_MS   ( 3600 * 1000 )
 Define the number of long running jobs. More...
 
#define LEGAL_INFOS   3
 Number of legal task pool initialization configurations.
 
#define ILLEGAL_INFOS   3
 Number of illegal task pool initialization configurations.
 

Functions

 TEST_GROUP (Common_Unit_Task_Pool)
 Test group for task pool tests.
 
 TEST_SETUP (Common_Unit_Task_Pool)
 Test setup for task pool tests.
 
 TEST_TEAR_DOWN (Common_Unit_Task_Pool)
 Test tear down for task pool tests.
 
 TEST_GROUP_RUNNER (Common_Unit_Task_Pool)
 Test group runner for task pool.
 
static void EmulateWork ()
 A function that emulates some work in the task pool execution by sleeping.
 
static void EmulateWorkLong ()
 A function that emulates some work in the task pool execution by sleeping.
 
static void ExecutionWithoutDestroyCb (IotTaskPool_t pTaskPool, IotTaskPoolJob_t pJob, void *pContext)
 A callback that does not recycle its job.
 
static void ExecutionBlockingWithoutDestroyCb (IotTaskPool_t pTaskPool, IotTaskPoolJob_t pJob, void *pContext)
 A callback that blocks.
 
static void ExecutionWithRecycleCb (IotTaskPool_t pTaskPool, IotTaskPoolJob_t pJob, void *pContext)
 A callback that recycles its job.
 
static void ExecutionLongWithoutDestroyCb (IotTaskPool_t pTaskPool, IotTaskPoolJob_t pJob, void *pContext)
 A callback that takes a long time and does not recycle its job.
 
static void BlankExecution (IotTaskPool_t pTaskPool, IotTaskPoolJob_t pJob, void *pContext)
 A callback that does not recycle its job.
 
void TEST_Common_Unit_Task_Pool_Error_ (void)
 Test retrieving error string for each task pool status error.
 
void TEST_Common_Unit_Task_Pool_CreateDestroyMaxThreads_ (void)
 Test task pool dynamic memory creation and destruction, with both legal and illegal information.
 
void TEST_Common_Unit_Task_Pool_CreateDestroyJobError_ (void)
 Test task pool job static and dynamic memory creation with bogus parameters.
 
void TEST_Common_Unit_Task_Pool_CreateDestroyRecycleRecyclableJobError_ (void)
 Test task pool job static and dynamic memory creation with bogus parameters.
 
void TEST_Common_Unit_Task_Pool_CreateRecyclableJob_ (void)
 Test task pool job static and dynamic memory creation with bogus parameters.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasksError_ (void)
 Test scheduling a job with bad parameters.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_LongRunningAndCachedJobsAndDestroy_ (void)
 Test scheduling a set of jobs: static allocation, bulk execution.
 
void TEST_Common_Unit_Task_Pool_TaskPool_ScheduleRecyclableTasksError_ (void)
 Test scheduling a job with bad parameters.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_Grow_ (void)
 Tests that the taskpool actually grows the number of tasks as expected.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_GrowHighPri_ (void)
 Test scheduling a set of non-recyclable jobs: static allocation, sequential execution.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_ScheduleOneThenWait_ (void)
 Test scheduling a set of non-recyclable jobs: static allocation, sequential execution.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_ScheduleOneDeferredThenWait_ (void)
 Test scheduling a set of non-recyclable jobs: static allocation, sequential execution.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_ScheduleOneRecyclableThenWait_ (void)
 Test scheduling a set of recyclable jobs: dynamic allocation, sequential execution.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_ScheduleAllThenWait_ (void)
 Test scheduling a set of jobs: static allocation, bulk execution.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_ScheduleAllRecyclableThenWait_ (void)
 Test scheduling a set of jobs: static allocation, bulk execution.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_ScheduleAllDeferredRecyclableThenWait_ (void)
 Test scheduling a set of deferred jobs.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_ReSchedule_ (void)
 Test scheduling and re-scheduling (without canceling first) a set of jobs.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_ReScheduleDeferred_ (void)
 Test scheduling and re-scheduling (without canceling first) a set of deferred jobs.
 
void TEST_Common_Unit_Task_Pool_ScheduleTasks_CancelTasks_ (void)
 Test scheduling and canceling jobs.
 

Variables

static IotTaskPoolInfo_t tpInfoLegal [LEGAL_INFOS]
 Legal initialization configurations. More...
 
static IotTaskPoolInfo_t tpInfoIllegal [ILLEGAL_INFOS]
 Illegal initialization configurations. More...
 

Detailed Description

Tests for task pool.

Macro Definition Documentation

◆ ONE_HOUR_FROM_NOW_MS

#define ONE_HOUR_FROM_NOW_MS   ( 3600 * 1000 )

Define the number of long running jobs.

Define the number of running jobs to grow the taskpool for. Define the number of threads to grow the taskpool to. Define the number of threads to grow the taskpool to. One hour in milliseconds.

Variable Documentation

◆ tpInfoLegal

IotTaskPoolInfo_t tpInfoLegal[LEGAL_INFOS]
static
Initial value:
=
{
{ .minThreads = 1, .maxThreads = 1, .stackSize = IOT_THREAD_DEFAULT_STACK_SIZE, .priority = IOT_THREAD_DEFAULT_PRIORITY },
{ .minThreads = 1, .maxThreads = 2, .stackSize = IOT_THREAD_DEFAULT_STACK_SIZE, .priority = IOT_THREAD_DEFAULT_PRIORITY },
{ .minThreads = 2, .maxThreads = 3, .stackSize = IOT_THREAD_DEFAULT_STACK_SIZE, .priority = IOT_THREAD_DEFAULT_PRIORITY }
}
#define IOT_THREAD_DEFAULT_PRIORITY
#define IOT_THREAD_DEFAULT_STACK_SIZE

Legal initialization configurations.

◆ tpInfoIllegal

IotTaskPoolInfo_t tpInfoIllegal[ILLEGAL_INFOS]
static
Initial value:
=
{
{ .minThreads = 0, .maxThreads = 1, .stackSize = IOT_THREAD_DEFAULT_STACK_SIZE, .priority = IOT_THREAD_DEFAULT_PRIORITY },
{ .minThreads = 1, .maxThreads = 0, .stackSize = IOT_THREAD_DEFAULT_STACK_SIZE, .priority = IOT_THREAD_DEFAULT_PRIORITY },
{ .minThreads = 2, .maxThreads = 1, .stackSize = IOT_THREAD_DEFAULT_STACK_SIZE, .priority = IOT_THREAD_DEFAULT_PRIORITY }
}
#define IOT_THREAD_DEFAULT_PRIORITY
#define IOT_THREAD_DEFAULT_STACK_SIZE

Illegal initialization configurations.