3 # Copyright The SCons Foundation
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Unit tests for linkCommon package
30 from SCons
.Environment
import Environment
33 class SharedLibraryTestCase(unittest
.TestCase
):
34 def setUp(self
) -> None:
37 def test_shlib_symlink_emitter(self
) -> None:
38 """Test shlib_symlink_emitter() """
39 env
= Environment(tools
=['gnulink'])
41 target
= env
.SharedLibrary('lib', 'lib.c', SHLIBPREFIX
='lib', SHLIBSUFFIX
=".so")
43 target_name
= str(target
[0])
44 self
.assertEqual(str(target_name
), 'liblib.so', "Expected target 'liblib.so' != '%s'" % target_name
)
46 target
= env
.SharedLibrary('xyz', 'lib.c', SHLIBPREFIX
='xyz', SHLIBSUFFIX
=".so", SHLIBVERSION
='1.2.3')
51 assert target_name
== 'xyzxyz.so.1.2.3', "Expected target 'xyzxyz.so.1.2.3' != '%s'" % target_name
53 if hasattr(t0
.attributes
, 'shliblinks'):
54 (soname_symlink
, t0_1
) = t0
.attributes
.shliblinks
[0]
55 (shlib_noversion_symlink
, t0_2
) = t0
.attributes
.shliblinks
[1]
57 self
.assertEqual(t0_1
, t0
, "soname_symlink target is not target[0]")
58 self
.assertEqual(t0_2
, t0
, "shlib_noversion_symlink target is not target[0]")
59 self
.assertEqual(str(soname_symlink
), 'xyzxyz.so.1',
60 "soname symlink is not 'xyzxyz.so.1': '%s'" % str(soname_symlink
))
61 self
.assertEqual(str(shlib_noversion_symlink
), 'xyzxyz.so',
62 "shlib_noversion_symlink is not 'xyzxyz.so': '%s'" % str(shlib_noversion_symlink
))
65 self
.fail('Target xyzxyz.so.1.2.3 has no .attributes.shliblinks')
68 if __name__
== "__main__":
73 # indent-tabs-mode:nil
75 # vim: set expandtab tabstop=4 shiftwidth=4: