if nasm:
+ # Allow flexibility about the type of object/executable format
+ # needed on different systems. Format_map is a dict that maps
+ # sys.platform substrings to the correct argument for the nasm -f
+ # option. The default is "elf," which seems to be a reasonable
+ # lowest common denominator (works on both Linux and FreeBSD,
+ # anyway...).
+ nasm_format = 'elf'
+ format_map = {}
+ for k, v in format_map.items():
+ if string.find(sys.platform, k) != -1:
+ nasm_format = v
+ break
+
test.write("wrapper.py",
"""import os
import string
test.write('SConstruct', """
eee = Environment(tools = ['gcc', 'gnulink', 'nasm'],
- ASFLAGS = '-f aout')
+ ASFLAGS = '-f %s')
fff = eee.Copy(AS = r'%s wrapper.py ' + WhereIs('nasm'))
eee.Program(target = 'eee', source = ['eee.asm', 'eee_main.c'])
fff.Program(target = 'fff', source = ['fff.asm', 'fff_main.c'])
-""" % python)
+""" % (nasm_format, python))
test.write('eee.asm',
"""
PRINT *, 'b2.for'
""")
-test.run(chdir='work1', arguments = '. ../build')
+# Some releases of freeBSD seem to have library complaints about
+# tempnam(). Filter out these annoying messages before checking for
+# error output.
+def blank_output(err):
+ if not err:
+ return 1
+ stderrlines = filter(lambda l: l, string.split(err, '\n'))
+ msg = "warning: tempnam() possibly used unsafely"
+ stderrlines = filter(lambda l, msg=msg: string.find(l, msg) == -1,
+ stderrlines)
+ return len(stderrlines) == 0
+
+test.run(chdir='work1', arguments = '. ../build', stderr=None)
+
+test.fail_test(not blank_output(test.stderr()))
test.run(program = foo11, stdout = "f1.c\n")
test.run(program = foo12, stdout = "f2.c\n")
#define F4_STR "f4.c 2\n"
""")
-test.run(chdir='work1', arguments = '../build/var5')
+test.run(chdir='work1', arguments = '../build/var5', stderr=None)
+
+test.fail_test(not blank_output(test.stderr()))
test.run(program = foo51, stdout = "f1.c 2\n")
test.run(program = test.workpath('build', 'var5', 'foo3' + _exe),
env.Program('prog.c')
""")
-test.run(chdir='work2', arguments='.')
+test.run(chdir='work2', arguments='.', stderr=None)
+
+test.fail_test(not blank_output(test.stderr()))
test.up_to_date(chdir='work2', arguments='.')
""")
test.pass_test()
-
stderr = None,
status = 2)
-bad_command = "Bad command or file name\n"
+bad_command = """\
+Bad command or file name
+"""
-unrecognized = """'%s' is not recognized as an internal or external command,
+unrecognized = """\
+'%s' is not recognized as an internal or external command,
operable program or batch file.
scons: *** [%s] Error 1
"""
-unspecified = """The name specified is not recognized as an
+unspecified = """\
+The name specified is not recognized as an
internal or external command, operable program or batch file.
scons: *** [%s] Error 1
"""
+not_found_1 = """
+sh: %s: not found
+scons: *** [%s] Error 1
+"""
+
+not_found_2 = """
+sh: %s: not found
+scons: *** [%s] Error 1
+"""
+
+No_such = """\
+%s: No such file or directory
+scons: *** [%s] Error 127
+"""
+
+cannot_execute = """\
+%s: cannot execute
+scons *** [%s] Error 126
+"""
+
+Permission_denied = """\
+%s: Permission denied
+scons: *** [%s] Error 126
+"""
+
+permission_denied = """\
+%s: permission denied
+scons: *** [%s] Error 126
+"""
+
+is_a_directory = """\
+%s: is a directory
+scons: *** [%s] Error 126
+"""
+
test.description_set("Incorrect STDERR:\n%s\n" % test.stderr())
if os.name == 'nt':
errs = [
unspecified % 'f1'
]
test.fail_test(not test.stderr() in errs)
-elif string.find(sys.platform, 'irix') != -1:
- test.fail_test(test.stderr() != """sh: %s: not found
-scons: *** [f1] Error 127
-""" % no_such_file)
else:
- test.fail_test(string.find(test.stderr(), """%s: No such file or directory
-scons: *** [f1] Error 127
-""" % no_such_file) == -1)
-
+ errs = [
+ not_found_1 % (no_such_file, 'f1'),
+ not_found_2 % (no_such_file, 'f1'),
+ No_such % (no_such_file, 'f1'),
+ ]
+ error_message_not_found = 1
+ for err in errs:
+ if string.find(test.stderr(), err) != -1:
+ error_message_not_found = None
+ break
+ test.fail_test(error_message_not_found)
test.write('SConstruct2', r"""
bld = Builder(action = '%s $SOURCES $TARGET')
unspecified % 'f2'
]
test.fail_test(not test.stderr() in errs)
-elif string.find(sys.platform, 'irix') != -1:
- test.fail_test(test.stderr() != """sh: %s: cannot execute
-scons: *** [f2] Error 126
-""" % not_executable)
else:
- test.fail_test(string.find(test.stderr(), """%s: Permission denied
-scons: *** [f2] Error 126
-""" % not_executable) == -1)
+ errs = [
+ cannot_execute % (not_executable, 'f2'),
+ Permission_denied % (not_executable, 'f2'),
+ permission_denied % (not_executable, 'f2'),
+ ]
+ error_message_not_found = 1
+ for err in errs:
+ if string.find(test.stderr(), err) != -1:
+ error_message_not_found = None
+ break
+ test.fail_test(error_message_not_found)
test.write('SConstruct3', r"""
bld = Builder(action = '%s $SOURCES $TARGET')
unspecified % 'f3'
]
test.fail_test(not test.stderr() in errs)
-elif string.find(sys.platform, 'irix') != -1:
- test.fail_test(test.stderr() != """sh: %s: cannot execute
-scons: *** [f3] Error 126
-""" % test.workdir)
else:
- test.fail_test(string.find(test.stderr(), """%s: is a directory
-scons: *** [f3] Error 126
-""" % test.workdir) == -1)
+ errs = [
+ cannot_execute % (not_executable, 'f3'),
+ is_a_directory % (test.workdir, 'f3'),
+ ]
+ error_message_not_found = 1
+ for err in errs:
+ if string.find(test.stderr(), err) != -1:
+ error_message_not_found = None
+ break
+ test.fail_test(error_message_not_found)
test.pass_test()