![]() |
AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
Classes | |
class | StopTaskTimer |
class | StopTaskTimerDelegateFactory |
class | StopwatchTest |
Test harness for Stopwatch class. More... | |
class | TimerDelegateTest |
class | TimerTest |
Test harness for Timer class. More... | |
Enumerations | |
enum | TestType { TestType::GMTIME, TestType::LOCALTIME } |
Functions | |
TEST_F (TimerDelegateTest, test_basicTimerDelegateAPI) | |
TEST_F (TimerDelegateTest, test_stopAndStartTimeDelegate) | |
Test to verify the stop and start API. More... | |
TEST_F (TimerDelegateTest, test_doubleStopTestAVS) | |
Test to verify that stopping an already stopped timer is a no-op. More... | |
TEST_F (TimerDelegateTest, test_verifyTaskWithFixedDuration) | |
TEST_F (TimerDelegateTest, test_verifyTaskWithVariableDuration) | |
TEST_F (TimerDelegateTest, test_doubleStartMustWaitForPreviousIterations) | |
TEST_F (TimerDelegateTest, test_taskWithStop) | |
TEST (MultiTimerTest, test_taskGetsCalled) | |
Test that an enqueued task gets called. More... | |
TEST (MultiTimerTest, testTimer_cancelledTaskShouldNotRun) | |
Test that an enqueued task that is cancelled before its expiration date does not run. More... | |
TEST (MultiTimerTest, test_executionOrderFollowExpirationTime) | |
TEST (MultiTimerTest, test_multipleTasksGetCalledInOrder) | |
Insert two tasks to the timer with the same delay. Expect that the tasks are run in the order they were inserted. More... | |
TEST (SafeCTimeAccessTest, test_getGmtimeNullReturnValue) | |
Test to verify that getGmtime returns failure if a nullptr is passed for the result variable. More... | |
TEST (SafeCTimeAccessTest, test_getLocaltimeNullReturnValue) | |
Test to verify that getLocaltime returns failure if a nullptr is passed for the result variable. More... | |
static void | checkTm (const std::tm &a, const std::tm &b) |
static void | testGmtimeHelper (const std::tm &expected, const time_t &t) |
static void | testLocaltimeHelper (const std::tm &expected, const time_t &t) |
TEST (SafeCTimeAccessTest, test_getGmtimeAtTheEpoch) | |
Test to verify that getGmtime returns the correct calendar date for the Unix epoch. More... | |
TEST (SafeCTimeAccessTest, test_getGmtime) | |
Test to verify that getGmtime returns the same calendar date as std::gmtime. More... | |
TEST (SafeCTimeAccessTest, test_getLocaltime) | |
Test to verify that getLocaltime returns the same calendar date as std::localtime. More... | |
static void | callSafeCTimeFunction (int startingSeed, const TestType &type, std::vector< std::pair< time_t, std::tm >> *results) |
static void | checkSafeCTimeFunction (const TestType &type) |
TEST (SafeCTimeAccessTest, DISABLED_test_gmTimeMultithreadedAccess) | |
Test to make sure that multithreaded access SafeCTimeAccess::getGmtime is safe. More... | |
TEST (SafeCTimeAccessTest, DISABLED_test_localtimeMultithreadedAccess) | |
Test to make sure that multithreaded access SafeCTimeAccess::getLocaltimetime is safe. More... | |
TEST_F (StopwatchTest, test_goodSequencing) | |
TEST_F (StopwatchTest, test_badSequencing) | |
TEST_F (StopwatchTest, testSlow_elapsed) | |
TEST_F (TimerTest, testTimer_singleShot) | |
This test runs a single-shot timer and verifies that the task is called once, at the expected time. More... | |
TEST_F (TimerTest, testTimer_multiShot) | |
TEST_F (TimerTest, testTimer_multiShotWithDelay) | |
TEST_F (TimerTest, testTimer_forever) | |
TEST_F (TimerTest, testTimer_slowTaskLessThanPeriod) | |
TEST_F (TimerTest, testTimer_slowTaskGreaterThanPeriod) | |
TEST_F (TimerTest, testTimer_slowTaskGreaterThanTwoPeriods) | |
TEST_F (TimerTest, testTimer_endToStartPeriod) | |
TEST_F (TimerTest, testTimer_stopSingleShotBeforeTask) | |
TEST_F (TimerTest, testTimer_stopSingleShotDuringTask) | |
TEST_F (TimerTest, testTimer_stopSingleShotAfterTask) | |
TEST_F (TimerTest, testTimer_stopMultiShot) | |
TEST_F (TimerTest, testTimer_startRunningBeforeTask) | |
TEST_F (TimerTest, testTimer_startRunningDuringTask) | |
TEST_F (TimerTest, testTimer_startRunningAfterTask) | |
TEST_F (TimerTest, test_deleteBeforeTask) | |
This test verifies that a timer which is deleted while active, but before running its task, does not run the task. More... | |
TEST_F (TimerTest, testTimer_deleteDuringTask) | |
This test verifies that a timer which is deleted while running a task completes the task. More... | |
TEST_F (TimerTest, testTimer_startRunningAfterStopDuringTask) | |
TEST_F (TimerTest, testTimer_multipleStopsDoesntDeadlock) | |
TEST (TimeTest, test_stringConversion) | |
TEST (TimeTest, test_iso8601StringConversion) | |
TEST (TimeTest, test_iso8601StringConversionUTC) | |
TEST (TimeTest, test_stringConversionError) | |
TEST (TimeTest, test_stringConversionNullParam) | |
TEST (TimeTest, test_timeConversion) | |
TEST (TimeTest, test_timeConversionCurrentTime) | |
TEST (TimeTest, test_currentTime) | |
TEST (TimeTest, test_currentTimeNullParam) | |
static void | testIso8601ConversionHelper (const std::string &expectedString, const std::chrono::seconds sec, const std::chrono::microseconds us) |
TEST (TimeTest, test_iso8601Conversion) | |
Variables | |
const time_t | LARGE_TIME_VALUE = (0x1 << 30) - 1 |
A bound on the upper time to check. More... | |
static std::mutex | g_resultsLock |
Mutex to guard access to the results vector. More... | |
static const std::chrono::milliseconds | TESTABLE_TIME_INCREMENT {100} |
static const auto | ACCURACY = std::chrono::milliseconds(15) |
Specifies the expected timing accuracy (timestamps must be within +/- ACCURACY of expected values). More... | |
static const auto | NO_DELAY = std::chrono::milliseconds(0) |
Used for cases where the task should return immediately, without delay. More... | |
static const auto | SHORT_DELAY = ACCURACY * 2 |
Used for cases where the task duration or timer period should be shorter than MEDIUM_DELAY and LONG_DELAY. More... | |
static const auto | MEDIUM_DELAY = SHORT_DELAY + ACCURACY |
Used for cases where the task duration or timer period should be greater than SHORT_DELAY and less than LONG_DELAY. More... | |
static const auto | LONG_DELAY = SHORT_DELAY * 2 + ACCURACY |
static const auto | TIMEOUT = std::chrono::seconds(1) |
static const size_t | ITERATIONS = 5 |
Number of task iterations to run for multi-shot tests. More... | |
|
static |
Function that accesses the safe time functions that is called from many threads. We call the function in a tight loop with no lock and save the results to be checked later.
startingSeed | This is used to make sure that different time values are checked. |
type | The flavor of testing to perform. Can be GMTIME or LOCALTIME. |
results | A vector where the results are appended to be checked later. |
|
static |
Main function for testing multithreaded access to the safe time functions. This function starts multiple threads that continuously access the time functions in an externally thread-unsafe manner. The results are collected in a single vector, where they are compared against the matching system function.
type | The flavor of testing to perform. Can be GMTIME or LOCALTIME. |
|
static |
Utility function to check to see if two std::tm objects are equal.
a | One of the structures to check. |
b | The other structure to check. |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | TimeTest | , |
test_stringConversion | |||
) |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | MultiTimerTest | , |
test_taskGetsCalled | |||
) |
Test that an enqueued task gets called.
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | SafeCTimeAccessTest | , |
test_getGmtimeNullReturnValue | |||
) |
Test to verify that getGmtime returns failure if a nullptr is passed for the result variable.
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | MultiTimerTest | , |
testTimer_cancelledTaskShouldNotRun | |||
) |
Test that an enqueued task that is cancelled before its expiration date does not run.
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | SafeCTimeAccessTest | , |
test_getLocaltimeNullReturnValue | |||
) |
Test to verify that getLocaltime returns failure if a nullptr is passed for the result variable.
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | TimeTest | , |
test_iso8601StringConversion | |||
) |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | MultiTimerTest | , |
test_executionOrderFollowExpirationTime | |||
) |
Insert two tasks to the timer where the first task has a longer wait period and the second is much shorter. Expect that the second one is run first. The first task should not run since we will exit the test before its expiration time.
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | TimeTest | , |
test_iso8601StringConversionUTC | |||
) |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | MultiTimerTest | , |
test_multipleTasksGetCalledInOrder | |||
) |
Insert two tasks to the timer with the same delay. Expect that the tasks are run in the order they were inserted.
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | SafeCTimeAccessTest | , |
test_getGmtimeAtTheEpoch | |||
) |
Test to verify that getGmtime returns the correct calendar date for the Unix epoch.
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | TimeTest | , |
test_stringConversionError | |||
) |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | TimeTest | , |
test_stringConversionNullParam | |||
) |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | SafeCTimeAccessTest | , |
test_getGmtime | |||
) |
Test to verify that getGmtime returns the same calendar date as std::gmtime.
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | TimeTest | , |
test_timeConversion | |||
) |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | SafeCTimeAccessTest | , |
test_getLocaltime | |||
) |
Test to verify that getLocaltime returns the same calendar date as std::localtime.
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | TimeTest | , |
test_timeConversionCurrentTime | |||
) |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | TimeTest | , |
test_currentTime | |||
) |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | TimeTest | , |
test_currentTimeNullParam | |||
) |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | TimeTest | , |
test_iso8601Conversion | |||
) |
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | SafeCTimeAccessTest | , |
DISABLED_test_gmTimeMultithreadedAccess | |||
) |
Test to make sure that multithreaded access SafeCTimeAccess::getGmtime is safe.
alexaClientSDK::avsCommon::utils::timing::test::TEST | ( | SafeCTimeAccessTest | , |
DISABLED_test_localtimeMultithreadedAccess | |||
) |
Test to make sure that multithreaded access SafeCTimeAccess::getLocaltimetime is safe.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | StopwatchTest | , |
test_goodSequencing | |||
) |
Test good sequencing of method calls.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | StopwatchTest | , |
test_badSequencing | |||
) |
Test bad sequencing of method calls.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerDelegateTest | , |
test_basicTimerDelegateAPI | |||
) |
Test to verify basic APIs to activate, start, and ensure that the TimerDelegate triggered the expected number of times.
Check after first task call.
Sleep until the timer completes all iterations.
Ensure timer is inactive post completion of all iterations.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerDelegateTest | , |
test_stopAndStartTimeDelegate | |||
) |
Test to verify the stop and start API.
Confirm that the timer stops immediately since the timer is not active yet (due to the delay).
Ensure timer is active once start is called.
Sleep until all iterations complete.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | StopwatchTest | , |
testSlow_elapsed | |||
) |
Test report of elapsed time. This test is timing sensitive.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerDelegateTest | , |
test_doubleStopTestAVS | |||
) |
Test to verify that stopping an already stopped timer is a no-op.
Wait until all iterations complete.
Stop the timer and confirm that the timer becomes inactive.
Verify that subsequent stop calls changes nothing.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_singleShot | |||
) |
This test runs a single-shot timer and verifies that the task is called once, at the expected time.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_multiShot | |||
) |
This test runs a multi-shot ABSOLUTE timer and verifies that the task is called the expected number of times, and that each call occurred at the expected time.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerDelegateTest | , |
test_verifyTaskWithFixedDuration | |||
) |
Test to verify timer operations with a task of fixed duration. Delay : 100ms. Period : 100ms. Task Time : 40ms. Expectation : 4 task iterations should complete after 440 ms. +-------———+---------------———+--------———+ | Iteration Time | Intermediate timepoint | Action | +================+========================+=================+ | 100 | | Start Task#1 | +-------———+---------------———+--------———+ | | 140 | End of Task#1 | +-------———+---------------———+--------———+ | 200 | | Start of Task#2 | +-------———+---------------———+--------———+ | | 240 | End of Task#2 | +-------———+---------------———+--------———+ | 300 | | Start of Task#3 | +-------———+---------------———+--------———+ | | 340 | End of Task#3 | +-------———+---------------———+--------———+ | 400 | | Start of Task#4 | +-------———+---------------———+--------———+ | | 440 | End of Task#4 | +-------———+---------------———+--------———+
Sleep until timer completes.
Confirm the task counter is as expected.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_multiShotWithDelay | |||
) |
This test runs a multi-shot ABSOLUTE timer with different initial delay and verifies that the task is called the expected number of times, and that each call occurred at the expected time.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_forever | |||
) |
This test runs a continuous ABSOLUTE timer, verifies that it remains active through several iterations, verifies that it stops when requested, and verifies that the expected number of calls occurred at their expected times.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_slowTaskLessThanPeriod | |||
) |
This test runs a slow task with an ABSOLUTE timer, but one which completes in less than a period, and verifies that the slow task does not change the number of calls or their period.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_slowTaskGreaterThanPeriod | |||
) |
This test runs a slow task with an ABSOLUTE timer which does not complete within a period, and verifies that the slow task results in skipped calls, but on a consistent period.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerDelegateTest | , |
test_verifyTaskWithVariableDuration | |||
) |
Test to verify timer operations with a task of variable duration. Delay: 100ms. Period: 100ms. Task Times: Iteration 1: 220ms. Iteration 2: 120ms. Iteration 3 (and beyond): 80ms. MaxCount: 9. Expectation of 1000 ms only 6 iterations are run and deactivated. +----------——+------------------——+------------------——+ | Iteration Time | Intermediate timepoint | Action | +================+========================+========================+ | 100 | | Start Task#1 | +----------——+------------------——+------------------——+ | 200 | | Skip | +----------——+------------------——+------------------——+ | 300 | | Skip | +----------——+------------------——+------------------——+ | | 320 | End of Task#1 | +----------——+------------------——+------------------——+ | 400 | | Start of Task#2 | +----------——+------------------——+------------------——+ | 500 | | Skip | +----------——+------------------——+------------------——+ | | 520 | End of Task#2 | +----------——+------------------——+------------------——+ | 600 | | Start of Task#3 | +----------——+------------------——+------------------——+ | | 680 | End of Task#3 | +----------——+------------------——+------------------——+ | 700 | 780 | Start and End of Task#4| +----------——+------------------——+------------------——+ | 800 | 880 | Start and End of Task#5| +----------——+------------------——+------------------——+ | 900 | 980 | Start and End of Task#6| +----------——+------------------——+------------------——+
Wait for all iterations to complete and verify the task counter.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_slowTaskGreaterThanTwoPeriods | |||
) |
This test runs a slow task with an ABSOLUTE timer which does not complete within multiple periods, and verifies that the slow task results in skipped calls, but on a consistent period.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_endToStartPeriod | |||
) |
This test runs a slow task with a RELATIVE timer which does not complete within a period, and verifies that the slow task does not result in skipped calls, but calls have a consistent between-task delay.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerDelegateTest | , |
test_doubleStartMustWaitForPreviousIterations | |||
) |
Test to verify that subsequent start API call must wait for the previous iterations to complete (when using Relative PeriodType).
Sleep for more time than the initial delay, verify the task counter.
Start again after 1 iteration. This start will wait for all iterations from previous start call to complete.
Sleep until all iterations complete.
Expected task count is 4 : 2 iterations in prev start call + 2 in later start call.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_stopSingleShotBeforeTask | |||
) |
This test verifies that a call to stop() before the task is called results in an inactive timer which does not execute the task.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_stopSingleShotDuringTask | |||
) |
This test verifies that a call to stop() while a task is executing results in an inactive timer after that task finishes executing.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerDelegateTest | , |
test_taskWithStop | |||
) |
Test to verify that if the task internally stops the timer, the timer will not run the remaining iterations.
Wait for 1 iteration to complete.
Since the task stopped the timer after the first iteration, expected task counter shall be 1.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_stopSingleShotAfterTask | |||
) |
This test verifies that a call to stop() after a task has finished executing leaves the timer inactive and unchanged.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_stopMultiShot | |||
) |
This test verifies that a call to stop() on a multi-shot timer results in an inactive timer with the expected number of calls.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_startRunningBeforeTask | |||
) |
This test verifies that a call to start() fails on a timer which is active but has not called a task yet, but does not interfere with the previously scheduled task.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_startRunningDuringTask | |||
) |
This test verifies that a call to start() fails on a timer which is currently executing a task, but does not interfere with that task.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_startRunningAfterTask | |||
) |
This test verifies that a call to start() succeeds on a timer which was previously used to run a task, but which is inactive at the time the new start() is called.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
test_deleteBeforeTask | |||
) |
This test verifies that a timer which is deleted while active, but before running its task, does not run the task.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_deleteDuringTask | |||
) |
This test verifies that a timer which is deleted while running a task completes the task.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_startRunningAfterStopDuringTask | |||
) |
This test verifies that a call to start() succeeds on a timer which was previously stopped while running a task, but which is inactive at the time the new start() is called.
alexaClientSDK::avsCommon::utils::timing::test::TEST_F | ( | TimerTest | , |
testTimer_multipleStopsDoesntDeadlock | |||
) |
This test verifies that multiple calls to stop does not result in a deadlock.
|
static |
Helper function to run through the test cases for getGmtime testing.
expected | The std::tm structure string that getGmtime should generate. |
t | The time_t to convert. |
|
static |
Helper function to run through the test cases for time to string conversions.
expectedString | The string that convertTimeToUtcIso8601Rfc3339 should generate. |
sec | The seconds since epoch to convert. |
us | The microseconds since epoch to convert. |
|
static |
Helper function to run through the test cases for getLocaltime testing.
expected | The std::tm structure string that getLocaltime should generate. |
t | The time_t to convert. |
|
static |
Specifies the expected timing accuracy (timestamps must be within +/- ACCURACY of expected values).
|
static |
Mutex to guard access to the results vector.
|
static |
Number of task iterations to run for multi-shot tests.
const time_t alexaClientSDK::avsCommon::utils::timing::test::LARGE_TIME_VALUE = (0x1 << 30) - 1 |
A bound on the upper time to check.
|
static |
Used for cases where the task duration or timer period should be greater than MEDIUM_DELAY, and greater than two SHORT_DELAYs.
|
static |
Used for cases where the task duration or timer period should be greater than SHORT_DELAY and less than LONG_DELAY.
|
static |
Used for cases where the task should return immediately, without delay.
|
static |
Used for cases where the task duration or timer period should be shorter than MEDIUM_DELAY and LONG_DELAY.
|
static |
|
static |
Used to limit the amount of time tests will wait for an operation to finish. This timeout will only be hit if a test is failing.
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0