Salome HOME
3a34170c80b3d9b4de25b155ffa81f0a136fe9dc
[modules/yacs.git] / src / bases / Test / basesTest.hxx
1 // Copyright (C) 2006-2021  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _BASESTEST_HXX_
21 #define _BASESTEST_HXX_
22
23 #include <cppunit/extensions/HelperMacros.h>
24 #include "Mutex.hxx"
25 #include "Thread.hxx"
26 #include "Semaphore.hxx"
27 #include "DynLibLoader.hxx"
28
29 namespace YACS
30 {
31   class BasesTest: public CppUnit::TestFixture
32   {
33     CPPUNIT_TEST_SUITE( BasesTest );
34     CPPUNIT_TEST( test1 );
35     CPPUNIT_TEST( test2 );
36     CPPUNIT_TEST( test3 );
37     CPPUNIT_TEST( testDL );
38     CPPUNIT_TEST_SUITE_END();
39       
40   public:
41       
42     void setUp();
43     void tearDown();
44       
45     void test1();
46     void test2();
47     void test3();
48     void testDL();
49
50   protected:
51       
52   private:
53     static void *th1_1(void *);
54     static void *th1_2(void *);
55     static void *th1_3(void *);
56     static void *th2_1(void *);
57
58     static void *myFunc(void *);
59     static void get_resources(int id, int amount);
60     static void free_resources(int id, int amount);
61     static int count_resources();
62       
63     static int _var;
64     static std::ostringstream _glob;
65     static YACS::BASES::Mutex _m;
66     static YACS::BASES::Semaphore _s1;
67     static YACS::BASES::Semaphore _s2;
68     static YACS::BASES::Condition _cond;
69       
70     static const int THREAD_NUM;
71     static const int LOOPS;
72     static const int MAX_RESOURCE;
73     static int _value;
74     static int _waiting;
75     static int _resources;
76     static int _ownedResources[];
77
78   };
79
80 }
81
82 #endif