270,271c270
< (category, mode, name, _ref, isa, opsys, config) = ref_dir.split('/')
< assert(_ref == 'ref')
---
> path = list(ref_dir.split('/'))
273,275c272,275
< # target path (where test output goes) is the same except without
< # the 'ref' component
< tgt_dir = os.path.join(category, mode, name, isa, opsys, config)
---
> # target path (where test output goes) consists of category, mode,
> # name, isa, opsys, and config (skips the 'ref' component)
> assert(path.pop(-4) == 'ref')
> tgt_dir = os.path.join(*path[-6:])
277c277
< # prepend file name with tgt_dir
---
> # local closure for prepending target path to filename
345,346c345
< cwd = os.getcwd()
< os.chdir(str(Dir('.').srcdir))
---
> src = Dir('.').srcdir
348c347
< dirs = glob.glob('*/*/*/ref/%s/*/%s' % (env['TARGET_ISA'], config))
---
> dirs = src.glob('*/*/*/ref/%s/*/%s' % (env['TARGET_ISA'], config))
349a349
> d = str(d)
352d351
< os.chdir(cwd)