mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-04-20 03:08:17 +00:00
update parser (#5)
This commit is contained in:
@@ -929,13 +929,13 @@ TEST(DataDispatchServiceTest, DirectRxTxSignalConcurrency)
|
||||
while (!bShutdown)
|
||||
{
|
||||
signalPubA.Write(std::rand());
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 10));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(std::rand() % 10));
|
||||
signalPubB.Write(std::rand());
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 10));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(std::rand() % 10));
|
||||
signalPubC.Write(std::rand());
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 10));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(std::rand() % 10));
|
||||
signalPubD.Write(std::rand());
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 10));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(std::rand() % 10));
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstring>
|
||||
#include "../../../global/process_watchdog.h"
|
||||
|
||||
#if defined(_WIN32) && defined(_UNICODE)
|
||||
@@ -7,8 +8,30 @@ extern "C" int wmain(int argc, wchar_t* argv[])
|
||||
extern "C" int main(int argc, char* argv[])
|
||||
#endif
|
||||
{
|
||||
CProcessWatchdog watchdog;
|
||||
// Check for the --gtest_repeat option.
|
||||
bool bRepeatEnabled = false;
|
||||
for (int iIndex = 0; iIndex < argc; iIndex++)
|
||||
{
|
||||
if (!argv[iIndex])
|
||||
continue;
|
||||
#if defined(_WIN32) && defined(_UNICODE)
|
||||
bRepeatEnabled |= std::wcsncmp(argv[iIndex], L"--gtest_repeat", 14) == 0;
|
||||
#else
|
||||
bRepeatEnabled |= std::strncmp(argv[iIndex], "--gtest_repeat", 14) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
// When repeat is enabled, do not enable the watchdog.
|
||||
if (bRepeatEnabled)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
else
|
||||
{
|
||||
CProcessWatchdog watchdog;
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1446,7 +1446,7 @@ TEST(DataDispatchServiceTest, TransactionalRxTxSignalConcurrency)
|
||||
|
||||
std::atomic_uint64_t uiValueCnt = 1000;
|
||||
|
||||
bool bShutdown = false;
|
||||
bool bShutdownPublisher = false, bShutdownConsumer = false;
|
||||
std::srand(static_cast<unsigned>(std::time(0)));
|
||||
|
||||
// Thread sync
|
||||
@@ -1471,18 +1471,18 @@ TEST(DataDispatchServiceTest, TransactionalRxTxSignalConcurrency)
|
||||
uiInitCnt++;
|
||||
std::shared_lock<std::shared_mutex> lock(mtxStart);
|
||||
|
||||
while (!bShutdown)
|
||||
while (!bShutdownPublisher)
|
||||
{
|
||||
sdv::core::CTransaction transaction = dispatch.CreateTransaction();
|
||||
uint64_t uiValue = std::rand();
|
||||
signalPubA.Write(uiValue, transaction);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 10));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(std::rand() % 10));
|
||||
signalPubB.Write(uiValue + 10, transaction);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 10));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(std::rand() % 10));
|
||||
signalPubC.Write(uiValue + 20, transaction);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 10));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(std::rand() % 10));
|
||||
signalPubD.Write(uiValue + 30, transaction);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 10));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(std::rand() % 10));
|
||||
transaction.Finish();
|
||||
}
|
||||
}
|
||||
@@ -1513,7 +1513,7 @@ TEST(DataDispatchServiceTest, TransactionalRxTxSignalConcurrency)
|
||||
uiInitCnt++;
|
||||
std::shared_lock<std::shared_mutex> lock(mtxStart);
|
||||
|
||||
while (!bShutdown)
|
||||
while (!bShutdownConsumer)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
@@ -1616,9 +1616,11 @@ TEST(DataDispatchServiceTest, TransactionalRxTxSignalConcurrency)
|
||||
|
||||
// Wait for all threads to finalize
|
||||
appcontrol.SetConfigMode();
|
||||
bShutdown = true;
|
||||
bShutdownPublisher = true;
|
||||
for (std::thread& rThread : rgPublishThreads)
|
||||
if (rThread.joinable()) rThread.join();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
bShutdownConsumer = true;
|
||||
for (std::thread& rThread : rgConsumeThreads)
|
||||
if (rThread.joinable()) rThread.join();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user