AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Functions | Variables
alexaClientSDK::avsCommon::utils::threading::test Namespace Reference

Classes

class  ExampleFunctor
 
class  ExecutorTest
 
class  SimpleObject
 
struct  SlowDestructor
 Used by futureWaitsForTaskCleanup delay and timestamp the time of lambda parameter destruction. More...
 

Functions

 TEST_F (ExecutorTest, testTimer_submitStdFunctionAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitStdBindAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitLambdaAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitFunctionPointerAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitFunctorAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitFunctionWithPrimitiveReturnTypeNoArgsAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitFunctionWithObjectReturnTypeNoArgsAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitFunctionWithNoReturnTypePrimitiveArgsAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitFunctionWithNoReturnTypeObjectArgsAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitFunctionWithPrimitiveReturnTypeObjectArgsAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitFunctionWithObjectReturnTypePrimitiveArgsAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitFunctionWithPrimitiveReturnTypePrimitiveArgsAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitFunctionWithObjectReturnTypeObjectArgsAndVerifyExecution)
 
 TEST_F (ExecutorTest, testTimer_submitToFront)
 
 TEST_F (ExecutorTest, testTimer_executionOrderEqualToSubmitOrder)
 
 TEST_F (ExecutorTest, testTimer_futureWaitsForTaskCleanup)
 This test verifies that the executor waits to fulfill its promise until after the task is cleaned up. More...
 
 TEST_F (ExecutorTest, testTimer_shutdown)
 This test verifies that the shutdown function completes the current task and does not accept new tasks. More...
 
 TEST_F (ExecutorTest, testTimer_pushAfterExecutordownFail)
 Test that calling submit after shutdown will fail the job. More...
 
 TEST_F (ExecutorTest, testTimer_shutdownCancelJob)
 Test that shutdown cancel jobs in the queue. More...
 
 TEST_F (ExecutorTest, test_forwardPromise)
 
 TEST_F (ExecutorTest, test_taskException)
 
 TEST_F (ExecutorTest, test_executeEmptyMove)
 Verify that empty function is not accepted by executor using movable function. More...
 
 TEST_F (ExecutorTest, test_executeEmptyRef)
 Verify that empty function is not accepted by executor using const reference function. More...
 
 TEST_F (ExecutorTest, test_executeLambdaMove)
 Verify that after task execution, the lambda is released if movable function is used. More...
 
 TEST_F (ExecutorTest, test_executeLambdaRef)
 Verify that after task execution, the lambda is not released if movable function is not used. More...
 
void exampleFunction ()
 Simple example function to be referenced in Executor related tests. More...
 
void exampleFunctionParams (int param)
 Simple example function which takes a parameter to be referenced in Executor related tests. More...
 
 TEST (TaskThreadTest, test_waitForNothing)
 Test that wait will return if no job has ever started. More...
 
 TEST (TaskThreadTest, test_startFailsDueToEmptyFunction)
 Test that start will fail if function is empty. More...
 
 TEST (TaskThreadTest, test_simpleJob)
 Test that start will trigger the provided job and thread will exit once the job is done and return false. More...
 
 TEST (TaskThreadTest, test_sequenceJobs)
 
 TEST (TaskThreadTest, test_startNewJob)
 
 TEST (TaskThreadTest, testTimer_startFailDueTooManyThreads)
 Test that start will fail if called multiple times while waiting for a job to start. More...
 
 TEST (TaskThreadTest, DISABLED_test_moniker)
 Test that threads related to this task thread will always have specified moniker. More...
 
 TEST (TaskThreadTest, test_monikerDifferentObjects)
 Test that threads from different TaskThreads will have different monikers. More...
 
 TEST (TaskThreadTest, test_obtainAndreleaseWorker)
 Test that wait will return if no job has ever started. More...
 
 TEST (TaskThreadTest, test_releaseMultipleHonorsMax)
 Test that wait will return if no job has ever started. More...
 
 TEST (TaskThreadTest, test_runWorkSeveralTimes)
 
 TEST (TaskThreadTest, test_runWorkRepeatedlyAndFinish)
 
 TEST (TaskThreadTest, test_runWorkRepeatedlyAndCancelFromWorkerHappensImmediately)
 
 TEST (TaskThreadTest, test_runWorkRepeatedlyAndCancel)
 
 TEST (TaskThreadTest, test_runWorkRepeatedlyWithCancelAndInterruptByDestruction)
 

Variables

static const std::chrono::seconds EXECUTOR_SIGNAL_WAIT_TIMEOUT {30}
 Maximum timeout for blocking wait when expecting a signal. More...
 
static const int VALUE = 1234
 Simple integer value to be reused in tests. More...
 
static const std::chrono::milliseconds SHORT_TIMEOUT_MS = std::chrono::milliseconds(100)
 Timeout to use for waiting on calls within tests. More...
 
static auto TASK = [](int arg) { return arg; }
 A simple task which takes an integer argument and returns the argument when executed. More...
 
const std::chrono::milliseconds MY_WAIT_TIMEOUT {100}
 Timeout used while waiting for synchronization events. More...
 
const auto THREAD_MONIKER = "1a1"
 Default thread moniker to use in tests. More...
 
const auto THREAD_MONIKER2 = "1a2"
 Another thread moniker to use in tests. More...
 

Function Documentation

◆ exampleFunction()

void alexaClientSDK::avsCommon::utils::threading::test::exampleFunction ( )

Simple example function to be referenced in Executor related tests.

◆ exampleFunctionParams()

void alexaClientSDK::avsCommon::utils::threading::test::exampleFunctionParams ( int  param)

Simple example function which takes a parameter to be referenced in Executor related tests.

◆ TEST() [1/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_obtainAndreleaseWorker   
)

Test that wait will return if no job has ever started.

◆ TEST() [2/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_runWorkSeveralTimes   
)

◆ TEST() [3/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_waitForNothing   
)

Test that wait will return if no job has ever started.

◆ TEST() [4/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_startFailsDueToEmptyFunction   
)

Test that start will fail if function is empty.

◆ TEST() [5/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_simpleJob   
)

Test that start will trigger the provided job and thread will exit once the job is done and return false.

◆ TEST() [6/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_releaseMultipleHonorsMax   
)

Test that wait will return if no job has ever started.

◆ TEST() [7/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_runWorkRepeatedlyAndFinish   
)

◆ TEST() [8/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_sequenceJobs   
)

Test that start will trigger the provided job and it will execute the job multiple times until the job returns false.

◆ TEST() [9/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_runWorkRepeatedlyAndCancelFromWorkerHappensImmediately   
)

◆ TEST() [10/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_runWorkRepeatedlyAndCancel   
)

◆ TEST() [11/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_startNewJob   
)

Test that start will replace the existing next function.

  • First function increments the counter, while the second will decrement until it reaches 0.

◆ TEST() [12/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_runWorkRepeatedlyWithCancelAndInterruptByDestruction   
)

◆ TEST() [13/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
testTimer_startFailDueTooManyThreads   
)

Test that start will fail if called multiple times while waiting for a job to start.

◆ TEST() [14/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
DISABLED_test_moniker   
)

Test that threads related to this task thread will always have specified moniker.

◆ TEST() [15/15]

alexaClientSDK::avsCommon::utils::threading::test::TEST ( TaskThreadTest  ,
test_monikerDifferentObjects   
)

Test that threads from different TaskThreads will have different monikers.

◆ TEST_F() [1/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitStdFunctionAndVerifyExecution   
)

◆ TEST_F() [2/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitStdBindAndVerifyExecution   
)

◆ TEST_F() [3/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitLambdaAndVerifyExecution   
)

◆ TEST_F() [4/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitFunctionPointerAndVerifyExecution   
)

◆ TEST_F() [5/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitFunctorAndVerifyExecution   
)

◆ TEST_F() [6/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitFunctionWithPrimitiveReturnTypeNoArgsAndVerifyExecution   
)

◆ TEST_F() [7/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitFunctionWithObjectReturnTypeNoArgsAndVerifyExecution   
)

◆ TEST_F() [8/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitFunctionWithNoReturnTypePrimitiveArgsAndVerifyExecution   
)

◆ TEST_F() [9/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitFunctionWithNoReturnTypeObjectArgsAndVerifyExecution   
)

◆ TEST_F() [10/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitFunctionWithPrimitiveReturnTypeObjectArgsAndVerifyExecution   
)

◆ TEST_F() [11/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitFunctionWithObjectReturnTypePrimitiveArgsAndVerifyExecution   
)

◆ TEST_F() [12/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitFunctionWithPrimitiveReturnTypePrimitiveArgsAndVerifyExecution   
)

◆ TEST_F() [13/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitFunctionWithObjectReturnTypeObjectArgsAndVerifyExecution   
)

◆ TEST_F() [14/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_submitToFront   
)

◆ TEST_F() [15/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_executionOrderEqualToSubmitOrder   
)

◆ TEST_F() [16/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_futureWaitsForTaskCleanup   
)

This test verifies that the executor waits to fulfill its promise until after the task is cleaned up.

◆ TEST_F() [17/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_shutdown   
)

This test verifies that the shutdown function completes the current task and does not accept new tasks.

◆ TEST_F() [18/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_pushAfterExecutordownFail   
)

Test that calling submit after shutdown will fail the job.

◆ TEST_F() [19/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
testTimer_shutdownCancelJob   
)

Test that shutdown cancel jobs in the queue.

◆ TEST_F() [20/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
test_forwardPromise   
)

◆ TEST_F() [21/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
test_taskException   
)

◆ TEST_F() [22/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
test_executeEmptyMove   
)

Verify that empty function is not accepted by executor using movable function.

◆ TEST_F() [23/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
test_executeEmptyRef   
)

Verify that empty function is not accepted by executor using const reference function.

◆ TEST_F() [24/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
test_executeLambdaMove   
)

Verify that after task execution, the lambda is released if movable function is used.

◆ TEST_F() [25/25]

alexaClientSDK::avsCommon::utils::threading::test::TEST_F ( ExecutorTest  ,
test_executeLambdaRef   
)

Verify that after task execution, the lambda is not released if movable function is not used.

Variable Documentation

◆ EXECUTOR_SIGNAL_WAIT_TIMEOUT

const std::chrono::seconds alexaClientSDK::avsCommon::utils::threading::test::EXECUTOR_SIGNAL_WAIT_TIMEOUT {30}
static

Maximum timeout for blocking wait when expecting a signal.

◆ MY_WAIT_TIMEOUT

const std::chrono::milliseconds alexaClientSDK::avsCommon::utils::threading::test::MY_WAIT_TIMEOUT {100}

Timeout used while waiting for synchronization events.

◆ SHORT_TIMEOUT_MS

const std::chrono::milliseconds alexaClientSDK::avsCommon::utils::threading::test::SHORT_TIMEOUT_MS = std::chrono::milliseconds(100)
static

Timeout to use for waiting on calls within tests.

◆ TASK

auto alexaClientSDK::avsCommon::utils::threading::test::TASK = [](int arg) { return arg; }
static

A simple task which takes an integer argument and returns the argument when executed.

◆ THREAD_MONIKER

const auto alexaClientSDK::avsCommon::utils::threading::test::THREAD_MONIKER = "1a1"

Default thread moniker to use in tests.

◆ THREAD_MONIKER2

const auto alexaClientSDK::avsCommon::utils::threading::test::THREAD_MONIKER2 = "1a2"

Another thread moniker to use in tests.

◆ VALUE

const int alexaClientSDK::avsCommon::utils::threading::test::VALUE = 1234
static

Simple integer value to be reused in tests.

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0