Browse Source

Add CarlaMutex test, valgrind has issues with pthread_mutex_trylock

tags/1.9.4
falkTX 10 years ago
parent
commit
ff205c473f
2 changed files with 50 additions and 0 deletions
  1. +46
    -0
      source/tests/CarlaMutex.cpp
  2. +4
    -0
      source/tests/Makefile

+ 46
- 0
source/tests/CarlaMutex.cpp View File

@@ -0,0 +1,46 @@
/*
* CarlaMutex Test
*/

#include <pthread.h>

class CarlaMutex
{
public:
CarlaMutex()
{
pthread_mutex_init(&fMutex, NULL);
}

~CarlaMutex()
{
pthread_mutex_destroy(&fMutex);
}

void lock()
{
pthread_mutex_lock(&fMutex);
}

bool tryLock()
{
return (pthread_mutex_trylock(&fMutex) == 0);
}

void unlock()
{
pthread_mutex_unlock(&fMutex);
}

private:
pthread_mutex_t fMutex;
};

int main()
{
CarlaMutex m;
m.tryLock();
m.unlock();

return 0;
}

+ 4
- 0
source/tests/Makefile View File

@@ -58,6 +58,10 @@ ChildProcess: ChildProcess.cpp
$(CXX) $< $(PEDANTIC_CXX_FLAGS) ../modules/juce_core.a -ldl -lpthread -lrt -o $@
# valgrind --leak-check=full ./$@

CarlaMutex: CarlaMutex.cpp ../utils/CarlaMutex.hpp
$(CXX) $< -lpthread -o $@
valgrind --leak-check=full ./$@

CarlaString: CarlaString.cpp ../utils/CarlaString.hpp
$(CXX) $< $(PEDANTIC_CXX_FLAGS) -o $@
valgrind --leak-check=full ./$@


Loading…
Cancel
Save