"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "travis/nasm-t.py" between
nasm-2.15.04.tar.xz and nasm-2.15.05.tar.xz

About: NASM (Netwide Assembler) is an 80x86 and x86-64 assembler designed for portability and modularity. It supports a range of object file formats including Linux and *BSD a.out, ELF, COFF, Mach-O, Microsoft 16-bit OBJ, Win32 and Win64. It supports all currently known x86 architectural extensions, and has strong support for macros.

nasm-t.py  (nasm-2.15.04.tar.xz):nasm-t.py  (nasm-2.15.05.tar.xz)
skipping to change at line 37 skipping to change at line 37
help = 'Hexdump executable to use') help = 'Hexdump executable to use')
sp = parser.add_subparsers(dest = 'cmd') sp = parser.add_subparsers(dest = 'cmd')
for cmd in ['run']: for cmd in ['run']:
spp = sp.add_parser(cmd, help = 'Run test cases') spp = sp.add_parser(cmd, help = 'Run test cases')
spp.add_argument('-t', '--test', spp.add_argument('-t', '--test',
dest = 'test', dest = 'test',
help = 'Run the selected test only', help = 'Run the selected test only',
required = False) required = False)
for cmd in ['new']:
spp = sp.add_parser(cmd, help = 'Add a new test case')
spp.add_argument('--description',
dest = 'description', default = "Description of a test",
help = 'Description of a test',
required = False)
spp.add_argument('--id',
dest = 'id',
help = 'Test identifier/name',
required = True)
spp.add_argument('--format',
dest = 'format', default = 'bin',
help = 'Output format',
required = False)
spp.add_argument('--source',
dest = 'source',
help = 'Source file',
required = False)
spp.add_argument('--option',
dest = 'option',
default = '-Ox',
help = 'NASM options',
required = False)
spp.add_argument('--ref',
dest = 'ref',
help = 'Test reference',
required = False)
spp.add_argument('--error',
dest = 'error',
help = 'Set to "y" if test is supposed to fail',
required = False)
spp.add_argument('--output',
dest = 'output', default = 'y',
help = 'Output (compiled) file name (or "y")',
required = False)
spp.add_argument('--stdout',
dest = 'stdout', default = 'y',
help = 'Filename of stdout file (or "y")',
required = False)
spp.add_argument('--stderr',
dest = 'stderr', default = 'y',
help = 'Filename of stderr file (or "y")',
required = False)
for cmd in ['list']: for cmd in ['list']:
spp = sp.add_parser(cmd, help = 'List test cases') spp = sp.add_parser(cmd, help = 'List test cases')
for cmd in ['update']: for cmd in ['update']:
spp = sp.add_parser(cmd, help = 'Update test cases with new compiler') spp = sp.add_parser(cmd, help = 'Update test cases with new compiler')
spp.add_argument('-t', '--test', spp.add_argument('-t', '--test',
dest = 'test', dest = 'test',
help = 'Update the selected test only', help = 'Update the selected test only',
required = False) required = False)
map_fmt_ext = {
'bin': '.bin',
'elf': '.o',
'elf64': '.o',
'elf32': '.o',
'elfx32': '.o',
'ith': '.ith',
'srec': '.srec',
'obj': '.obj',
'win32': '.obj',
'win64': '.obj',
'coff': '.obj',
'macho': '.o',
'macho32': '.o',
'macho64': '.o',
'aout': '.out',
'aoutb': '.out',
'as86': '.o',
'rdf': '.rdf',
}
args = parser.parse_args() args = parser.parse_args()
if args.cmd == None: if args.cmd == None:
parser.print_help() parser.print_help()
sys.exit(1) sys.exit(1)
def read_stdfile(path): def read_stdfile(path):
with open(path, "rb") as f: with open(path, "rb") as f:
data = f.read().decode("utf-8").strip("\n") data = f.read().decode("utf-8").strip("\n")
f.close() f.close()
skipping to change at line 278 skipping to change at line 343
opts += t['option'].split(" ") opts += t['option'].split(" ")
if 'source' in desc: if 'source' in desc:
opts += [desc['_base-dir'] + os.sep + desc['source']] opts += [desc['_base-dir'] + os.sep + desc['source']]
return opts return opts
def exec_nasm(desc): def exec_nasm(desc):
print("\tProcessing %s" % (desc['_test-name'])) print("\tProcessing %s" % (desc['_test-name']))
opts = [args.nasm] + prepare_run_opts(desc) opts = [args.nasm] + prepare_run_opts(desc)
nasm_env = os.environ.copy() nasm_env = os.environ.copy()
nasm_env['NASM_TEST_RUN'] = 'y' nasm_env['NASMENV'] = '--reproducible'
desc_env = desc.get('environ') desc_env = desc.get('environ')
if desc_env: if desc_env:
for i in desc_env: for i in desc_env:
v = i.split('=') v = i.split('=')
if len(v) == 2: if len(v) == 2:
nasm_env[v[0]] = v[1] nasm_env[v[0]] = v[1]
else: else:
nasm_env[v[0]] = None nasm_env[v[0]] = None
skipping to change at line 320 skipping to change at line 385
if stderr != "": if stderr != "":
show_std("stderr", stderr) show_std("stderr", stderr)
test_fail(desc['_test-name'], test_fail(desc['_test-name'],
"Unexpected ret code: " + str(wait_rc)) "Unexpected ret code: " + str(wait_rc))
return None, None, None return None, None, None
return pnasm, stdout, stderr return pnasm, stdout, stderr
def test_run(desc): def test_run(desc):
print("=== Running %s ===" % (desc['_test-name'])) print("=== Running %s ===" % (desc['_test-name']))
if 'disable' in desc:
return test_skip(desc['_test-name'], desc["disable"])
pnasm, stdout, stderr = exec_nasm(desc) pnasm, stdout, stderr = exec_nasm(desc)
if pnasm == None: if pnasm == None:
return False return False
for t in desc['target']: for t in desc['target']:
if 'output' in t: if 'output' in t:
output = desc['_base-dir'] + os.sep + t['output'] output = desc['_base-dir'] + os.sep + t['output']
match = desc['_base-dir'] + os.sep + t['match'] match = desc['_base-dir'] + os.sep + t['match']
if desc['_wait'] == 1: if desc['_wait'] == 1:
continue continue
skipping to change at line 372 skipping to change at line 440
return test_pass(desc['_test-name']) return test_pass(desc['_test-name'])
# #
# Compile sources and generate new targets # Compile sources and generate new targets
def test_update(desc): def test_update(desc):
print("=== Updating %s ===" % (desc['_test-name'])) print("=== Updating %s ===" % (desc['_test-name']))
if 'update' in desc and desc['update'] == 'false': if 'update' in desc and desc['update'] == 'false':
return test_skip(desc['_test-name'], "No output provided") return test_skip(desc['_test-name'], "No output provided")
if 'disable' in desc:
return test_skip(desc['_test-name'], desc["disable"])
pnasm, stdout, stderr = exec_nasm(desc) pnasm, stdout, stderr = exec_nasm(desc)
if pnasm == None: if pnasm == None:
return False return False
for t in desc['target']: for t in desc['target']:
if 'output' in t: if 'output' in t:
output = desc['_base-dir'] + os.sep + t['output'] output = desc['_base-dir'] + os.sep + t['output']
match = desc['_base-dir'] + os.sep + t['match'] match = desc['_base-dir'] + os.sep + t['match']
print("\tMoving %s to %s" % (output, match)) print("\tMoving %s to %s" % (output, match))
skipping to change at line 398 skipping to change at line 468
f.close() f.close()
if 'stderr' in t: if 'stderr' in t:
match = desc['_base-dir'] + os.sep + t['stderr'] match = desc['_base-dir'] + os.sep + t['stderr']
print("\tMoving %s to %s" % ('stderr', match)) print("\tMoving %s to %s" % ('stderr', match))
with open(match, "wb") as f: with open(match, "wb") as f:
f.write(stderr.encode("utf-8")) f.write(stderr.encode("utf-8"))
f.close() f.close()
return test_updated(desc['_test-name']) return test_updated(desc['_test-name'])
#
# Create a new empty test case
if args.cmd == 'new':
#
# If no source provided create one
# from (ID which is required)
if not args.source:
args.source = args.id + ".asm"
#
# Emulate "touch" on source file
path_asm = args.dir + os.sep + args.source
print("\tCreating %s" % (path_asm))
open(path_asm, 'a').close()
#
# Fill the test descriptor
#
# FIXME: We should probably use Jinja
path_json = args.dir + os.sep + args.id + ".json"
print("\tFilling descriptor %s" % (path_json))
with open(path_json, 'wb') as f:
f.write("[\n\t{\n".encode("utf-8"))
acc = []
if args.description:
acc.append("\t\t\"description\": \"{}\"".format(args.description))
acc.append("\t\t\"id\": \"{}\"".format(args.id))
if args.format:
acc.append("\t\t\"format\": \"{}\"".format(args.format))
acc.append("\t\t\"source\": \"{}\"".format(args.source))
if args.option:
acc.append("\t\t\"option\": \"{}\"".format(args.option))
if args.ref:
acc.append("\t\t\"ref\": \"{}\"".format(args.ref))
if args.error == 'y':
acc.append("\t\t\"error\": \"true\"")
f.write(",\n".join(acc).encode("utf-8"))
if args.output or args.stdout or args.stderr:
acc = []
if args.output:
if args.output == 'y':
if args.format in map_fmt_ext:
args.output = args.id + map_fmt_ext[args.format]
acc.append("\t\t\t{{ \"output\": \"{}\" }}".format(args.output))
if args.stdout:
if args.stdout == 'y':
args.stdout = args.id + '.stdout'
acc.append("\t\t\t{{ \"stdout\": \"{}\" }}".format(args.stdout))
if args.stderr:
if args.stderr == 'y':
args.stderr = args.id + '.stderr'
acc.append("\t\t\t{{ \"stderr\": \"{}\" }}".format(args.stderr))
f.write(",\n".encode("utf-8"))
f.write("\t\t\"target\": [\n".encode("utf-8"))
f.write(",\n".join(acc).encode("utf-8"))
f.write("\n\t\t]".encode("utf-8"))
f.write("\n\t}\n]\n".encode("utf-8"))
f.close()
if args.cmd == 'run': if args.cmd == 'run':
desc_array = [] desc_array = []
if args.test == None: if args.test == None:
desc_array = collect_test_desc_from_dir(args.dir) desc_array = collect_test_desc_from_dir(args.dir)
else: else:
desc_array = collect_test_desc_from_file(args.test) desc_array = collect_test_desc_from_file(args.test)
if len(desc_array) == 0: if len(desc_array) == 0:
test_abort(args.test, "Can't obtain test descriptors") test_abort(args.test, "Can't obtain test descriptors")
for desc in desc_array: for desc in desc_array:
 End of changes. 6 change blocks. 
1 lines changed or deleted 130 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)