diff options
Diffstat (limited to 'test/Win32')
-rw-r--r-- | test/Win32/default-drive.py | 71 | ||||
-rw-r--r-- | test/Win32/mingw.py | 203 | ||||
-rw-r--r-- | test/Win32/scons-bat-error.py | 84 | ||||
-rw-r--r-- | test/Win32/win32pathmadness.py | 148 |
4 files changed, 506 insertions, 0 deletions
diff --git a/test/Win32/default-drive.py b/test/Win32/default-drive.py new file mode 100644 index 0000000..94d8377 --- /dev/null +++ b/test/Win32/default-drive.py @@ -0,0 +1,71 @@ +#!/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. +# + +""" +This test verifies (on Windows systems) that specifying an +absolute path name without a drive letter uses the SConstruct +file's drive as the default. +""" + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import os.path +import string +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +if sys.platform != 'win32': + msg = "Skipping drive-letter test on non-Windows platform '%s'\n" % sys.platform + test.skip_test(msg) + +test.subdir('src') + +test.write(['src', 'SConstruct'], """ +def cat(env, source, target): + target = str(target[0]) + source = map(str, source) + f = open(target, "wb") + for src in source: + f.write(open(src, "rb").read()) + f.close() + +env = Environment(BUILDERS={'Build':Builder(action=cat)}) +env.Build('../build/file.out', 'file.in') +""") + +test.write(['src', 'file.in'], "src/file.in\n") + +build_file_out = test.workpath('build', 'file.out') + +print os.path.splitdrive(build_file_out)[1] +test.run(chdir = 'src', + arguments = os.path.splitdrive(build_file_out)[1]) + +test.must_match(['build', 'file.out'], "src/file.in\n") + +test.pass_test() diff --git a/test/Win32/mingw.py b/test/Win32/mingw.py new file mode 100644 index 0000000..fac8910 --- /dev/null +++ b/test/Win32/mingw.py @@ -0,0 +1,203 @@ +""" +This tests the MinGW C/C++ compiler support. +""" + +#!/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 TestSCons +import sys +import os.path +import os +import TestCmd +import time +import string + +test = TestSCons.TestSCons(match = TestCmd.match_re_dotall) + +# MinGW is Windows only: +if sys.platform != 'win32': + msg = "Skipping mingw test on non-Windows platform '%s'\n" % sys.platform + test.skip_test(msg) + +# This test requires MinGW to be installed: +test.write('SConstruct',""" +from SCons.Tool.mingw import exists +import sys +env = Environment() +if exists(env): + print 'mingw exists' +sys.exit(0) +""") + +test.run() +if string.find(test.stdout(), 'mingw exists') == -1: + test.skip_test("No MinGW on this system, skipping test.\n") + +test.subdir('header') + +# Do the actual testing: +test.write('SConstruct',""" +env=Environment(tools=['mingw']) +assert env['CC'] == 'gcc' +env.StaticLibrary('static', 'static.cpp') +env.SharedLibrary('shared', 'shared.cpp') +env.SharedLibrary('cshared', ['cshared.c', 'cshared.def']) +env.Program('test', ['test.cpp', env.RES('resource.rc', CPPPATH=['header'])], LIBS=['static', 'shared', 'cshared'], LIBPATH=['.']) +""") + +test.write('test.cpp', ''' +#include <stdio.h> +#include <windows.h> +#include "resource.h" + +void shared_func(void); +void static_func(void); +extern "C" void cshared_func(void); + +int main(void) +{ + printf("%s\\n", "test.cpp"); + shared_func(); + static_func(); + cshared_func(); + + char test[1024]; + LoadString(GetModuleHandle(NULL), IDS_TEST, test, sizeof(test)); + printf("%d %s\\n", IDS_TEST, test); + + return 0; +} +''') + +test.write('resource.rc', ''' +#include "resource.h" +#include <resource2.h> + +STRINGTABLE DISCARDABLE +BEGIN + IDS_TEST RESOURCE_RC +END +''') + +test.write('resource.h', ''' +#define IDS_TEST 2001 +''') + +test.write('static.cpp', ''' +#include <stdio.h> + +void static_func(void) +{ + printf("%s\\n", "static.cpp"); +} +''') + +test.write('shared.cpp', ''' +#include <stdio.h> + +void shared_func(void) +{ + printf("%s\\n", "shared.cpp"); +} +''') + +test.write('cshared.c', ''' +#include <stdio.h> + +void cshared_func(void) +{ + printf("%s\\n", "cshared.c"); +} +''') + +test.write('cshared.def', ''' +EXPORTS +cshared_func +''') + + + +test.write('header/resource2.h', ''' +#define RESOURCE_RC "resource.rc" +''') + +# the mingw linker likes to print "Creating library file: libfoo.a" to stderr, but +# we'd like for this test to pass once this bug is fixed, so match anything at all +# that comes out of stderr: +test.run(arguments='test.exe', stderr='.*') +# ensure the source def for cshared.def got used, and there wasn't a target def for chshared.dll: +test.fail_test(string.find(test.stdout(), 'cshared.def') == -1) +test.fail_test(string.find(test.stdout(), '-Wl,--output-def,cshared.def') != -1) +# ensure the target def got generated for the shared.dll: +test.fail_test(not os.path.exists(test.workpath('shared.def'))) +test.run(program=test.workpath('test.exe'), stdout='test.cpp\nshared.cpp\nstatic.cpp\ncshared.c\n2001 resource.rc\n') + +# ensure that modifying the header causes the resource to be rebuilt: +test.write('resource.h', ''' +#define IDS_TEST 2002 +''') +test.run(arguments='test.exe', stderr='.*') +test.run(program=test.workpath('test.exe'), stdout='test.cpp\nshared.cpp\nstatic.cpp\ncshared.c\n2002 resource.rc\n') + +# Test with specifying the default tool to make sure msvc setting doen't ruin it +# for mingw: +test.write('SConstruct',""" +env=Environment(tools=['default', 'mingw']) +assert env['CC'] == 'gcc' +env.SharedLibrary('shared', 'shared.cpp') +env.Program('test', 'test.cpp', LIBS=['static', 'shared', 'cshared'], LIBPATH=['.']) +""") + +test.write('test.cpp', ''' +#include <stdio.h> + +void shared_func(void); + +int main(void) +{ + printf("%s\\n", "test.cpp2"); + shared_func(); + return 0; +} +''') + +test.write('shared.cpp', ''' +#include <stdio.h> + +void shared_func(void) +{ + printf("%s\\n", "shared.cpp2"); +} +''') + +# the mingw linker likes to print "Creating library file: libfoo.a" to stderr, but +# we'd like for this test to pass once this bug is fixed, so match anything at all +# that comes out of stderr: +test.run(arguments='test.exe', stderr='.*') +test.run(program=test.workpath('test.exe'), stdout='test.cpp2\nshared.cpp2\n') + +test.pass_test() diff --git a/test/Win32/scons-bat-error.py b/test/Win32/scons-bat-error.py new file mode 100644 index 0000000..d39858b --- /dev/null +++ b/test/Win32/scons-bat-error.py @@ -0,0 +1,84 @@ +#!/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. +# + +""" +Verify that the scons.bat file returns error codes as we expect. +""" + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +if sys.platform != 'win32': + msg = "Skipping scons.bat test on non-Windows platform '%s'\n" % sys.platform + test.skip_test(msg) + +python = test.where_is('python') + +if not python: + msg = "Skipping scons.bat test; python is not on %PATH%.\n" + test.skip_test(msg) + +scons_bat = os.path.splitext(test.program)[0] + '.bat' + +if not os.path.exists(scons_bat): + msg = "Skipping scons.bat test; %s does not exist.\n" % scons_bat + test.skip_test(msg) + +test.write('scons.bat', test.read(scons_bat)) + +# The scons.bat file tries to import SCons.Script from its sys.prefix +# directories first (i.e., site-packages) which means this test might +# end up using an installed SCons in preference to something local. +# If so, create a SConstruct file that will exit with our expected +# error status. If there is *not* an installed SCons, we still want +# this test to work, so we make a "SCons" package in the local +# directory with a Script.py module that contains a main() function +# that just exits with the expected status. + +test.subdir('SCons') + +test.write(['SCons', '__init__.py'], "") + +test.write(['SCons', 'Script.py'], """\ +import sys +def main(): + sys.exit(7) +""") + +test.write('SConstruct', """\ +import sys +sys.exit(7) +""") + +test.run(program = 'scons.bat', status = 7) + + + +test.pass_test() diff --git a/test/Win32/win32pathmadness.py b/test/Win32/win32pathmadness.py new file mode 100644 index 0000000..df350eb --- /dev/null +++ b/test/Win32/win32pathmadness.py @@ -0,0 +1,148 @@ +#!/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. +# + +""" +This test verifies that the build command signatures do not depend on +the case of the drive letter on Windows. This is important because Windows is +inconsistent about which case is used for the drive letter. +""" + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons +import sys +import TestCmd +import string +import os.path + +test = TestSCons.TestSCons(match=TestCmd.match_re) + +if sys.platform != 'win32': + msg = "Skipping Windows path tests on non-Windows platform '%s'\n" % sys.platform + test.skip_test(msg) + +test.subdir('src', 'build', 'include', 'src2') + +test.write('src/SConstruct', """ +env=Environment(LIBS=['../build/foo'], CPPPATH=['../include'], CCCOM='$CC $CCFLAGS $CPPFLAGS $_CPPINCFLAGS /c ${SOURCES.abspath} /Fo$TARGET') +foo=env.Object('../build/foo', 'foo.c') +Default(env.Library('../build/foo', foo)) +Default(env.SharedLibrary('../build/bar', 'bar.c')) +Default(env.Program('../build/bar', ['main.c', '../src2/blat.c', '../build/bar.lib'])) +""") + +test.write('src/foo.c', """ +int foo(void) +{ + return 1; +} +""") + +test.write('src/bar.c', """ +__declspec(dllexport) int bar(void) +{ + return 1; +} +""") + +test.write('src/main.c', """ +#include <bar.h> +int main(void) +{ + return 1; +} +""") + +test.write('src2/blat.c', """ +int blat(void) +{ + return 1; +} +""") + +test.write('include/bar.h', """ +int foo(void); +int blat(void); +int bar(void); +""") + +drive, rest = os.path.splitdrive(test.workpath('src')) + +drive_upper = string.upper(drive) +drive_lower = string.lower(drive) +rest_upper = rest[0] + string.upper(rest[1]) + rest[2:] +rest_lower = rest[0] + string.lower(rest[1]) + rest[2:] + +combinations = [ + os.path.join(drive_upper, rest_upper), + os.path.join(drive_upper, rest_lower), + os.path.join(drive_lower, rest_upper), + os.path.join(drive_lower, rest_lower), +] + +test.run(chdir=combinations[0]) + +for dir in combinations[1:]: + test.run(chdir=dir, stdout=test.wrap_stdout("""\ +scons: .* is up to date. +scons: .* is up to date. +scons: .* is up to date. +""")) + + + +test.write('SConstruct', """ +env=Environment() +env.StaticLibrary('a', 'a.c') +env.StaticLibrary('b', 'b.c') +""") + +test.write('a.c', ''' +#include "a.h" +#include "b.h" +''') + +test.write('b.c', ''' +#include "a.h" +#include "B.h" +''') + +test.write('a.h', """ +#define A_H +""") + +test.write('b.h', """ +#define B_H +""") + +test.run(arguments='a.lib b.lib') +test.run(arguments='b.lib a.lib', stdout=test.wrap_stdout("""\ +scons: .* is up to date. +scons: .* is up to date. +""")) + + + +test.pass_test() + |