|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50763 - in sandbox/interthreads/libs/interthreads: build test
From: vicente.botet_at_[hidden]
Date: 2009-01-25 07:54:31
Author: viboes
Date: 2009-01-25 07:54:30 EST (Sun, 25 Jan 2009)
New Revision: 50763
URL: http://svn.boost.org/trac/boost/changeset/50763
Log:
interthreads version 0.3.1
Most bugs fixed
Added:
sandbox/interthreads/libs/interthreads/test/data_types.hpp (contents, props changed)
Text files modified:
sandbox/interthreads/libs/interthreads/build/Jamfile.v2 | 7 +++----
sandbox/interthreads/libs/interthreads/test/Jamfile.v2 | 8 ++++----
sandbox/interthreads/libs/interthreads/test/test_ae.hpp | 18 +++++++++---------
sandbox/interthreads/libs/interthreads/test/test_basic_threader.cpp | 6 ++++--
sandbox/interthreads/libs/interthreads/test/test_thread_pool.cpp | 25 +++++--------------------
sandbox/interthreads/libs/interthreads/test/test_threader.cpp | 40 +++++++++++++++++++++++++---------------
6 files changed, 50 insertions(+), 54 deletions(-)
Modified: sandbox/interthreads/libs/interthreads/build/Jamfile.v2
==============================================================================
--- sandbox/interthreads/libs/interthreads/build/Jamfile.v2 (original)
+++ sandbox/interthreads/libs/interthreads/build/Jamfile.v2 2009-01-25 07:54:30 EST (Sun, 25 Jan 2009)
@@ -1,4 +1,3 @@
-# $Id$
# Copyright 2006-2007 Roland Schwarz.
# Copyright 2007 Anthony Williams
# Copyright 2008-2009 Vicente Botet Escriba
@@ -40,9 +39,9 @@
project boost/interthreads
: source-location ../src
: requirements <threading>multi
- <target-os>cygwin
- <threadapi>pthread
- <variant>debug
+# <target-os>cygwin
+# <threadapi>pthread
+# <variant>debug
# <define>BOOST_THREAD_HAS_THREAD_ATTR
<include>../../..
Modified: sandbox/interthreads/libs/interthreads/test/Jamfile.v2
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/Jamfile.v2 (original)
+++ sandbox/interthreads/libs/interthreads/test/Jamfile.v2 2009-01-25 07:54:30 EST (Sun, 25 Jan 2009)
@@ -26,9 +26,9 @@
<include>.
<include>../../..
<threading>multi
- <target-os>cygwin
- <threadapi>pthread
- <variant>debug
+# <target-os>cygwin
+# <threadapi>pthread
+# <variant>debug
# <define>BOOST_THREAD_HAS_THREAD_ATTR
;
@@ -46,7 +46,7 @@
{
test-suite "tests"
:
- [ interthreads-run move_test.cpp ]
+# [ interthreads-run move_test.cpp ]
[ interthreads-run test_basic_threader.cpp ]
[ interthreads-run test_launcher.cpp ]
[ interthreads-run test_threader.cpp ]
Added: sandbox/interthreads/libs/interthreads/test/data_types.hpp
==============================================================================
--- (empty file)
+++ sandbox/interthreads/libs/interthreads/test/data_types.hpp 2009-01-25 07:54:30 EST (Sun, 25 Jan 2009)
@@ -0,0 +1,101 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-20009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/sync for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERTHREADS_TEST_DATA_TYPES__HPP
+#define BOOST_INTERTHREADS_TEST_DATA_TYPES__HPP
+
+
+#include <boost/thread/xtime.hpp>
+#include <boost/thread/thread.hpp>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+using namespace boost::unit_test;
+
+namespace
+{
+inline boost::xtime delay(int secs, int msecs=0, int nsecs=0)
+{
+ const int MILLISECONDS_PER_SECOND = 1000;
+ const int NANOSECONDS_PER_SECOND = 1000000000;
+ const int NANOSECONDS_PER_MILLISECOND = 1000000;
+
+ boost::xtime xt;
+ if (boost::TIME_UTC != boost::xtime_get (&xt, boost::TIME_UTC))
+ BOOST_ERROR ("boost::xtime_get != boost::TIME_UTC");
+
+ nsecs += xt.nsec;
+ msecs += nsecs / NANOSECONDS_PER_MILLISECOND;
+ secs += msecs / MILLISECONDS_PER_SECOND;
+ nsecs += (msecs % MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND;
+ xt.nsec = nsecs % NANOSECONDS_PER_SECOND;
+ xt.sec += secs + (nsecs / NANOSECONDS_PER_SECOND);
+
+ return xt;
+}
+
+void sleep(int sec)
+{
+ boost::xtime t;
+ boost::xtime_get(&t,1);
+ t.sec += sec;
+ boost::thread::sleep(t);
+}
+}
+
+
+
+struct non_copyable_functor
+ : boost::noncopyable
+{
+ unsigned value;
+ typedef unsigned result_type;
+
+ non_copyable_functor():
+ value(0)
+ {}
+
+ unsigned operator()()
+ {
+ value=999;
+ return value;
+ }
+};
+
+struct copyable_functor
+{
+ unsigned value;
+ typedef int result_type;
+
+ copyable_functor():
+ value(0)
+ {}
+
+ int operator()()
+ {
+ value=999;
+ return value;
+ }
+};
+
+struct print_xml
+{
+ template <typename T>
+ void operator()(T const& x) const
+ {
+ std::cout
+// << '<' << typeid(x).name() << '>'
+ << x
+// << "</" << typeid(x).name() << '>'
+ << std::endl
+ ;
+ }
+};
+
+#endif
Modified: sandbox/interthreads/libs/interthreads/test/test_ae.hpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/test_ae.hpp (original)
+++ sandbox/interthreads/libs/interthreads/test/test_ae.hpp 2009-01-25 07:54:30 EST (Sun, 25 Jan 2009)
@@ -171,12 +171,12 @@
template <typename AE>
void do_test_wait_for_any(AE& ae) {
- BOOST_AUTO(res, bith::wait_for_any(ae, simple_thread, simple_thread2));
- BOOST_CHECK_EQUAL(res.first, 0u);
- BOOST_CHECK_EQUAL(res.second, 999);
- res = bith::wait_for_any(ae, simple_thread2, simple_thread);
+ BOOST_AUTO(res, bith::wait_for_any(ae, simple_thread2, simple_thread));
BOOST_CHECK_EQUAL(res.first, 1u);
BOOST_CHECK_EQUAL(res.second, 999);
+ res = bith::wait_for_any(ae, simple_thread, simple_thread2);
+ BOOST_CHECK_EQUAL(res.first, 0u);
+ BOOST_CHECK_EQUAL(res.second, 999);
}
template <typename AE>
@@ -244,13 +244,12 @@
BOOST_CHECK(!failed);
}
-
template <typename AE>
void do_test_fork_after_get(AE& ae) {
test_value=0;
test_value2=0;
test_value3=0;
- BOOST_AUTO(actT, fork_all(ae, my_simple_thread, my_simple_thread2));
+ BOOST_AUTO(actT, bith::fork_all(ae, my_simple_thread, my_simple_thread2));
#ifndef ACT_WRAPPER
typename AE:: template handle<int>::type res;
@@ -264,12 +263,13 @@
BOOST_CHECK_EQUAL(test_value3, 333);
BOOST_CHECK_EQUAL(res, 333);
}
+
template <typename AE>
void do_test_fork_after_wait(AE& ae) {
test_value=0;
test_value2=0;
test_value3=0;
- BOOST_AUTO(actT, fork_all(ae, my_simple_thread, my_simple_thread2));
+ BOOST_AUTO(actT, bith::fork_all(ae, my_simple_thread, my_simple_thread2));
#ifndef ACT_WRAPPER
typename AE:: template handle<int>::type res;
@@ -283,12 +283,13 @@
BOOST_CHECK_EQUAL(test_value3, 333);
}
+
template <typename AE>
void do_test_fork_after_join(AE& ae) {
test_value=0;
test_value2=0;
test_value3=0;
- BOOST_AUTO(actT, fork_all(ae, my_simple_thread, my_simple_thread2));
+ BOOST_AUTO(actT, bith::fork_all(ae, my_simple_thread, my_simple_thread2));
#ifndef ACT_WRAPPER
typename AE:: template handle<int>::type res;
@@ -302,6 +303,5 @@
BOOST_CHECK_EQUAL(test_value3, 333);
}
-
}
#endif
Modified: sandbox/interthreads/libs/interthreads/test/test_basic_threader.cpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/test_basic_threader.cpp (original)
+++ sandbox/interthreads/libs/interthreads/test/test_basic_threader.cpp 2009-01-25 07:54:30 EST (Sun, 25 Jan 2009)
@@ -71,7 +71,7 @@
}
#if 0
-// this do not works because boost::thread is not movable-only and boost::fusion::tuple works only with CopyContructible types
+// this do not works because boost::thread is movable-only and boost::fusion::tuple works only with CopyContructible types
void do_test_join_all() {
bith::basic_threader ae;
typedef bith::result_of::fork_all<bith::basic_threader,bfus::tuple<void(*)(),void(*)()> >::type type;
@@ -89,7 +89,9 @@
test->add(BOOST_TEST_CASE(&do_test_member_fork_bind));
test->add(BOOST_TEST_CASE(&do_test_fork));
test->add(BOOST_TEST_CASE(&do_test_fork_1));
- //test->add(BOOST_TEST_CASE(&do_test_join_all));
+#if 0
+ test->add(BOOST_TEST_CASE(&do_test_join_all));
+#endif
return test;
}
Modified: sandbox/interthreads/libs/interthreads/test/test_thread_pool.cpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/test_thread_pool.cpp (original)
+++ sandbox/interthreads/libs/interthreads/test/test_thread_pool.cpp 2009-01-25 07:54:30 EST (Sun, 25 Jan 2009)
@@ -9,25 +9,14 @@
//////////////////////////////////////////////////////////////////////////////
-#include "boost/fusion/include/vector_tie.hpp"
-#include "boost/thread/thread_time.hpp"
-#include "boost/thread/mutex.hpp"
-#include "boost/thread/locks.hpp"
-#include <boost/thread/xtime.hpp>
-#include "boost/interthreads/typeof/launcher.hpp"
-#include "boost/interthreads/typeof/threader.hpp"
#include "boost/interthreads/typeof/scheduler.hpp"
-#include "boost/interthreads/typeof/future.hpp"
#include "boost/interthreads/algorithm.hpp"
-#include <boost/typeof/typeof.hpp>
#include <libs/interthreads/test/data_types.hpp>
#include <libs/interthreads/test/test_ae.hpp>
#include <iostream>
#include <boost/test/unit_test.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/type_traits.hpp>
#include <boost/tp/unbounded_channel.hpp>
#include <boost/tp/fifo.hpp>
@@ -36,7 +25,7 @@
namespace bith = boost::interthreads;
namespace bfus = boost::fusion;
-#define SCHEDULER
+//#define SCHEDULER
#ifdef SCHEDULER
typedef bith::scheduler<
@@ -54,7 +43,6 @@
aetst::do_test_member_fork(ae);
}
-
void do_test_member_fork_bind() {
pool_type ae(boost::tp::poolsize(2));
aetst::do_test_member_fork_bind(ae);
@@ -107,7 +95,6 @@
aetst::do_test_wait_for_all(ae);
}
-#if 0 // DO NOT COMPILE
void do_test_fork_after_wait() {
pool_type ae(boost::tp::poolsize(2));
aetst::do_test_fork_after_wait(ae);
@@ -116,7 +103,6 @@
pool_type ae(boost::tp::poolsize(2));
aetst::do_test_fork_after_get(ae);
}
-#endif
test_suite* init_unit_test_suite(int, char*[])
{
@@ -132,10 +118,9 @@
test->add(BOOST_TEST_CASE(&do_test_wait_all));
test->add(BOOST_TEST_CASE(&do_test_set_all));
test->add(BOOST_TEST_CASE(&do_test_wait_for_all));
-#if 0
- test->add(BOOST_TEST_CASE(&do_test_fork_after_wait)); // DO NOT COMPILE
- test->add(BOOST_TEST_CASE(&do_test_fork_after_get)); // DO NOT COMPILE
- test->add(BOOST_TEST_CASE(&do_test_wait_for_any)); // FAILS
-#endif
+ test->add(BOOST_TEST_CASE(&do_test_fork_after_wait));
+ test->add(BOOST_TEST_CASE(&do_test_fork_after_get));
+ test->add(BOOST_TEST_CASE(&do_test_wait_for_any));
+
return test;
}
Modified: sandbox/interthreads/libs/interthreads/test/test_threader.cpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/test_threader.cpp (original)
+++ sandbox/interthreads/libs/interthreads/test/test_threader.cpp 2009-01-25 07:54:30 EST (Sun, 25 Jan 2009)
@@ -7,21 +7,17 @@
// See http://www.boost.org/libs/sync for documentation.
//
//////////////////////////////////////////////////////////////////////////////
-
-
-#include "boost/fusion/include/vector_tie.hpp"
-#include "boost/thread/thread_time.hpp"
+
#include "boost/thread/mutex.hpp"
#include "boost/thread/locks.hpp"
-#include <boost/thread/xtime.hpp>
+
#include "boost/interthreads/typeof/launcher.hpp"
#include "boost/interthreads/typeof/threader.hpp"
#include "boost/interthreads/typeof/future.hpp"
#include "boost/interthreads/algorithm.hpp"
-#ifdef FORK_AFTER
-#endif
#include "boost/interthreads/fork_after.hpp"
#include <boost/typeof/typeof.hpp>
+
#include <libs/interthreads/test/data_types.hpp>
#include <libs/interthreads/test/test_ae.hpp>
@@ -29,14 +25,6 @@
#include <string>
#include <boost/test/unit_test.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/type_traits.hpp>
-
-
-//#include "boost/fusion/include/begin.hpp"
-//#include "boost/fusion/include/end.hpp"
-//#include "boost/fusion/include/next.hpp"
-
using namespace boost::unit_test;
namespace bith = boost::interthreads;
namespace bfus = boost::fusion;
@@ -171,6 +159,25 @@
aetst::do_test_fork_after_get(ae);
}
+void do_test_other() {
+ boost::mutex mtx_;
+ int i=0;
+ for (boost::mutex::scoped_lock lock_(mtx_), *continue_hlp_,**continue_=&continue_hlp_; continue_; continue_=0) {
+ i++;
+ }
+ BOOST_CHECK_EQUAL(i, 1);
+
+ for (boost::mutex::scoped_lock lock_(mtx_), *continue_=&lock_; continue_; continue_=0) {
+ i++;
+ }
+ BOOST_CHECK_EQUAL(i, 2);
+ if (bool __stop = false) {} else
+ for (boost::mutex::scoped_lock lock_(mtx_) ; !__stop; __stop= true) {
+ i++;
+ }
+ BOOST_CHECK_EQUAL(i, 3);
+}
+
test_suite* init_unit_test_suite(int, char*[])
{
test_suite* test = BOOST_TEST_SUITE("shared_threader");
@@ -183,6 +190,7 @@
test->add(BOOST_TEST_CASE(&do_test_thread_interrupts_at_interruption_point));
test->add(BOOST_TEST_CASE(&do_test_creation_through_functor));
test->add(BOOST_TEST_CASE(&do_test_creation_through_reference_wrapper));
+
test->add(BOOST_TEST_CASE(&do_test_wait_all));
test->add(BOOST_TEST_CASE(&do_test_join_all));
test->add(BOOST_TEST_CASE(&do_test_wait_for_any));
@@ -192,7 +200,9 @@
test->add(BOOST_TEST_CASE(&do_test_fork_after_wait));
test->add(BOOST_TEST_CASE(&do_test_fork_after_get));
test->add(BOOST_TEST_CASE(&do_test_wait_for_any_fusion_sequence));
+
#if 0
+ test->add(BOOST_TEST_CASE(&do_test_other));
test->add(BOOST_TEST_CASE(&do_test_get_all));
#endif
return test;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk