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 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Verify correct use of the live 'nasm' assembler.
37 _python_ = TestSCons._python_
40 test = TestSCons.TestSCons()
42 nasm = test.where_is('nasm')
45 test.skip_test('nasm not found; skipping test\n')
47 if string.find(sys.platform, 'linux') == -1:
48 test.skip_test("skipping test on non-Linux platform '%s'\n" % sys.platform)
52 stdout = popen2.popen2('nasm -v')[0]
54 test.skip_test('could not determine nasm version; skipping test\n')
56 version = string.split(stdout.read())[2]
57 if version[:4] != '0.98':
58 test.skip_test("skipping test of nasm version %s\n" % version)
60 machine = os.uname()[4]
61 if not machine in ('i386', 'i486', 'i586', 'i686'):
62 fmt = "skipping test of nasm %s on non-x86 machine '%s'\n"
63 test.skip_test(fmt % (version, machine))
65 # Allow flexibility about the type of object/executable format
66 # needed on different systems. Format_map is a dict that maps
67 # sys.platform substrings to the correct argument for the nasm -f
68 # option. The default is "elf," which seems to be a reasonable
69 # lowest common denominator (works on both Linux and FreeBSD,
73 for k, v in format_map.items():
74 if string.find(sys.platform, k) != -1:
78 test.write("wrapper.py",
82 open('%s', 'wb').write("wrapper.py\\n")
83 os.system(string.join(sys.argv[1:], " "))
84 """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
86 test.write('SConstruct', """
87 eee = Environment(tools = ['gcc', 'gnulink', 'nasm'],
88 ASFLAGS = '-f %(nasm_format)s')
89 fff = eee.Clone(AS = r'%(_python_)s wrapper.py ' + WhereIs('nasm'))
90 eee.Program(target = 'eee', source = ['eee.asm', 'eee_main.c'])
91 fff.Program(target = 'fff', source = ['fff.asm', 'fff_main.c'])
101 test.write('fff.asm',
108 test.write('eee_main.c', r"""
112 main(int argc, char *argv[])
115 printf("eee_main.c %s\n", name);
120 test.write('fff_main.c', r"""
127 main(int argc, char *argv[])
130 printf("fff_main.c %s\n", name);
135 test.run(arguments = 'eee' + _exe, stderr = None)
137 test.run(program = test.workpath('eee'), stdout = "eee_main.c eee.asm\n")
139 test.must_not_exist('wrapper.out')
141 test.run(arguments = 'fff' + _exe)
143 test.run(program = test.workpath('fff'), stdout = "fff_main.c fff.asm\n")
145 test.must_match('wrapper.out', "wrapper.py\n")
153 # indent-tabs-mode:nil
155 # vim: set expandtab tabstop=4 shiftwidth=4: