9 commits - c++/compiled c++/lib libkolabxml.spec.in pykolab/format
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Thu Mar 1 17:33:49 CET 2012
c++/compiled/XMLParserWrapper.h | 7
c++/lib/CMakeLists.txt | 2
c++/lib/base64.h | 3
c++/lib/kolabevent.h | 3
c++/lib/kolabformat.h | 1
c++/lib/kolabjournal.h | 3
c++/lib/kolabtodo.h | 3
c++/lib/utils.h | 3
c++/lib/xcalconversions.h | 3
libkolabxml.spec.in | 20 ++
pykolab/format/tests/test-parallel_threads.py | 247 ++++++++++++++++++++++++++
pykolab/format/tests/test-thread_safety.py | 8
12 files changed, 286 insertions(+), 17 deletions(-)
New commits:
commit 300cb5c68e09854320936a59cbe7f6add4e8980c
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu Mar 1 16:33:10 2012 +0000
Be stubborn and add test-parallel_threads.py
Not sure what happened to Christian's test-thread_safety.py, had to add it back in(?)
diff --git a/pykolab/format/tests/test-parallel_threads.py b/pykolab/format/tests/test-parallel_threads.py
new file mode 100644
index 0000000..617a74e
--- /dev/null
+++ b/pykolab/format/tests/test-parallel_threads.py
@@ -0,0 +1,247 @@
+import unittest
+
+from kolabformat import DateTime
+from kolabformat import Duration
+from kolabformat import Event
+from kolabformat import RecurrenceRule
+
+from kolabformat import getSerializedUID
+from kolabformat import writeEvent
+
+import threading
+import time
+
+class ThreadEvent(threading.Thread):
+ def __init__(self, *args, **kw):
+ threading.Thread.__init__(self, target=self.get_uids, args=[kw['sleep']])
+ self.myevent = Event()
+ # All in UTC.
+ self.myevent.setStart(DateTime(2011,12,31,20,00,00))
+ self.myevent.setEnd(DateTime(2012,01,01,03,00,00))
+
+ # Set the organizer. cal-address first, display name later.
+ self.myevent.setOrganizer("John.Doe at example.org", "John Doe")
+
+ self.myevent.setSummary("New Year's eve")
+
+ self.myevent.setDescription("Celebrate new years eve with some champagne, family and friends")
+
+ def get_uids(self, sleep=0):
+ writeEvent(self.myevent)
+ self.uid1 = getSerializedUID()
+ time.sleep(sleep * 3 * 2)
+ self.uid2 = getSerializedUID()
+
+class TestThreadSafety(unittest.TestCase):
+ def create_threads(self, sleep=0):
+ self.thread1 = ThreadEvent(sleep=sleep)
+ self.thread2 = ThreadEvent(sleep=sleep)
+
+ self.thread1.start()
+
+ time.sleep(sleep * 3)
+
+ self.thread2.start()
+
+ time.sleep(sleep * 3)
+
+ self.thread1.join()
+ self.thread2.join()
+
+ self.uid1_1 = self.thread1.uid1
+ self.uid2_1 = self.thread2.uid1
+
+ self.uid1_2 = self.thread1.uid2
+ self.uid2_2 = self.thread2.uid2
+
+ ##
+ ## Tests that sleep for plenty of time in between actions.
+ ##
+
+ def test_thread_safety_000_05_uid1_1_ne_uid2_1(self):
+ self.create_threads(sleep=0.5)
+
+ self.assertNotEqual(
+ self.uid1_1,
+ self.uid2_1,
+ "uid(1) for the event in thread #1 is the same as uid(1)" + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_000_05_uid1_1_ne_uid2_2(self):
+ self.create_threads(sleep=0.5)
+
+ self.assertNotEqual(
+ self.uid1_1,
+ self.uid2_2,
+ "uid(1) for the event in thread #1 is the same as uid(2)" + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_000_05_uid1_2_ne_uid2_1(self):
+ self.create_threads(sleep=0.5)
+
+ self.assertNotEqual(
+ self.uid1_2,
+ self.uid2_1,
+ "uid(2) for the event in thread #1 is the same as uid(1) " + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_000_05_uid1_2_ne_uid2_2(self):
+ self.create_threads(sleep=0.5)
+
+ self.assertNotEqual(
+ self.uid1_2,
+ self.uid2_2,
+ "uid(2) for the event in thread #1 is the same as uid(2) " + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_000_05_uid1_1_eq_uid1_2(self):
+ self.create_threads(sleep=0.5)
+
+ self.assertEqual(
+ self.uid1_1,
+ self.uid1_2,
+ "uid(1) for the event in thread #1 is different from " + \
+ "uid(2) for the event in thread #1."
+ )
+
+ def test_thread_safety_000_05_uid2_1_eq_uid2_2(self):
+ self.create_threads(sleep=0.5)
+
+ self.assertEqual(
+ self.uid2_1,
+ self.uid2_2,
+ "uid(1) for the event in thread #2 is different from " + \
+ "uid(2) for the event in thread #2."
+ )
+
+ ##
+ ## Tests that sleep for just a little bit in between actions.
+ ##
+
+ def test_thread_safety_001_01_uid1_1_ne_uid2_1(self):
+ self.create_threads(sleep=0.1)
+
+ self.assertNotEqual(
+ self.uid1_1,
+ self.uid2_1,
+ "uid(1) for the event in thread #1 is the same as uid(1)" + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_001_01_uid1_1_ne_uid2_2(self):
+ self.create_threads(sleep=0.1)
+
+ self.assertNotEqual(
+ self.uid1_1,
+ self.uid2_2,
+ "uid(1) for the event in thread #1 is the same as uid(2)" + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_001_01_uid1_2_ne_uid2_1(self):
+ self.create_threads(sleep=0.1)
+
+ self.assertNotEqual(
+ self.uid1_2,
+ self.uid2_1,
+ "uid(2) for the event in thread #1 is the same as uid(1) " + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_001_01_uid1_2_ne_uid2_2(self):
+ self.create_threads(sleep=0.1)
+
+ self.assertNotEqual(
+ self.uid1_2,
+ self.uid2_2,
+ "uid(2) for the event in thread #1 is the same as uid(2) " + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_001_01_uid1_1_eq_uid1_2(self):
+ self.create_threads(sleep=0.1)
+
+ self.assertEqual(
+ self.uid1_1,
+ self.uid1_2,
+ "uid(1) for the event in thread #1 is different from " + \
+ "uid(2) for the event in thread #1."
+ )
+
+ def test_thread_safety_001_01_uid2_1_eq_uid2_2(self):
+ self.create_threads(sleep=0.1)
+
+ self.assertEqual(
+ self.uid2_1,
+ self.uid2_2,
+ "uid(1) for the event in thread #2 is different from " + \
+ "uid(2) for the event in thread #2."
+ )
+
+ ##
+ ## Tests that are fast as lightning (no sleep)
+ ##
+
+ def test_thread_safety_002_00_uid1_1_ne_uid2_1(self):
+ self.create_threads()
+
+ self.assertNotEqual(
+ self.uid1_1,
+ self.uid2_1,
+ "uid(1) for the event in thread #1 is the same as uid(1)" + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_002_00_uid1_1_ne_uid2_2(self):
+ self.create_threads()
+
+ self.assertNotEqual(
+ self.uid1_1,
+ self.uid2_2,
+ "uid(1) for the event in thread #1 is the same as uid(2)" + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_002_00_uid1_2_ne_uid2_1(self):
+ self.create_threads()
+
+ self.assertNotEqual(
+ self.uid1_2,
+ self.uid2_1,
+ "uid(2) for the event in thread #1 is the same as uid(1) " + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_002_00_uid1_2_ne_uid2_2(self):
+ self.create_threads()
+
+ self.assertNotEqual(
+ self.uid1_2,
+ self.uid2_2,
+ "uid(2) for the event in thread #1 is the same as uid(2) " + \
+ "for the event in thread #2."
+ )
+
+ def test_thread_safety_002_00_uid1_1_eq_uid1_2(self):
+ self.create_threads()
+
+ self.assertEqual(
+ self.uid1_1,
+ self.uid1_2,
+ "uid(1) for the event in thread #1 is different from " + \
+ "uid(2) for the event in thread #1."
+ )
+
+ def test_thread_safety_002_00_uid2_1_eq_uid2_2(self):
+ self.create_threads()
+
+ self.assertEqual(
+ self.uid2_1,
+ self.uid2_2,
+ "uid(1) for the event in thread #2 is different from " + \
+ "uid(2) for the event in thread #2."
+ )
diff --git a/pykolab/format/tests/test-thread_safety.py b/pykolab/format/tests/test-thread_safety.py
new file mode 100644
index 0000000..2e21a32
--- /dev/null
+++ b/pykolab/format/tests/test-thread_safety.py
@@ -0,0 +1,67 @@
+import unittest
+
+from kolabformat import DateTime
+from kolabformat import Duration
+from kolabformat import Event
+from kolabformat import RecurrenceRule
+
+from kolabformat import getSerializedUID
+from kolabformat import writeEvent
+
+import threading
+import time
+
+class ThreadEvent(threading.Thread):
+ def __init__(self, *args, **kw):
+ threading.Thread.__init__(self, target=self.create_event)
+ self.errorBit = False
+
+ def create_event(self):
+ self.myevent = Event()
+ # All in UTC.
+ self.myevent.setStart(DateTime(2011,12,31,20,00,00))
+ self.myevent.setEnd(DateTime(2012,01,01,03,00,00))
+
+ # Set the organizer. cal-address first, display name later.
+ self.myevent.setOrganizer("John.Doe at example.org", "John Doe")
+
+ self.myevent.setSummary("New Year's eve")
+
+ self.myevent.setDescription("Celebrate new years eve with some champagne, family and friends")
+
+
+ def write(self):
+ self.create_event()
+ writeEvent(self.myevent)
+
+ def uid(self):
+ return getSerializedUID()
+
+ def run(self):
+ for i in range(10):
+ self.write()
+ self.uid1 = self.uid()
+ time.sleep(1)
+ #We expect the other thread to be called once while we're sleeping
+ #To be absolutely sure we'd have to use locking
+ self.uid2 = self.uid()
+ if self.uid1 != self.uid2:
+ self.errorBit = True
+
+class TestThreadSafety(unittest.TestCase):
+ def create_threads(self):
+ self.thread1 = ThreadEvent()
+ self.thread1.start()
+
+ self.thread2 = ThreadEvent()
+ self.thread2.start()
+
+ time.sleep(10.0)
+
+ self.thread2.join();
+ self.thread1.join();
+
+ def test_thread_safety_uid1_ne_uid2(self):
+ self.create_threads()
+ self.assertTrue(not self.thread1.errorBit)
+ self.assertTrue(not self.thread2.errorBit)
commit 09b87f275a19f382ed5ef6fbeaadbed6645d0d0b
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu Mar 1 16:33:02 2012 +0000
Add build requirements
diff --git a/libkolabxml.spec.in b/libkolabxml.spec.in
index 16d812d..55e2652 100644
--- a/libkolabxml.spec.in
+++ b/libkolabxml.spec.in
@@ -9,7 +9,11 @@ URL: http://www.kolab.org
Source0: http://git.kolab.org/libkolabxml/snapshot/%{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
+%if 0%{?rhel} < 6
+BuildRequires: boost141-devel
+%else
BuildRequires: boost-devel
+%endif
BuildRequires: cmake
BuildRequires: gcc-c++
BuildRequires: gettext
@@ -17,7 +21,7 @@ BuildRequires: intltool
BuildRequires: php-devel
BuildRequires: python-devel
BuildRequires: swig
-BuildRequires: xerces-c
+BuildRequires: xerces-c-devel
BuildRequires: xsd
#Requires:
@@ -40,6 +44,11 @@ bindings provided through libkolabxml.
%build
%configure
+
+%if 0%{?rhel} < 6
+export BOOST_INCLUDEDIR=/usr/include/boost141/
+%endif
+
make %{?_smp_mflags}
%install
commit bcf0edd25f10b66b587fd08815cc651253543564
Merge: a7b82bb 1b10e07
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu Mar 1 16:30:46 2012 +0000
Merge branch 'master' of ssh://git.kolab.org/git/libkolabxml
commit a7b82bb127c4b200348162a218bb810df7ca8f9e
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Feb 24 18:24:46 2012 +0000
Correct the location to look for XMLGrammarPool.hpp for versions of xerces-c < 3.0
diff --git a/c++/compiled/XMLParserWrapper.h b/c++/compiled/XMLParserWrapper.h
index 1c8b7ee..8f6362e 100644
--- a/c++/compiled/XMLParserWrapper.h
+++ b/c++/compiled/XMLParserWrapper.h
@@ -32,12 +32,7 @@
# include <xercesc/dom/DOMBuilder.hpp>
#endif
-
-#if _XERCES_VERSION >= 30000
-# include <xercesc/framework/XMLGrammarPool.hpp>
-#else
-# include <xercesc/internal/XMLGrammarPool.hpp>
-#endif
+#include <xercesc/framework/XMLGrammarPool.hpp>
/**
* This wrapper controls the lifetime of the parser object.
commit 5e7ef57735e205c85ae96eaf3ec0d3180e7f1f35
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Feb 24 18:10:36 2012 +0000
Also include newline at oef here
diff --git a/c++/lib/kolabevent.h b/c++/lib/kolabevent.h
index 6cb1587..0c32867 100644
--- a/c++/lib/kolabevent.h
+++ b/c++/lib/kolabevent.h
@@ -121,4 +121,5 @@ private:
}
-#endif
\ No newline at end of file
+#endif
+
commit 479cb74da2287f4cf3126d39ebd2868bdbc37d6c
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Feb 24 18:08:25 2012 +0000
Include eol at end of file
diff --git a/c++/lib/base64.h b/c++/lib/base64.h
index ceb1357..5f87aec 100644
--- a/c++/lib/base64.h
+++ b/c++/lib/base64.h
@@ -1,4 +1,5 @@
#include <string>
std::string base64_encode(unsigned char const* , unsigned int len);
-std::string base64_decode(std::string const& s);
\ No newline at end of file
+std::string base64_decode(std::string const& s);
+
diff --git a/c++/lib/kolabformat.h b/c++/lib/kolabformat.h
index 56e0c39..bd9782d 100644
--- a/c++/lib/kolabformat.h
+++ b/c++/lib/kolabformat.h
@@ -80,3 +80,4 @@ std::string writeConfiguration(const Kolab::Configuration &);
}
#endif // KOLABFORMAT_H
+
diff --git a/c++/lib/kolabjournal.h b/c++/lib/kolabjournal.h
index d9806f2..025d6e4 100644
--- a/c++/lib/kolabjournal.h
+++ b/c++/lib/kolabjournal.h
@@ -83,4 +83,5 @@ private:
}
-#endif
\ No newline at end of file
+#endif
+
diff --git a/c++/lib/kolabtodo.h b/c++/lib/kolabtodo.h
index 1271bc0..8391621 100644
--- a/c++/lib/kolabtodo.h
+++ b/c++/lib/kolabtodo.h
@@ -117,4 +117,5 @@ private:
}
-#endif
\ No newline at end of file
+#endif
+
diff --git a/c++/lib/utils.h b/c++/lib/utils.h
index 41f60ce..9a6a868 100644
--- a/c++/lib/utils.h
+++ b/c++/lib/utils.h
@@ -114,4 +114,5 @@ std::string uriInlineDecoding(const std::string &s, std::string &mimetype);
} //Namespace
-#endif
\ No newline at end of file
+#endif
+
diff --git a/c++/lib/xcalconversions.h b/c++/lib/xcalconversions.h
index e0d3412..0cd6e47 100644
--- a/c++/lib/xcalconversions.h
+++ b/c++/lib/xcalconversions.h
@@ -1716,4 +1716,5 @@ typename T::IncidencePtr deserializeIncidence(const std::string& s, bool isUrl)
}
}//Namespace
-#endif
\ No newline at end of file
+#endif
+
commit 5bee3d5444b318eca180003b0a4f55e74636ceb0
Merge: 7ee21a1 f73a454
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Feb 24 17:53:20 2012 +0000
Merge branch 'master' of ssh://git.kolab.org/git/libkolabxml
Conflicts:
c++/lib/CMakeLists.txt
diff --cc libkolabxml.spec.in
index 38d0f2d,76affbf..16d812d
--- a/libkolabxml.spec.in
+++ b/libkolabxml.spec.in
@@@ -9,7 -9,7 +9,16 @@@ URL: http://www.kolab.or
Source0: http://git.kolab.org/libkolabxml/snapshot/%{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
- BuildRequires: boost-thread
-#BuildRequires:
++BuildRequires: boost-devel
++BuildRequires: cmake
++BuildRequires: gcc-c++
++BuildRequires: gettext
++BuildRequires: intltool
++BuildRequires: php-devel
++BuildRequires: python-devel
++BuildRequires: swig
++BuildRequires: xerces-c
++BuildRequires: xsd
#Requires:
%description
diff --cc pykolab/format/tests/test-thread_safety.py
index 8878356,8878356..0000000
deleted file mode 100644,100644
--- a/pykolab/format/tests/test-thread_safety.py
+++ /dev/null
commit 7ee21a1a6d859f1b3caed12091319429eb8607ee
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Feb 24 13:03:15 2012 +0000
Correct boost-thread library linking (thanks to Thomas Jarosch <thomas.jarosch at intra2net.com>)
diff --git a/c++/lib/CMakeLists.txt b/c++/lib/CMakeLists.txt
index dfd4921..6fcfd90 100644
--- a/c++/lib/CMakeLists.txt
+++ b/c++/lib/CMakeLists.txt
@@ -10,7 +10,9 @@ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC " ) #always generate shared libra
#Library with serialization/deserialization code and kolab-containers
add_library(kolabxml SHARED kolabformat.cpp kolabcontainers.cpp kolabevent.cpp kolabtodo.cpp kolabjournal.cpp kolabcontact.cpp utils.cpp base64.cpp ../compiled/XMLParserWrapper.cpp ../compiled/grammar-input-stream.cxx ${SCHEMA_SOURCEFILES})
-target_link_libraries(kolabxml ${XERCES_C} boost_thread)
+# boost
+find_package(Boost COMPONENTS thread REQUIRED)
+target_link_libraries(kolabxml ${XERCES_C} ${Boost_LIBRARIES})
#For the core library we can be stricter when compiling. This doesn't work with the auto generated code though.
set_target_properties(kolabxml PROPERTIES COMPILE_FLAGS "-Wl,--no-undefined -Werror ")
commit bee1fdbba3c69c3ba387d99171a370181b57eb79
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Feb 24 10:45:36 2012 +0000
Add build requirement for boost-thread
diff --git a/libkolabxml.spec.in b/libkolabxml.spec.in
index 76affbf..38d0f2d 100644
--- a/libkolabxml.spec.in
+++ b/libkolabxml.spec.in
@@ -9,7 +9,7 @@ URL: http://www.kolab.org
Source0: http://git.kolab.org/libkolabxml/snapshot/%{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
-#BuildRequires:
+BuildRequires: boost-thread
#Requires:
%description
More information about the commits
mailing list