fixed testing
This commit is contained in:
@@ -3,5 +3,5 @@ include_directories(../..)
|
||||
include_directories(../../../utils)
|
||||
|
||||
add_executable(test_contrib test_tem.cpp)
|
||||
target_link_libraries(test_contrib ebus ebuscontrib)
|
||||
target_link_libraries(test_contrib ebus ebuscontrib pthread)
|
||||
add_test(contrib test_contrib)
|
||||
|
||||
@@ -5,7 +5,7 @@ AM_CXXFLAGS = -I$(top_srcdir)/src \
|
||||
noinst_PROGRAMS = test_contrib
|
||||
|
||||
test_contrib_SOURCES = test_tem.cpp
|
||||
test_contrib_LDADD = ../../libebus.a ../libebuscontrib.a
|
||||
test_contrib_LDADD = ../../libebus.a ../libebuscontrib.a -lpthread
|
||||
|
||||
distclean-local:
|
||||
-rm -f Makefile.in
|
||||
|
||||
@@ -8,21 +8,21 @@ include_directories(..)
|
||||
include_directories(../../utils)
|
||||
|
||||
add_executable(test_filereader test_filereader.cpp)
|
||||
target_link_libraries(test_filereader ebus)
|
||||
target_link_libraries(test_filereader ebus pthread)
|
||||
add_test(filereader test_filereader)
|
||||
|
||||
add_executable(test_device test_device.cpp)
|
||||
target_link_libraries(test_device ebus ${test_LIBS})
|
||||
target_link_libraries(test_device ebus pthread ${test_LIBS})
|
||||
add_test(device test_device)
|
||||
|
||||
add_executable(test_symbol test_symbol.cpp)
|
||||
target_link_libraries(test_symbol ebus)
|
||||
target_link_libraries(test_symbol ebus pthread)
|
||||
add_test(symbol test_symbol)
|
||||
|
||||
add_executable(test_data test_data.cpp)
|
||||
target_link_libraries(test_data ebus ${test_LIBS})
|
||||
target_link_libraries(test_data ebus pthread ${test_LIBS})
|
||||
add_test(data test_data)
|
||||
|
||||
add_executable(test_message test_message.cpp)
|
||||
target_link_libraries(test_message ebus ${test_LIBS})
|
||||
target_link_libraries(test_message ebus pthread ${test_LIBS})
|
||||
add_test(message test_message)
|
||||
|
||||
@@ -9,19 +9,19 @@ noinst_PROGRAMS = test_filereader \
|
||||
test_message
|
||||
|
||||
test_filereader_SOURCES = test_filereader.cpp
|
||||
test_filereader_LDADD = ../libebus.a
|
||||
test_filereader_LDADD = ../libebus.a -lpthread
|
||||
|
||||
test_device_SOURCES = test_device.cpp
|
||||
test_device_LDADD = ../libebus.a
|
||||
test_device_LDADD = ../libebus.a -lpthread
|
||||
|
||||
test_symbol_SOURCES = test_symbol.cpp
|
||||
test_symbol_LDADD = ../libebus.a
|
||||
test_symbol_LDADD = ../libebus.a -lpthread
|
||||
|
||||
test_data_SOURCES = test_data.cpp
|
||||
test_data_LDADD = ../libebus.a
|
||||
test_data_LDADD = -lpthread ../libebus.a
|
||||
|
||||
test_message_SOURCES = test_message.cpp
|
||||
test_message_LDADD = ../libebus.a
|
||||
test_message_LDADD = ../libebus.a -lpthread
|
||||
|
||||
if CONTRIB
|
||||
test_device_LDADD += ../contrib/libebuscontrib.a
|
||||
|
||||
@@ -105,25 +105,4 @@ bool WaitThread::Wait(int seconds) {
|
||||
return isRunning();
|
||||
}
|
||||
|
||||
|
||||
Mutex::Mutex() {
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(&m_mutex, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
}
|
||||
|
||||
Mutex::~Mutex() {
|
||||
pthread_mutex_destroy(&m_mutex);
|
||||
}
|
||||
|
||||
void Mutex::lock() {
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
}
|
||||
|
||||
void Mutex::unlock() {
|
||||
pthread_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
+16
-4
@@ -151,22 +151,34 @@ class Mutex {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Mutex();
|
||||
inline Mutex() {
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(&m_mutex, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Mutex();
|
||||
virtual inline ~Mutex() {
|
||||
pthread_mutex_destroy(&m_mutex);
|
||||
};
|
||||
|
||||
/**
|
||||
* Lock this mutex.
|
||||
*/
|
||||
void lock();
|
||||
void inline lock() {
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock this mutex.
|
||||
*/
|
||||
void unlock();
|
||||
void inline unlock() {
|
||||
pthread_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
||||
private:
|
||||
/** the mutex for waiting. */
|
||||
|
||||
Reference in New Issue
Block a user