summaryrefslogtreecommitdiff
path: root/AudioManagerUtilities/test/AmSocketHandlerTest/CAmSocketHandlerTest.h
diff options
context:
space:
mode:
authorJens Lorenz <jlorenz@de.adit-jv.com>2018-04-04 09:47:25 +0200
committerJens Lorenz <jlorenz@de.adit-jv.com>2018-04-09 17:00:47 +0200
commit29b816429d141584af128256545ca0dc96ce0be3 (patch)
tree1a92719a70418f91284174eb0c079018c65c8bfa /AudioManagerUtilities/test/AmSocketHandlerTest/CAmSocketHandlerTest.h
parente9240071f34ae96f72f4befd19f6fa68cc721ad1 (diff)
downloadaudiomanager-29b816429d141584af128256545ca0dc96ce0be3.tar.gz
AMUtil: Rework of socketHandler to avoid calls of invalidated objects
This patch tries to follow the idea raised in PR26. Following two patches have been reworked: commit: cfe0e77aaf87a0590ceea42f6afa62b0c7d95e80 commit: bc33226f59910a960f62d419ba10d4ea761e3724 The biggest change applies to the internal database. Instead of having a vector for all items which will be copied inside the worker thread the new approach aims a central map which allows to store the sh_poll elements in containers. By this a container is valid until it is remove from map. The remove of items inside a map is now centralized within the worker and only the worker is responsible to keep the ppoll list and the map in sync. This patch also extends the unit tests to stress different timer scenarios. Signed-off-by: Aleksandar Donchev <Aleksander.Donchev@partner.bmw.de> Signed-off-by: Jens Lorenz <jlorenz@de.adit-jv.com>
Diffstat (limited to 'AudioManagerUtilities/test/AmSocketHandlerTest/CAmSocketHandlerTest.h')
-rw-r--r--AudioManagerUtilities/test/AmSocketHandlerTest/CAmSocketHandlerTest.h70
1 files changed, 61 insertions, 9 deletions
diff --git a/AudioManagerUtilities/test/AmSocketHandlerTest/CAmSocketHandlerTest.h b/AudioManagerUtilities/test/AmSocketHandlerTest/CAmSocketHandlerTest.h
index a274605..93620b5 100644
--- a/AudioManagerUtilities/test/AmSocketHandlerTest/CAmSocketHandlerTest.h
+++ b/AudioManagerUtilities/test/AmSocketHandlerTest/CAmSocketHandlerTest.h
@@ -101,23 +101,21 @@ namespace am
UNIX, INET
};
CAmSamplePlugin(CAmSocketHandler *mySocketHandler, sockType_e socketType);
- ~CAmSamplePlugin()
- {
- }
- ;
+ virtual ~CAmSamplePlugin() { }
void connectSocket(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
- void receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
- bool dispatchData(const sh_pollHandle_t handle, void* userData);
- bool check(const sh_pollHandle_t handle, void* userData);
+ virtual void receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
+ virtual bool dispatchData(const sh_pollHandle_t handle, void* userData);
+ virtual bool check(const sh_pollHandle_t handle, void* userData);
TAmShPollFired<CAmSamplePlugin> connectFiredCB;
TAmShPollFired<CAmSamplePlugin> receiveFiredCB;
TAmShPollDispatch<CAmSamplePlugin> sampleDispatchCB;
TAmShPollCheck<CAmSamplePlugin> sampleCheckCB;
-
- private:
+ bool isSocketOpened() { return mSocket>-1; }
+ protected:
CAmSocketHandler *mSocketHandler;
sh_pollHandle_t mConnecthandle, mReceiveHandle;
std::queue<std::string> msgList;
+ int mSocket;
};
class CAmTimerSockethandlerController: public MockIAmTimerCb
@@ -162,6 +160,46 @@ namespace am
TAmShTimerCallBack<CAmTimer> pTimerCallback;
};
+ class CAmTimerStressTest: public MockIAmTimerCb
+ {
+ CAmSocketHandler *mpSocketHandler;
+ timespec mUpdateTimeout;
+ int32_t mRepeats;
+ int32_t mHandle;
+ public:
+ explicit CAmTimerStressTest(CAmSocketHandler *SocketHandler, const timespec &timeout, const int32_t repeats = 0u);
+ virtual ~CAmTimerStressTest();
+
+ int32_t getHandle() { return mHandle; }
+ void setHandle(const int32_t id) { mHandle=id; }
+
+ timespec getUpdateTimeout( ) { return mUpdateTimeout; }
+
+ void timerCallback(sh_timerHandle_t handle, void * userData);
+
+ TAmShTimerCallBack<CAmTimerStressTest> pTimerCallback;
+ };
+
+ class CAmTimerStressTest2: public MockIAmTimerCb
+ {
+ CAmSocketHandler *mpSocketHandler;
+ timespec mUpdateTimeout;
+ int32_t mRepeats;
+ int32_t mHandle;
+ public:
+ explicit CAmTimerStressTest2(CAmSocketHandler *SocketHandler, const timespec &timeout, const int32_t repeats = 0u);
+ virtual ~CAmTimerStressTest2();
+
+ int32_t getHandle() { return mHandle; }
+ void setHandle(const int32_t id) { mHandle=id; }
+
+ timespec getUpdateTimeout( ) { return mUpdateTimeout; }
+
+ void timerCallback(sh_timerHandle_t handle, void * userData);
+
+ TAmShTimerCallBack<CAmTimerStressTest2> pTimerCallback;
+ };
+
class CAmTimerMeasurment: public MockIAmTimerCb
{
CAmSocketHandler *mSocketHandler;
@@ -189,5 +227,19 @@ namespace am
void TearDown();
};
+ class CAmSamplePluginStressTest: public CAmSamplePlugin
+ {
+ std::vector<CAmTimerStressTest2*> mTimers;
+ public:
+ CAmSamplePluginStressTest(CAmSocketHandler *mySocketHandler, sockType_e socketType);
+ virtual ~CAmSamplePluginStressTest();
+
+ void receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void* userData) final;
+ bool dispatchData(const sh_pollHandle_t handle, void* userData) final;
+ bool check(const sh_pollHandle_t handle, void* userData) final;
+
+ std::vector<CAmTimerStressTest2*> & getTimers() { return mTimers; }
+ };
+
} /* namespace am */
#endif /* SOCKETHANDLERTEST_H_ */