3 # NEPI, a framework to manage network experiments
4 # Copyright (C) 2013 INRIA
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
22 from nepi.util.parallel import ParallelRun
27 class ParallelRunTestCase(unittest.TestCase):
28 def test_run_simple(self):
29 runner = ParallelRun(maxthreads = 4)
38 runner.put(inc, count)
42 self.assertEquals(count[0], 10)
44 def test_run_interrupt(self):
50 startt = datetime.datetime.now()
52 runner = ParallelRun(maxthreads = 4)
61 endt = datetime.datetime.now()
62 time_elapsed = (endt - startt).seconds
63 self.assertTrue( time_elapsed < 500)
65 def test_run_error(self):
74 runner = ParallelRun(maxthreads = 4)
78 runner.put(inc, count)
84 self.assertEquals(count[0], 4)
86 self.assertRaises(RuntimeError, runner.sync)
88 if __name__ == '__main__':