21 """
22 Execute the test-scripts with required environment variables. It acts like
23 /usr/bin/env, but provides some extra functionality to dynamically set up
24 the environment variables.
25 """
26
27 catch_sigterm()
28
29 os.environ['SRC_ROOT'] = os.path.abspath(
30 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
31 os.environ['FUCHSIA_IMAGES_ROOT'] = os.path.join(os.environ['SRC_ROOT'],
32 'third_party', 'fuchsia',
33 'images')
34 sdk_dir = ''
35 if platform.system() == 'Linux':
36 sdk_dir = 'linux'
37 elif platform.system() == 'Darwin':
38 sdk_dir = 'mac'
39 else:
40 assert False, 'Unsupported OS'
41 os.environ['FUCHSIA_SDK_ROOT'] = os.path.join(os.environ['SRC_ROOT'],
42 'third_party', 'fuchsia',
43 'sdk', sdk_dir)
44
45 os.environ['FUCHSIA_GN_SDK_ROOT'] = os.path.join(os.environ['SRC_ROOT'],
46 'third_party', 'fuchsia',
47 'gn-sdk', 'src')
48
49 with subprocess.Popen(sys.argv[1:]) as proc:
50 try:
51 proc.wait()
52 except:
53
54 proc.terminate()
55 return proc.returncode
56
57