summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPawel Tomulik <ptomulik@meil.pw.edu.pl>2015-09-20 15:01:35 (GMT)
committerPawel Tomulik <ptomulik@meil.pw.edu.pl>2015-09-20 15:01:35 (GMT)
commit123fea257474ede95fa6bef8fb403cc83eff5cdc (patch)
treee8311f24bbf21acf81fd1bfb5557c294814832df /test
parent9e5928980c0855f91de016467ef752d3aa338f1a (diff)
downloadSCons-123fea257474ede95fa6bef8fb403cc83eff5cdc.zip
SCons-123fea257474ede95fa6bef8fb403cc83eff5cdc.tar.gz
SCons-123fea257474ede95fa6bef8fb403cc83eff5cdc.tar.bz2
add tests to test/LINK/VersionedLib.py
Diffstat (limited to 'test')
-rw-r--r--test/LINK/VersionedLib.py332
1 files changed, 215 insertions, 117 deletions
diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py
index a75e4a5..2e38dee 100644
--- a/test/LINK/VersionedLib.py
+++ b/test/LINK/VersionedLib.py
@@ -32,30 +32,167 @@ import SCons.Platform
_exe = TestSCons._exe
-test = TestSCons.TestSCons()
+platform = SCons.Platform.platform_default()
-test.write('SConstruct', """\
-import os
-env = Environment()
-objs = env.SharedObject('test.c')
-mylib = env.SharedLibrary('test', objs, SHLIBVERSION = '2.5.4')
-env.Program('testapp1.c', LIBS = mylib, LIBPATH='.')
-env.Program('testapp2.c', LIBS = ['test'], LIBPATH='.')
-instnode = env.InstallVersionedLib("#/installtest",mylib)
-env.Default(instnode)
-""")
+if platform == 'posix':
+ test_plan = [
+ {
+ 'libversion' : '2',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2') ],
+ },
+ {
+ 'libversion' : '2.5',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ],
+ },
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ],
+ },
+ {
+ 'libversion' : '2.5.4.7.8',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ],
+ },
+ {
+ 'libversion' : 'aabf114f',
+ 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ],
+ },
+ {
+ 'libversion' : '2.dfffa11',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ],
+ },
+ ]
+elif platform == 'darwin':
+ # All (?) the files we expect will get created in the current directory
+ test_plan = [
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'libtest.dylib', 'libtest.2.5.4.dylib', 'test.os' ],
+ 'instfiles' : [ 'libtest.dylib', 'libtest.2.5.4.dylib' ],
+ 'symlinks' : [],
+ },
+ ]
+elif platform == 'cygwin':
+ test_plan = [
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [],
+ },
+ {
+ 'libversion' : '2',
+ 'files' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-2.dll.a') ],
+ },
+ {
+ 'libversion' : '2.5',
+ 'files' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5.dll.a') ],
+ },
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4.dll.a') ],
+ },
+ {
+ 'libversion' : '2.5.4.7.8',
+ 'files' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4-7-8.dll.a') ],
+ },
+ {
+ 'libversion' : 'aabf114f',
+ 'files' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-aabf114f.dll.a') ],
+ },
+ {
+ 'libversion' : '2.dfffa11',
+ 'files' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-2-dfffa11.dll.a') ],
+ },
+ ]
+elif platform == 'win32':
+ test_plan = [
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'test.dll', 'test.lib', 'test.obj' ],
+ 'instfiles' : [ 'test.dll', 'test.lib' ],
+ 'symlinks' : [],
+ },
+ ]
+elif platform == 'sunos':
+ test_plan = [
+ {
+ 'libversion' : '2',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2') ],
+ },
+ {
+ 'libversion' : '2.5',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ],
+ },
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ],
+ },
+ {
+ 'libversion' : '2.5.4.7.8',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ],
+ },
+ {
+ 'libversion' : 'aabf114f',
+ 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ],
+ },
+ {
+ 'libversion' : '2.dfffa11',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ],
+ },
+ ]
+else:
+ test_plan = [
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'libtest.so', 'test.os' ],
+ 'instfiles' : [ ],
+ },
+ ]
-test.write('test.c', """\
+test_c_src = """\
#if _WIN32
__declspec(dllexport)
#endif
-int testlib(int n)
-{
-return n+1 ;
-}
-""")
+int testlib(int n) { return n+1 ; }
+"""
-testapp_src = """\
+testapp_c_src = """\
#if _WIN32
__declspec(dllimport)
#endif
@@ -70,112 +207,73 @@ printf("results: testlib(2) = %d\\n",itest) ;
return 0 ;
}
"""
-test.write('testapp1.c', testapp_src)
-test.write('testapp2.c', testapp_src)
-platform = SCons.Platform.platform_default()
+for t in test_plan:
+ test = TestSCons.TestSCons()
-test.run(arguments = ['--tree=all'])
+ libversion = t['libversion']
+ files = t['files']
+ symlinks = t['symlinks']
+ instfiles = t['instfiles']
-if platform == 'posix':
- # All (?) the files we expect will get created in the current directory
- files = [
- 'libtest.so',
- 'libtest.so.2',
- 'libtest.so.2.5.4',
- 'test.os',
- ]
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = [
- 'libtest.so',
- 'libtest.so.2',
- 'libtest.so.2.5.4',
- ]
-elif platform == 'darwin':
- # All (?) the files we expect will get created in the current directory
- files = [
- 'libtest.dylib',
- 'libtest.2.5.4.dylib',
- 'test.os',
- ]
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = [
- 'libtest.dylib',
- 'libtest.2.5.4.dylib',
- ]
-elif platform == 'cygwin':
- # All (?) the files we expect will get created in the current directory
- files = [
- 'cygtest-2-5-4.dll',
- 'libtest-2-5-4.dll.a',
- 'libtest.dll.a',
- 'test.os',
- ]
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = [
- 'cygtest-2-5-4.dll',
- 'libtest-2-5-4.dll.a',
- 'libtest.dll.a',
- ]
-elif platform == 'win32':
- # All (?) the files we expect will get created in the current directory
- files = [
- 'test.dll',
- 'test.lib',
- 'test.obj',
- ]
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = [
- 'test.dll',
- 'test.lib',
- ]
-elif platform == 'sunos':
- # All (?) the files we expect will get created in the current directory
- files = [
- 'libtest.so',
- 'libtest.so.2',
- 'libtest.so.2.5.4',
- 'so_test.os',
- ]
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = [
- 'libtest.so',
- 'libtest.so.2',
- 'libtest.so.2.5.4',
- ]
-else:
- # All (?) the files we expect will get created in the current directory
- files= [
- 'libtest.so',
- 'test.os']
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = []
-
-for f in files:
- test.must_exist([ f])
-for f in instfiles:
- test.must_exist(['installtest', f])
-
-# modify test.c and make sure it can recompile when links already exist
-test.write('test.c', """\
-#if _WIN32
-__declspec(dllexport)
-#endif
-int testlib(int n)
-{
-return n+11 ;
-}
-""")
+ test.write('SConstruct', """\
+import os
+env = Environment()
+objs = env.SharedObject('test.c')
+mylib = env.SharedLibrary('test', objs, SHLIBVERSION = '%s')
+env.Program('testapp1.c', LIBS = mylib, LIBPATH='.')
+env.Program('testapp2.c', LIBS = ['test'], LIBPATH='.')
+instnode = env.InstallVersionedLib("#/installtest",mylib)
+env.Default(instnode)
+""" % libversion)
+
+ test.write('test.c', test_c_src)
+ test.write('testapp1.c', testapp_c_src)
+ test.write('testapp2.c', testapp_c_src)
+
+ test.run(arguments = ['--tree=all'])
+
+ for f in files:
+ test.must_exist([ f])
+ for f in instfiles:
+ test.must_exist(['installtest', f])
+
+ wrong_symlinks = []
+ for (linkname,expected) in symlinks:
+ try:
+ endpoint = os.readlink(linkname)
+ except OSError, err:
+ print "%s (expected symlink %r -> %r)" % (err, linkname, expected)
+ wrong_symlinks.append(linkname)
+ else:
+ if endpoint != expected:
+ print "Wrong symlink: %r -> %r (expected symlink: %r -> %r)" % (linkname, endpoint, linkname, expected)
+ wrong_symlinks.append(linkname)
+
+ if wrong_symlinks:
+ test.fail_test(wrong_symlinks)
+
+ # modify test.c and make sure it can recompile when links already exist
+ test.write('test.c', """\
+ #if _WIN32
+ __declspec(dllexport)
+ #endif
+ int testlib(int n)
+ {
+ return n+11 ;
+ }
+ """)
+
+ test.run()
-test.run()
+ test.run(arguments = ['-c'])
-test.run(arguments = ['-c'])
+ for f in files:
+ test.must_not_exist([ f])
-for f in files:
- test.must_not_exist([ f])
-for f in instfiles:
- test.must_not_exist(['installtest', f])
+ for f in instfiles:
+ test.must_not_exist(['installtest', f])
test.pass_test()