mirror of
https://github.com/open62541/open62541.git
synced 2025-06-03 04:00:21 +00:00
refactor(test): Use the fake clock also for non-monotonic time-source
The subscription tests depend on a deterministic clock.
This commit is contained in:
parent
1365c3f204
commit
054420cf33
@ -89,7 +89,8 @@ START_TEST(ClientConfig_Copy){
|
||||
UA_ClientConfig srcConfig;
|
||||
memset(&srcConfig, 0, sizeof(UA_ClientConfig));
|
||||
UA_ClientConfig_setDefault(&srcConfig);
|
||||
srcConfig.eventLoop->dateTime_nowMonotonic = UA_DateTime_nowMonotonic_fake;
|
||||
srcConfig.eventLoop->dateTime_now = UA_DateTime_now_fake;
|
||||
srcConfig.eventLoop->dateTime_nowMonotonic = UA_DateTime_now_fake;
|
||||
|
||||
UA_StatusCode retval = UA_ClientConfig_copy(&srcConfig, &dstConfig);
|
||||
ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
|
||||
|
@ -192,7 +192,8 @@ registerServer(void) {
|
||||
memset(&cc, 0, sizeof(UA_ClientConfig));
|
||||
UA_ClientConfig_setDefaultEncryption(&cc, certificate, privateKey, NULL, 0, NULL, 0);
|
||||
UA_CertificateVerification_AcceptAll(&cc.certificateVerification);
|
||||
cc.eventLoop->dateTime_nowMonotonic = UA_DateTime_nowMonotonic_fake;
|
||||
cc.eventLoop->dateTime_now = UA_DateTime_now_fake;
|
||||
cc.eventLoop->dateTime_nowMonotonic = UA_DateTime_now_fake;
|
||||
|
||||
*running_register = false;
|
||||
THREAD_JOIN(server_thread_register);
|
||||
@ -222,7 +223,8 @@ unregisterServer(void) {
|
||||
memset(&cc, 0, sizeof(UA_ClientConfig));
|
||||
UA_ClientConfig_setDefaultEncryption(&cc, certificate, privateKey, NULL, 0, NULL, 0);
|
||||
UA_CertificateVerification_AcceptAll(&cc.certificateVerification);
|
||||
cc.eventLoop->dateTime_nowMonotonic = UA_DateTime_nowMonotonic_fake;
|
||||
cc.eventLoop->dateTime_now = UA_DateTime_now_fake;
|
||||
cc.eventLoop->dateTime_nowMonotonic = UA_DateTime_now_fake;
|
||||
|
||||
*running_register = false;
|
||||
THREAD_JOIN(server_thread_register);
|
||||
@ -266,7 +268,8 @@ Server_register_semaphore(void) {
|
||||
memset(&cc, 0, sizeof(UA_ClientConfig));
|
||||
UA_ClientConfig_setDefaultEncryption(&cc, certificate, privateKey, NULL, 0, NULL, 0);
|
||||
UA_CertificateVerification_AcceptAll(&cc.certificateVerification);
|
||||
cc.eventLoop->dateTime_nowMonotonic = UA_DateTime_nowMonotonic_fake;
|
||||
cc.eventLoop->dateTime_now = UA_DateTime_now_fake;
|
||||
cc.eventLoop->dateTime_nowMonotonic = UA_DateTime_now_fake;
|
||||
|
||||
*running_register = false;
|
||||
THREAD_JOIN(server_thread_register);
|
||||
|
@ -16,7 +16,8 @@ UA_Server * UA_Server_newForUnitTest(void) {
|
||||
return NULL;
|
||||
UA_ServerConfig *config = UA_Server_getConfig(server);
|
||||
/* Manually set the eventloop clock to the fake clock */
|
||||
config->eventLoop->dateTime_nowMonotonic = UA_DateTime_nowMonotonic_fake;
|
||||
config->eventLoop->dateTime_now = UA_DateTime_now_fake;
|
||||
config->eventLoop->dateTime_nowMonotonic = UA_DateTime_now_fake;
|
||||
return server;
|
||||
}
|
||||
|
||||
@ -27,7 +28,8 @@ UA_Client * UA_Client_newForUnitTest(void) {
|
||||
return NULL;
|
||||
UA_ClientConfig *config = UA_Client_getConfig(client);
|
||||
/* Manually set the eventloop clock to the fake clock */
|
||||
config->eventLoop->dateTime_nowMonotonic = UA_DateTime_nowMonotonic_fake;
|
||||
config->eventLoop->dateTime_now = UA_DateTime_now_fake;
|
||||
config->eventLoop->dateTime_nowMonotonic = UA_DateTime_now_fake;
|
||||
return client;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,6 @@ UA_realSleep(UA_UInt32 duration) {
|
||||
#endif
|
||||
}
|
||||
|
||||
UA_DateTime UA_DateTime_nowMonotonic_fake(UA_EventLoop *el) {
|
||||
UA_DateTime UA_DateTime_now_fake(UA_EventLoop *el) {
|
||||
return testingClock;
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ void UA_fakeSleep(UA_UInt32 duration);
|
||||
void UA_realSleep(UA_UInt32 duration);
|
||||
|
||||
/* To be hooked into the EventLoop for unit tests that need deterministic timings */
|
||||
UA_DateTime UA_DateTime_nowMonotonic_fake(UA_EventLoop *el);
|
||||
UA_DateTime UA_DateTime_now_fake(UA_EventLoop *el);
|
||||
|
||||
#endif /* TESTING_CLOCK_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user