]> SALOME platform Git repositories - tools/sat.git/blob - test/test_sat5_0/compilation/test_compilation.py
Salome HOME
option bin_products part 1
[tools/sat.git] / test / test_sat5_0 / compilation / test_compilation.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3
4 #  Copyright (C) 2010-2018  CEA/DEN
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library 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 GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19
20 import os
21 import sys
22 import unittest
23
24 import src.product
25 from src.salomeTools import Sat
26
27 class TestCase(unittest.TestCase):
28     """Test of the compile command"""
29
30     def test_010(self):
31         # Test the compile command with '--products' option
32         OK = 'KO'
33
34         appli = 'appli-test'
35         product_name = 'PRODUCT_GIT'
36
37         sat = Sat()
38                             
39         sat.prepare(appli + ' --product ' + product_name)
40         expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
41         expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
42
43         sat.clean(appli + ' --build --install --product ' + product_name, batch=True)
44         sat.compile(appli + ' --product ' + product_name)
45         
46         if os.path.exists(expected_file_path):
47             OK = 'OK'         
48         # pyunit method to compare 2 str
49         self.assertEqual(OK, 'OK')
50
51     def test_020(self):
52         # Test the configure command with '--fathers' option
53         OK = 'KO'
54
55         appli = 'appli-test'
56         product_name = 'PRODUCT_GIT'
57         product_name2 = 'PRODUCT_ARCHIVE'
58
59         sat = Sat()
60                             
61         sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
62         expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
63         expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
64         expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
65         expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
66         
67         sat.clean(appli + ' --build --install --product ' + product_name +"," +product_name2, batch=True)
68         sat.compile(appli + ' --with_fathers --product ' + product_name)
69         
70         if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
71             OK = 'OK'         
72         # pyunit method to compare 2 str
73         self.assertEqual(OK, 'OK')
74         
75     def test_030(self):
76         # Test the configure command with '--children' option
77         OK = 'KO'
78
79         appli = 'appli-test'
80         product_name = 'PRODUCT_GIT'
81         product_name2 = 'PRODUCT_ARCHIVE'
82
83         sat = Sat()
84                             
85         sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
86         expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
87         expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
88         expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
89         expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
90
91         sat.clean(appli + ' --build --install --product ' + product_name +"," +product_name2, batch=True)
92         sat.compile(appli + ' --with_children --product ' + product_name2)
93         
94         if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
95             OK = 'OK'         
96         # pyunit method to compare 2 str
97         self.assertEqual(OK, 'OK')
98
99     def test_040(self):
100         # Test the configure command with '--clean_all' option
101         OK = 'KO'
102
103         appli = 'appli-test'
104         product_name = 'PRODUCT_GIT'
105         product_name2 = 'PRODUCT_ARCHIVE'
106
107         sat = Sat()
108                             
109         sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
110         expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
111         expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
112         expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
113         expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
114
115         sat.compile(appli + ' --with_children --product ' + product_name2)
116         
117         sat.compile(appli + ' --clean_all --with_children --product ' + product_name2, batch=True)
118         
119         if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
120             OK = 'OK'         
121         # pyunit method to compare 2 str
122         self.assertEqual(OK, 'OK')
123
124     def test_050(self):
125         # Test the configure command with '--clean_install' option
126         OK = 'KO'
127
128         appli = 'appli-test'
129         product_name = 'PRODUCT_GIT'
130         product_name2 = 'PRODUCT_ARCHIVE'
131
132         sat = Sat()
133                             
134         sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
135         expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
136         expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
137         expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
138         expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
139
140         sat.compile(appli + ' --with_children --product ' + product_name2)
141         
142         sat.compile(appli + ' --clean_install --with_children --product ' + product_name2, batch=True)
143         
144         if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
145             OK = 'OK'         
146         # pyunit method to compare 2 str
147         self.assertEqual(OK, 'OK')
148
149     def test_060(self):
150         # Test the configure command with '--make_flags' option
151         OK = 'KO'
152
153         appli = 'appli-test'
154         product_name = 'PRODUCT_GIT'
155
156         sat = Sat()
157                             
158         sat.prepare(appli + ' --product ' + product_name)
159         expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
160         expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
161
162         sat.clean(appli + ' --build --install --product ' + product_name, batch=True)
163         sat.compile(appli + ' --make_flags 3 --product ' + product_name)
164                
165         if os.path.exists(expected_file_path):
166             OK = 'OK'         
167         # pyunit method to compare 2 str
168         self.assertEqual(OK, 'OK')
169
170     def test_070(self):
171         # Test the configure command with '--show' option
172         OK = 'KO'
173
174         appli = 'appli-test'
175         product_name = 'PRODUCT_GIT'
176
177         sat = Sat()
178                             
179         sat.prepare(appli + ' --product ' + product_name)
180         expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
181         expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
182
183         sat.clean(appli + ' --build --install --product ' + product_name, batch=True)
184         sat.compile(appli + ' --show --product ' + product_name)
185                
186         if not(os.path.exists(expected_file_path)):
187             OK = 'OK'         
188         # pyunit method to compare 2 str
189         self.assertEqual(OK, 'OK')
190
191     def test_080(self):
192         # Test the configure command with '--stop_first_fail' option
193         OK = 'KO'
194
195         appli = 'appli-test'
196
197         sat = Sat()
198                             
199         sat.prepare(appli + ' --product PRODUCT_CVS,Python')
200         expected_install_dir = src.product.get_product_config(sat.cfg, "PRODUCT_CVS").install_dir
201
202         sat.clean(appli + ' --build --install --product PRODUCT_CVS', batch=True)
203         sat.compile(appli + ' --stop_first_fail --product PRODUCT_CVS,Python')
204                
205         if not(os.path.exists(expected_install_dir)):
206             OK = 'OK'         
207         # pyunit method to compare 2 str
208         self.assertEqual(OK, 'OK')
209
210     def test_090(self):
211         # Test the 'sat -h compile' command to get description       
212
213         OK = "KO"
214
215         import compile
216         
217         if "The compile command constructs the products" in compile.description():
218             OK = "OK"
219
220         # pyunit method to compare 2 str
221         self.assertEqual(OK, "OK")
222
223 # test launch
224 if __name__ == '__main__':
225     unittest.main()
226     pass
227