diff options
| author | William Deegan <bill@baddogconsulting.com> | 2015-09-21 17:03:12 (GMT) |
|---|---|---|
| committer | William Deegan <bill@baddogconsulting.com> | 2015-09-21 17:03:12 (GMT) |
| commit | 0941093e0e5a030faa49968457638a3a6aee7ad8 (patch) | |
| tree | 6d33513c14eb6eac0531dd050de0ecca4c39bd79 /test/LINK | |
| download | SCons-2.4.0.zip SCons-2.4.0.tar.gz SCons-2.4.0.tar.bz2 | |
release 2.4.02.4.0
Diffstat (limited to 'test/LINK')
| -rw-r--r-- | test/LINK/LINK.py | 90 | ||||
| -rw-r--r-- | test/LINK/LINKCOM.py | 79 | ||||
| -rw-r--r-- | test/LINK/LINKCOMSTR.py | 97 | ||||
| -rw-r--r-- | test/LINK/LINKFLAGS.py | 91 | ||||
| -rw-r--r-- | test/LINK/SHLINK.py | 88 | ||||
| -rw-r--r-- | test/LINK/SHLINKCOM.py | 95 | ||||
| -rw-r--r-- | test/LINK/SHLINKCOMSTR.py | 119 | ||||
| -rw-r--r-- | test/LINK/SHLINKFLAGS.py | 89 | ||||
| -rw-r--r-- | test/LINK/VersionedLib.py | 164 |
9 files changed, 912 insertions, 0 deletions
diff --git a/test/LINK/LINK.py b/test/LINK/LINK.py new file mode 100644 index 0000000..25d9efb --- /dev/null +++ b/test/LINK/LINK.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os + +import TestSCons + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.write("wrapper.py", +"""import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + +test.write('SConstruct', """ +foo = Environment() +link = foo.subst("$LINK") +bar = Environment(LINK = r'%(_python_)s wrapper.py ' + link) +foo.Program(target = 'foo', source = 'foo.c') +bar.Program(target = 'bar', source = 'bar.c') +""" % locals()) + +test.write('foo.c', r""" +#include <stdio.h> +#include <stdlib.h> +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("foo.c\n"); + exit (0); +} +""") + +test.write('bar.c', r""" +#include <stdio.h> +#include <stdlib.h> +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("foo.c\n"); + exit (0); +} +""") + + +test.run(arguments = 'foo' + _exe) + +test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + +test.run(arguments = 'bar' + _exe) + +test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/LINKCOM.py b/test/LINK/LINKCOM.py new file mode 100644 index 0000000..f09e8f8 --- /dev/null +++ b/test/LINK/LINKCOM.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to configure the $LINKCOM construction variable. +""" + +import TestSCons + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + + + +test.write('mylink.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in [l for l in infile.readlines() if l != '/*link*/\n']: + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LINKCOM = r'%(_python_)s mylink.py $TARGET $SOURCES', + OBJSUFFIX = '.obj', + PROGSUFFIX = '.exe') +env.Program(target = 'test1', source = ['test1.obj', 'test2.obj']) +""" % locals()) + +test.write('test1.obj', """\ +test1.obj +/*link*/ +""") + +test.write('test2.obj', """\ +test2.obj +/*link*/ +""") + +test.run() + +test.must_match('test1.exe', "test1.obj\ntest2.obj\n") + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/LINKCOMSTR.py b/test/LINK/LINKCOMSTR.py new file mode 100644 index 0000000..8fd8adc --- /dev/null +++ b/test/LINK/LINKCOMSTR.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that the $LINKCOMSTR construction variable allows you to customize +the displayed linker string. +""" + +import TestSCons + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + + + +test.write('mylink.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in [l for l in infile.readlines() if l != '/*link*/\n']: + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LINKCOM = r'%(_python_)s mylink.py $TARGET $SOURCES', + LINKCOMSTR = 'Linking $TARGET from $SOURCES', + OBJSUFFIX = '.obj', + PROGSUFFIX = '.exe') +env.Program(target = 'test1', source = ['test1.obj', 'test2.obj']) +""" % locals()) + +test.write('test1.obj', """\ +test1.obj +/*link*/ +""") + +test.write('test2.obj', """\ +test2.obj +/*link*/ +""") + +test.run(stdout = test.wrap_stdout("""\ +Linking test1.exe from test1.obj test2.obj +""")) + +test.must_match('test1.exe', "test1.obj\ntest2.obj\n") + +# Now test an actual compile and link. Since MS Windows +# resets the link actions, this could fail even if the above +# test passed. +test.write('SConstruct', """ +env = Environment(CXXCOMSTR = 'Compiling $TARGET ...', + LINKCOMSTR = 'Linking $TARGET ...') +env.Program('test', 'test.cpp') +""") +test.write('test.cpp', """ +int main(int argc, char **argv) {} +""") + +test.run() +if ("Linking" not in test.stdout()): + test.fail_test() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/LINKFLAGS.py b/test/LINK/LINKFLAGS.py new file mode 100644 index 0000000..442baf7 --- /dev/null +++ b/test/LINK/LINKFLAGS.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os + +import TestSCons + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.write("wrapper.py", +"""import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +args = [s for s in sys.argv[1:] if s != 'fake_link_flag'] +os.system(" ".join(args)) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + +test.write('SConstruct', """ +foo = Environment() +bar = Environment(LINK = foo.subst(r'%(_python_)s wrapper.py $LINK'), + LINKFLAGS = foo.subst('$LINKFLAGS fake_link_flag')) +foo.Program(target = 'foo', source = 'foo.c') +bar.Program(target = 'bar', source = 'bar.c') +""" % locals()) + +test.write('foo.c', r""" +#include <stdio.h> +#include <stdlib.h> +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("foo.c\n"); + exit (0); +} +""") + +test.write('bar.c', r""" +#include <stdio.h> +#include <stdlib.h> +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("foo.c\n"); + exit (0); +} +""") + + +test.run(arguments = 'foo' + _exe) + +test.must_not_exist(test.workpath('wrapper.out')) + +test.run(arguments = 'bar' + _exe) + +test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/SHLINK.py b/test/LINK/SHLINK.py new file mode 100644 index 0000000..bc1239b --- /dev/null +++ b/test/LINK/SHLINK.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os + +import TestSCons + +_python_ = TestSCons._python_ +dll_ = TestSCons.dll_ +_shlib = TestSCons._dll + +test = TestSCons.TestSCons() + +test.write("wrapper.py", +"""import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + +test.write('SConstruct', """ +foo = Environment() +shlink = foo.Dictionary('SHLINK') +bar = Environment(SHLINK = r'%(_python_)s wrapper.py ' + shlink) +foo.SharedLibrary(target = 'foo', source = 'foo.c') +bar.SharedLibrary(target = 'bar', source = 'bar.c') +""" % locals()) + +test.write('foo.c', r""" +#include <stdio.h> + +void +test() +{ + printf("foo.c\n"); + fflush(stdout); +} +""") + +test.write('bar.c', r""" +#include <stdio.h> + +void +test() +{ + printf("foo.c\n"); + fflush(stdout); +} +""") + +test.run(arguments = dll_ + 'foo' + _shlib) + +test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + +test.run(arguments = dll_ + 'bar' + _shlib) + +test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/SHLINKCOM.py b/test/LINK/SHLINKCOM.py new file mode 100644 index 0000000..8bdb9b5 --- /dev/null +++ b/test/LINK/SHLINKCOM.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to configure the $SHLINKCOM construction variable. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + + + +test.write('mycc.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in [l for l in infile.readlines() if l != '/*cc*/\n']: + outfile.write(l) +sys.exit(0) + +""") +test.write('mylink.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in [l for l in infile.readlines() if l != '/*link*/\n']: + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(SHCCCOM = r'%(_python_)s mycc.py $TARGET $SOURCES', + SHLINKCOM = r'%(_python_)s mylink.py $TARGET $SOURCES', + SHOBJSUFFIX = '.obj', + SHLIBPREFIX = '', + SHLIBSUFFIX = '.dll') +t1 = env.SharedObject('test1', 'test1.c') +t2 = env.SharedObject('test2', 'test2.c') +env.SharedLibrary(target = 'test3', source = [t1, t2]) +""" % locals()) + +test.write('test1.c', """\ +test1.c +/*cc*/ +/*link*/ +""") + +test.write('test2.c', """\ +test2.c +/*cc*/ +/*link*/ +""") + +test.run() + +test.must_match('test3.dll', "test1.c\ntest2.c\n") + + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/SHLINKCOMSTR.py b/test/LINK/SHLINKCOMSTR.py new file mode 100644 index 0000000..db40732 --- /dev/null +++ b/test/LINK/SHLINKCOMSTR.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that the $SHLINKCOMSTR construction variable allows you to customize +the displayed linker string for programs using shared libraries. +""" + +import sys +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + + + +test.write('mycc.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in [l for l in infile.readlines() if l != '/*cc*/\n']: + outfile.write(l) +sys.exit(0) + +""") +test.write('mylink.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in [l for l in infile.readlines() if l != '/*link*/\n']: + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(SHCCCOM = r'%(_python_)s mycc.py $TARGET $SOURCES', + SHLINKCOM = r'%(_python_)s mylink.py $TARGET $SOURCES', + SHLINKCOMSTR = 'Linking shared $TARGET from $SOURCES', + SHOBJPREFIX = '', + SHOBJSUFFIX = '.obj', + SHLIBPREFIX = '', + SHLIBSUFFIX = '.dll') +t1 = env.SharedObject('test1', 'test1.c') +t2 = env.SharedObject('test2', 'test2.c') +env.SharedLibrary(target = 'test3', source = [t1, t2]) +""" % locals()) + +test.write('test1.c', """\ +test1.c +/*cc*/ +/*link*/ +""") + +test.write('test2.c', """\ +test2.c +/*cc*/ +/*link*/ +""") + +test.run(stdout = test.wrap_stdout("""\ +%(_python_)s mycc.py test1.obj test1.c +%(_python_)s mycc.py test2.obj test2.c +Linking shared test3.dll from test1.obj test2.obj +""" % locals())) + +test.must_match('test3.dll', "test1.c\ntest2.c\n") + +if sys.platform == "win32": + import SCons.Tool.MSCommon as msc + if msc.msvc_exists(): + # Now test an actual compile and link. Since MS Windows + # resets the link actions, this could fail even if the above + # test passed. + test.write('SConstruct', """ +env = Environment(CXXCOMSTR = 'Compiling $TARGET ...', + SHLINKCOMSTR = 'Shared-Linking $TARGET ...') +env.SharedLibrary('test', 'test.cpp') +""") + test.write('test.cpp', """ +int i; +""") + + test.run() + if ("Shared-Linking" not in test.stdout()): + test.fail_test() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/SHLINKFLAGS.py b/test/LINK/SHLINKFLAGS.py new file mode 100644 index 0000000..57766de --- /dev/null +++ b/test/LINK/SHLINKFLAGS.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os + +import TestSCons + +_python_ = TestSCons._python_ +lib_ = TestSCons.dll_ +_shlib = TestSCons._dll + +test = TestSCons.TestSCons() + +test.write("wrapper.py", +"""import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +args = [s for s in sys.argv[1:] if s != 'fake_shlink_flag'] +os.system(" ".join(args)) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + +test.write('SConstruct', """ +foo = Environment() +bar = Environment(SHLINK = foo.subst(r'%(_python_)s wrapper.py $SHLINK'), + SHLINKFLAGS = foo.subst('$SHLINKFLAGS fake_shlink_flag')) +foo.SharedLibrary(target = 'foo', source = 'foo.c') +bar.SharedLibrary(target = 'bar', source = 'bar.c') +""" % locals()) + +test.write('foo.c', r""" +#include <stdio.h> + +void +test() +{ + printf("foo.c\n"); + fflush(stdout); +} +""") + +test.write('bar.c', r""" +#include <stdio.h> + +void +test() +{ + printf("foo.c\n"); + fflush(stdout); +} +""") + +test.run(arguments = lib_ + 'foo' + _shlib) + +test.must_not_exist(test.workpath('wrapper.out')) + +test.run(arguments = lib_ + 'bar' + _shlib) + +test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py new file mode 100644 index 0000000..a2345d6 --- /dev/null +++ b/test/LINK/VersionedLib.py @@ -0,0 +1,164 @@ +#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import sys
+import TestSCons
+
+import SCons.Platform
+
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """\
+import os
+env = Environment()
+objs = env.SharedObject('test.c')
+mylib = env.SharedLibrary('test', objs, SHLIBVERSION = '2.5.4')
+env.Program(source=['testapp.c',mylib])
+env.Program(target=['testapp2'],source=['testapp.c','libtest.dylib'])
+instnode = env.InstallVersionedLib("#/installtest",mylib)
+env.Default(instnode)
+""")
+
+test.write('test.c', """\
+#if _WIN32
+__declspec(dllexport)
+#endif
+int testlib(int n)
+{
+return n+1 ;
+}
+""")
+
+test.write('testapp.c', """\
+#include <stdio.h>
+int main(int argc, char **argv)
+{
+int itest ;
+
+itest = testlib(2) ;
+printf("results: testlib(2) = %d\n",itest) ;
+return 0 ;
+}
+""")
+
+platform = SCons.Platform.platform_default()
+
+
+test.run()
+
+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',
+ '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',
+ ]
+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',
+ ]
+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.run()
+
+test.run(arguments = '-c')
+
+for f in files:
+ test.must_not_exist([ f])
+for f in instfiles:
+ test.must_not_exist(['installtest', f])
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
|
