diff options
Diffstat (limited to 'libs/pbd/test')
-rw-r--r-- | libs/pbd/test/filesystem_test.cc | 2 | ||||
-rw-r--r-- | libs/pbd/test/mutex_test.cc | 24 | ||||
-rw-r--r-- | libs/pbd/test/mutex_test.h | 17 | ||||
-rw-r--r-- | libs/pbd/test/test_common.cc | 4 | ||||
-rw-r--r-- | libs/pbd/test/test_common.h | 2 | ||||
-rw-r--r-- | libs/pbd/test/testrunner.cc | 4 |
6 files changed, 50 insertions, 3 deletions
diff --git a/libs/pbd/test/filesystem_test.cc b/libs/pbd/test/filesystem_test.cc index ce2faadc82..458105d177 100644 --- a/libs/pbd/test/filesystem_test.cc +++ b/libs/pbd/test/filesystem_test.cc @@ -10,6 +10,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION (FilesystemTest); void FilesystemTest::testPathIsWithin () { +#ifndef PLATFORM_WINDOWS system ("rm -r foo"); CPPUNIT_ASSERT (g_mkdir_with_parents ("foo/bar/baz", 0755) == 0); @@ -31,5 +32,6 @@ FilesystemTest::testPathIsWithin () CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar")); CPPUNIT_ASSERT (PBD::path_is_within ("foo/jim/baz", "frobozz") == false); +#endif } diff --git a/libs/pbd/test/mutex_test.cc b/libs/pbd/test/mutex_test.cc new file mode 100644 index 0000000000..52c36c4695 --- /dev/null +++ b/libs/pbd/test/mutex_test.cc @@ -0,0 +1,24 @@ +#include "mutex_test.h" + +CPPUNIT_TEST_SUITE_REGISTRATION (MutexTest); + +using namespace std; + +MutexTest::MutexTest () +{ +} + +void +MutexTest::testBasic () +{ + Glib::Threads::Mutex::Lock lm (m_mutex); + + CPPUNIT_ASSERT (lm.locked()); + + /* This will fail on POSIX systems but not on some older versions of glib + * on win32 as TryEnterCriticalSection is used and it will return true + * as CriticalSection is reentrant and fail the assertion. + */ + CPPUNIT_ASSERT (!m_mutex.trylock()); + +} diff --git a/libs/pbd/test/mutex_test.h b/libs/pbd/test/mutex_test.h new file mode 100644 index 0000000000..95b6ea3f65 --- /dev/null +++ b/libs/pbd/test/mutex_test.h @@ -0,0 +1,17 @@ +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include "glibmm/threads.h" + +class MutexTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (MutexTest); + CPPUNIT_TEST (testBasic); + CPPUNIT_TEST_SUITE_END (); + +public: + MutexTest (); + void testBasic (); + +private: + Glib::Threads::Mutex m_mutex; +}; diff --git a/libs/pbd/test/test_common.cc b/libs/pbd/test/test_common.cc index 16da3ed2a8..6e099d2f3e 100644 --- a/libs/pbd/test/test_common.cc +++ b/libs/pbd/test/test_common.cc @@ -25,10 +25,10 @@ * in an installed location on windows or by setting an environment variable * on unix. */ -PBD::SearchPath +PBD::Searchpath test_search_path () { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS std::string wsp(g_win32_get_package_installation_directory_of_module(NULL)); return Glib::build_filename (wsp, "pbd_testdata"); #else diff --git a/libs/pbd/test/test_common.h b/libs/pbd/test/test_common.h index 0dc62f61dc..825c01fecb 100644 --- a/libs/pbd/test/test_common.h +++ b/libs/pbd/test/test_common.h @@ -21,6 +21,6 @@ #include "pbd/search_path.h" -PBD::SearchPath test_search_path (); +PBD::Searchpath test_search_path (); #endif diff --git a/libs/pbd/test/testrunner.cc b/libs/pbd/test/testrunner.cc index 1512ebd024..ea8f0aa115 100644 --- a/libs/pbd/test/testrunner.cc +++ b/libs/pbd/test/testrunner.cc @@ -4,11 +4,15 @@ #include <cppunit/TestResultCollector.h> #include <cppunit/TestRunner.h> #include <cppunit/BriefTestProgressListener.h> +#include <glibmm/thread.h> #include "scalar_properties.h" + int main () { + Glib::thread_init(); + ScalarPropertiesTest::make_property_quarks (); CppUnit::TestResult testresult; |