python_code
stringlengths 0
679k
| repo_name
stringlengths 9
41
| file_path
stringlengths 6
149
|
|---|---|---|
#!/usr/bin/env python3
import os
import sys
assert(os.environ['TEST_VAR'] == sys.argv[1])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/68 test env value/test.py
|
#!/usr/bin/env python3
import os
import sys
import subprocess
environ = os.environ.copy()
environ['PKG_CONFIG_LIBDIR'] = os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'cross_pkgconfig')
sys.exit(
subprocess.run(['pkg-config'] + sys.argv[1:], env=environ).returncode)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig.py
|
#!/usr/bin/env python3
import os
import pathlib
import sys
if len(sys.argv) < 3:
sys.exit('usage: replacer.py <pattern> <replacement>')
source_root = pathlib.Path(os.environ['MESON_DIST_ROOT'])
modfile = source_root / 'prog.c'
contents = modfile.read_text()
contents = contents.replace(sys.argv[1], sys.argv[2])
modfile.write_text(contents)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/35 dist script/replacer.py
|
#!/usr/bin/env python3
import os
import pathlib
import sys
assert sys.argv[1] == 'success'
source_root = pathlib.Path(os.environ['MESON_PROJECT_DIST_ROOT'])
modfile = source_root / 'prog.c'
with modfile.open('w') as f:
f.write('int main(){return 0;}')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/35 dist script/subprojects/sub/dist-script.py
|
#!/usr/bin/env python3
# Test that the MESON_EXE_WRAPPER environment variable is set
import argparse
import os
import sys
def main():
parser = argparse.ArgumentParser()
parser.add_argument('binary') # unused, but needed for test behavior
parser.add_argument('--expected', action='store_true')
args = parser.parse_args()
defined = 'MESON_EXE_WRAPPER' in os.environ
if args.expected != defined:
print(os.environ, file=sys.stderr)
return 1
return 0
if __name__ == "__main__":
sys.exit(main())
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/71 cross test passed/exewrapper.py
|
#!/usr/bin/env python3
import subprocess
import sys
if __name__ == "__main__":
sys.exit(subprocess.run(sys.argv[1:]).returncode)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/71 cross test passed/script.py
|
#!/usr/bin/env python3
import os
assert('PATH' in os.environ)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/2 testsetups/envcheck.py
|
#!/usr/bin/env python3
print('c')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/59 introspect buildoptions/c_compiler.py
|
#! /usr/bin/env python3
import sys
from shutil import copyfile
copyfile(*sys.argv[1:])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/57 introspection/cp.py
|
#!/usr/bin/env python
import sys
import tachyon
result = tachyon.phaserize('shoot')
if not isinstance(result, int):
print('Returned result not an integer.')
sys.exit(1)
if result != 1:
print('Returned result {} is not 1.'.format(result))
sys.exit(1)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/39 python extmodule/blaster.py
|
#!/usr/bin/env python3
import subprocess, sys, platform
# Meson does not yet support Studio cc on Solaris, only gcc or clang
if platform.system() == 'SunOS':
cc = 'gcc'
else:
cc = 'cc'
subprocess.call([cc, "-DEXTERNAL_HOST"] + sys.argv[1:])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/61 identity cross/host_wrapper.py
|
#!/usr/bin/env python3
import subprocess, sys, platform
# Meson does not yet support Studio cc on Solaris, only gcc or clang
if platform.system() == 'SunOS':
cc = 'gcc'
else:
cc = 'cc'
subprocess.call([cc, "-DEXTERNAL_BUILD"] + sys.argv[1:])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/61 identity cross/build_wrapper.py
|
#! /usr/bin/python
import os
assert(os.environ['MESON_DEVENV'] == '1')
assert(os.environ['MESON_PROJECT_NAME'] == 'devenv')
assert(os.environ['TEST_A'] == '1')
assert(os.environ['TEST_B'] == '1+2+3')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/91 devenv/test-devenv.py
|
#!/usr/bin/env python3
import os
assert('ENV_A' in os.environ)
assert('ENV_B' in os.environ)
assert('ENV_C' in os.environ)
print('ENV_A is', os.environ['ENV_A'])
print('ENV_B is', os.environ['ENV_B'])
print('ENV_C is', os.environ['ENV_C'])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/unit/49 testsetup default/envcheck.py
|
#!/usr/bin/env python3
"""Test script that checks if zlib was statically linked to executable"""
import subprocess
import sys
def handle_common(path):
"""Handle the common case."""
output = subprocess.check_output(['nm', path]).decode('utf-8')
if 'T zlibVersion' in output:
return 0
return 1
def handle_cygwin(path):
"""Handle the Cygwin case."""
output = subprocess.check_output(['nm', path]).decode('utf-8')
if (('I __imp_zlibVersion' in output) or ('D __imp_zlibVersion' in output)):
return 1
return 0
def main():
"""Main function"""
if len(sys.argv) > 2 and sys.argv[1] == '--platform=cygwin':
return handle_cygwin(sys.argv[2])
else:
return handle_common(sys.argv[2])
if __name__ == '__main__':
sys.exit(main())
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/linuxlike/14 static dynamic linkage/verify_static.py
|
import shutil
import sys
if __name__ == '__main__':
shutil.copy(sys.argv[1], sys.argv[2])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/linuxlike/3 linker script/copy.py
|
#!/usr/bin/env python3
from storer import Storer
import sys
s = Storer()
if s.get_value() != 0:
print('Initial value incorrect.')
sys.exit(1)
s.set_value(42)
if s.get_value() != 42:
print('Setting value failed.')
sys.exit(1)
try:
s.set_value('not a number')
print('Using wrong argument type did not fail.')
sys.exit(1)
except TypeError:
pass
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python3/3 cython/cytest.py
|
#!/usr/bin/env python3
from gluon import gluonator
import sys
print('Running mainprog from root dir.')
if gluonator.gluoninate() != 42:
sys.exit(1)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python3/1 basic/prog.py
|
#!/usr/bin/env python3
# In order to run this program, PYTHONPATH must be set to
# point to source root.
from gluon import gluonator
import sys
print('Running mainprog from subdir.')
if gluonator.gluoninate() != 42:
sys.exit(1)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python3/1 basic/subdir/subprog.py
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python3/1 basic/gluon/__init__.py
|
|
def gluoninate():
return 42
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python3/1 basic/gluon/gluonator.py
|
#!/usr/bin/env python3
import os
import sys
import argparse
from pathlib import Path
filedir = Path(os.path.dirname(__file__)).resolve()
if list(filedir.glob('ext/*tachyon.*')):
sys.path.insert(0, (filedir / 'ext').as_posix())
import tachyon
parser = argparse.ArgumentParser()
parser.add_argument('-o', dest='output', default=None)
options = parser.parse_args(sys.argv[1:])
result = tachyon.phaserize('shoot')
if options.output:
with open(options.output, 'w') as f:
f.write('success')
if not isinstance(result, int):
print('Returned result not an integer.')
sys.exit(1)
if result != 1:
print(f'Returned result {result} is not 1.')
sys.exit(1)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python3/4 custom target depends extmodule/blaster.py
|
#!/usr/bin/env python3
import tachyon
import sys
result = tachyon.phaserize('shoot')
if not isinstance(result, int):
print('Returned result not an integer.')
sys.exit(1)
if result != 1:
print(f'Returned result {result} is not 1.')
sys.exit(1)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python3/2 extmodule/blaster.py
|
#!/usr/bin/env python3
import subprocess
import sys
subprocess.run(sys.argv[1:])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/native/5 install script/wrap.py
|
#!/usr/bin/env python3
import sys, subprocess
prog, infile, outfile = sys.argv[1:]
subprocess.check_call([prog, infile, outfile])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/native/3 pipeline/depends/copyrunner.py
|
with open('main.c', 'w') as fp:
print('''
#include <stdio.h>
int main(void) {
printf(\"Hello World\");
return 0;
}
''', file=fp)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/cmake/11 cmake_module_path/subprojects/cmMod/gen.py
|
#!/usr/bin/env python3
import os
import shutil
if 'CI' in os.environ or shutil.which('pkg-config'):
print('yes')
else:
print('no')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/osx/2 library versions/require_pkgconfig.py
|
#!/usr/bin/env python3
from storer import Storer
s = Storer()
if s.get_value() != 0:
raise SystemExit('Initial value incorrect.')
s.set_value(42)
if s.get_value() != 42:
raise SystemExit('Setting value failed.')
try:
s.set_value('not a number')
raise SystemExit('Using wrong argument type did not fail.')
except TypeError:
pass
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python/3 cython/cytest.py
|
#!/usr/bin/env python3
from gluon import gluonator
print('Running mainprog from root dir.')
if gluonator.gluoninate() != 42:
raise ValueError("!= 42")
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python/1 basic/prog.py
|
#!/usr/bin/env python3
# In order to run this program, PYTHONPATH must be set to
# point to source root.
from gluon import gluonator
print('Running mainprog from subdir.')
if gluonator.gluoninate() != 42:
raise ValueError("!= 42")
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python/1 basic/subdir/subprog.py
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python/1 basic/gluon/__init__.py
|
|
def gluoninate():
return 42
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python/1 basic/gluon/gluonator.py
|
#!/usr/bin/env python3
import os
import sys
import argparse
from pathlib import Path
filedir = Path(os.path.dirname(__file__)).resolve()
if list(filedir.glob('ext/*tachyon*')):
sys.path.insert(0, (filedir / 'ext').as_posix())
import tachyon
parser = argparse.ArgumentParser()
parser.add_argument('-o', dest='output', default=None)
options = parser.parse_args(sys.argv[1:])
result = tachyon.phaserize('shoot')
if options.output:
with open(options.output, 'w') as f:
f.write('success')
if not isinstance(result, int):
raise SystemExit('Returned result not an integer.')
if result != 1:
raise SystemExit(f'Returned result {result} is not 1.')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/python/4 custom target depends extmodule/blaster.py
|
#!/usr/bin/env python3
import argparse
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('out')
parser.add_argument('--mode', choices=['main', 'lib'], default='main')
args = parser.parse_args()
with open(args.out, 'w') as f:
if args.mode == 'main':
f.write('fn main() { println!("I prefer tarnish, actually.") }')
elif args.mode == 'lib':
f.write('pub fn libfun() { println!("I prefer tarnish, actually.") }')
if __name__ == "__main__":
main()
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/rust/11 generated main/gen.py
|
#!/usr/bin/env python3
# SPDX-license-identifer: Apache-2.0
# Copyright © 2021 Intel Corporation
import argparse
import shutil
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('input')
parser.add_argument('output')
args = parser.parse_args()
shutil.copy2(args.input, args.output)
if __name__ == "__main__":
main()
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/rust/12 bindgen/src/gen_header.py
|
#!/usr/bin/env python3
import argparse
import subprocess
import sys
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('command')
parser.add_argument('expected')
args = parser.parse_args()
out = subprocess.run(args.command, stdout=subprocess.PIPE)
actual = out.stdout.decode().strip()
if args.expected != actual:
print('expected:', args.expected, file=sys.stderr)
print('actual: ', actual, file=sys.stderr)
sys.exit(1)
sys.exit(0)
if __name__ == "__main__":
main()
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/rust/16 internal c dependencies/test.py
|
#!/usr/bin/env python3
from storer import Storer
s = Storer()
if s.get_value() != 0:
raise SystemExit('Initial value incorrect.')
s.set_value(42)
if s.get_value() != 42:
raise SystemExit('Setting value failed.')
try:
s.set_value('not a number')
raise SystemExit('Using wrong argument type did not fail.')
except TypeError:
pass
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/cython/1 basic/cytest.py
|
# SPDX-License-Identifier: Apache-2.0
import argparse
import textwrap
parser = argparse.ArgumentParser()
parser.add_argument('output')
args = parser.parse_args()
with open(args.output, 'w') as f:
f.write(textwrap.dedent('''\
cpdef func():
return "Hello, World!"
'''))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/cython/2 generated sources/gen.py
|
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
import argparse
import importlib
parser = argparse.ArgumentParser()
parser.add_argument('mod')
args = parser.parse_args()
mod = importlib.import_module(args.mod)
assert mod.func() == 'Hello, World!'
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/cython/2 generated sources/test.py
|
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('input')
parser.add_argument('output')
args = parser.parse_args()
with open(args.input, 'r') as i, open(args.output, 'w') as o:
o.write(i.read())
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/cython/2 generated sources/generator.py
|
# SPDX-License-Identifier: Apache-2.0
import argparse
import textwrap
parser = argparse.ArgumentParser()
parser.add_argument('output')
args = parser.parse_args()
with open(args.output, 'w') as f:
f.write(textwrap.dedent('''\
cpdef func():
return "Hello, World!"
'''))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/cython/2 generated sources/libdir/gen.py
|
#!/usr/bin/env python3
import sys, os
if len(sys.argv) != 3:
print(sys.argv[0], '<namespace>', '<output dir>')
name = sys.argv[1]
odir = sys.argv[2]
with open(os.path.join(odir, name + '.h'), 'w') as f:
f.write('int func();\n')
with open(os.path.join(odir, name + '.c'), 'w') as f:
f.write('int main(int argc, char *argv[]) { return 0; }')
with open(os.path.join(odir, name + '.sh'), 'w') as f:
f.write('#!/bin/bash')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/failing/42 custom target outputs not matching install_dirs/generator.py
|
#!/usr/bin/env python3
import sys
out = sys.argv[-1]
with open(out, 'wb') as o:
for infile in sys.argv[1:-1]:
with open(infile, 'rb') as f:
o.write(f.read())
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/failing/41 custom target plainname many inputs/catfiles.py
|
#!/usr/bin/env python3
import sys
if len(sys.argv) != 3:
print(sys.argv[0], '<input>', '<output>')
inf = sys.argv[1]
outf = sys.argv[2]
with open(outf, 'wb') as o:
with open(inf, 'rb') as i:
o.write(i.read())
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/failing/93 custom target install data/preproc.py
|
#!/usr/bin/env python3
print('Yo dawg, we put overrides in your overrides,')
print('so now you can override when you override.')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/failing/70 dual override/overrides.py
|
#!/usr/bin/env python3
import sys
exit(int(sys.argv[1]))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/failing/72 run_command unclean exit/returncode.py
|
#!/usr/bin/env python3
print('Doing something else.')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/failing/71 override used/other.py
|
#!/usr/bin/env python3
print('Doing something.')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/failing/71 override used/something.py
|
#!/usr/bin/env python3
import os
template = '''#pragma once
#define THE_NUMBER {}
'''
input_file = os.path.join(os.environ['MESON_SOURCE_ROOT'], 'raw.dat')
output_file = os.path.join(os.environ['MESON_BUILD_ROOT'], 'generated.h')
with open(input_file) as f:
data = f.readline().strip()
with open(output_file, 'w') as f:
f.write(template.format(data))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/99 postconf/postconf.py
|
#!/usr/bin/env python3
# Mimic a binary that generates an object file (e.g. windres).
import sys, subprocess
if __name__ == '__main__':
if len(sys.argv) != 4:
print(sys.argv[0], 'compiler input_file output_file')
sys.exit(1)
compiler = sys.argv[1]
ifile = sys.argv[2]
ofile = sys.argv[3]
if compiler.endswith('cl'):
cmd = [compiler, '/nologo', '/MDd', '/Fo' + ofile, '/c', ifile]
else:
cmd = [compiler, '-c', ifile, '-o', ofile]
sys.exit(subprocess.call(cmd))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/52 object generator/obj_generator.py
|
#!/usr/bin/env python3
import os
assert os.environ['MY_PATH'] == os.pathsep.join(['0', '1', '2'])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/33 run program/check-env.py
|
#!/usr/bin/env python3
print('1.2')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/33 run program/get-version.py
|
#! /usr/bin/env python3
import sys
from shutil import copyfile
copyfile(*sys.argv[1:])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/214 source set custom target/cp.py
|
#!/usr/bin/env python3
import sys
ifile = sys.argv[1]
ofile = sys.argv[2]
with open(ifile) as f:
resval = f.readline().strip()
templ = '#define RESULT (%s)\n'
with open(ofile, 'w') as f:
f.write(templ % (resval, ))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/125 configure file in generator/src/gen.py
|
#!/usr/bin/env python3
import sys
ifile = open(sys.argv[1])
ofile = open(sys.argv[2], 'w')
ofile.write(ifile.read())
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/129 build by default/mygen.py
|
#!/usr/bin/env python3
import os.path, sys
invert = False
for path in sys.argv[1:]:
if path == '--not':
invert = True
elif not os.path.exists(path) ^ invert:
sys.exit(1)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/129 build by default/checkexists.py
|
#!/usr/bin/env python3
import os
import sys
if not os.path.isfile(sys.argv[1]):
raise Exception("Couldn't find {!r}".format(sys.argv[1]))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/51 run target/check_exists.py
|
#!/usr/bin/env python3
import sys
with open(sys.argv[1], 'rb') as ifile, open(sys.argv[2], 'wb') as ofile:
ofile.write(ifile.read())
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/51 run target/converter.py
|
#!/usr/bin/env python3
import os, sys
from pathlib import Path
assert 'MESON_SOURCE_ROOT' in os.environ
assert 'MESON_BUILD_ROOT' in os.environ
assert 'MESON_SUBDIR' in os.environ
assert 'MESONINTROSPECT' in os.environ
assert 'MY_ENV' in os.environ
# Environment has absolute paths and argv has relative paths when using ninja
# backend and absolute paths when using vs backend. What matters is once
# resolved they point to same location.
env_source_root = Path(os.environ['MESON_SOURCE_ROOT']).resolve()
env_build_root = Path(os.environ['MESON_BUILD_ROOT']).resolve()
env_current_source_dir = Path(env_source_root, os.environ['MESON_SUBDIR']).resolve()
argv_paths = [Path(i).resolve() for i in sys.argv[1:]]
source_root, build_root, current_source_dir = argv_paths
assert source_root == env_source_root
assert build_root == env_build_root
assert current_source_dir == env_current_source_dir
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/51 run target/check-env.py
|
#!/usr/bin/env python3
import sys
plain_arg = sys.argv[1]
_, filename, _ = plain_arg.split(':')
try:
with open(filename, 'rb') as f:
content = f.read()
except FileNotFoundError:
print('Could not open file. Missing dependency?')
sys.exit(1)
print('File opened, pretending to send it somewhere.')
print(len(content), 'bytes uploaded')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/51 run target/fakeburner.py
|
#!/usr/bin/env python3
print('I am a script. Being run.')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/51 run target/subdir/textprinter.py
|
#!/usr/bin/env python3
import os
import sys
import shlex
do_print = False
if len(sys.argv) > 1:
do_print = bool(sys.argv[1])
if 'MESONINTROSPECT' not in os.environ:
raise RuntimeError('MESONINTROSPECT not found')
mesonintrospect = os.environ['MESONINTROSPECT']
introspect_arr = shlex.split(mesonintrospect)
# print(mesonintrospect)
# print(introspect_arr)
some_executable = introspect_arr[0]
if not os.path.isfile(some_executable):
raise RuntimeError(f'{mesonintrospect!r} does not exist')
if do_print:
print(some_executable, end='')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/139 mesonintrospect from scripts/check_env.py
|
#!/usr/bin/env python3
import os
import shlex
import subprocess
if 'MESONINTROSPECT' not in os.environ:
raise RuntimeError('MESONINTROSPECT not found')
if 'MESON_BUILD_ROOT' not in os.environ:
raise RuntimeError('MESON_BUILD_ROOT not found')
mesonintrospect = os.environ['MESONINTROSPECT']
introspect_arr = shlex.split(mesonintrospect)
buildroot = os.environ['MESON_BUILD_ROOT']
subprocess.check_output([*introspect_arr, '--all', buildroot])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/139 mesonintrospect from scripts/check_introspection.py
|
#!/usr/bin/env python3
import shutil, sys, subprocess, argparse, pathlib
parser = argparse.ArgumentParser()
parser.add_argument('--private-dir', required=True)
parser.add_argument('-o', nargs='+', required=True)
parser.add_argument('cmparr', nargs='+')
contents = ['''
int flob() {
return 0;
}
''', '''
int flob() {
return 1;
}
''']
def generate_lib_gnulike(outfile, c_file, private_dir, compiler_array):
if shutil.which('ar'):
static_linker = 'ar'
elif shutil.which('llvm-ar'):
static_linker = 'llvm-ar'
elif shutil.which('gcc-ar'):
static_linker = 'gcc-ar'
else:
sys.exit('Could not detect a static linker.')
o_file = c_file.with_suffix('.o')
compile_cmd = compiler_array + ['-c', '-g', '-O2', '-o', str(o_file), str(c_file)]
subprocess.check_call(compile_cmd)
out_file = pathlib.Path(outfile)
if out_file.exists():
out_file.unlink()
link_cmd = [static_linker, 'csr', outfile, str(o_file)]
subprocess.check_call(link_cmd)
return 0
def generate_lib_msvc(outfile, c_file, private_dir, compiler_array):
static_linker = 'lib'
o_file = c_file.with_suffix('.obj')
compile_cmd = compiler_array + ['/MDd',
'/nologo',
'/ZI',
'/Ob0',
'/Od',
'/c',
'/Fo' + str(o_file),
str(c_file)]
subprocess.check_call(compile_cmd)
out_file = pathlib.Path(outfile)
if out_file.exists():
out_file.unlink()
link_cmd = [static_linker,
'/nologo',
'/OUT:' + str(outfile),
str(o_file)]
subprocess.check_call(link_cmd)
return 0
def generate_lib(outfiles, private_dir, compiler_array):
private_dir = pathlib.Path(private_dir)
if not private_dir.exists():
private_dir.mkdir()
for i, content in enumerate(contents):
c_file = private_dir / ('flob_' + str(i + 1) + '.c')
c_file.write_text(content)
outfile = outfiles[i]
cl_found = False
for cl_arg in compiler_array:
if (cl_arg.endswith('cl') or cl_arg.endswith('cl.exe')) and 'clang-cl' not in cl_arg:
ret = generate_lib_msvc(outfile, c_file, private_dir, compiler_array)
if ret > 0:
return ret
else:
cl_found = True
break
if not cl_found:
ret = generate_lib_gnulike(outfile, c_file, private_dir, compiler_array)
if ret > 0:
return ret
return 0
if __name__ == '__main__':
options = parser.parse_args()
sys.exit(generate_lib(options.o, options.private_dir, options.cmparr))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/209 link custom_i single from multiple/generate_conflicting_stlibs.py
|
#!/usr/bin/env python3
import sys
import pathlib
[ifilename, ofilename] = sys.argv[1:3]
ftempl = '''int %s(void) {
return 6;
}
'''
d = pathlib.Path(ifilename).read_text().split('\n')[0].strip()
pathlib.Path(ofilename).write_text(ftempl % d)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/182 find override/subdir/converter.py
|
#!/usr/bin/env python3
import sys
import shutil
shutil.copyfile(sys.argv[1], sys.argv[2])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/126 generated llvm ir/copyfile.py
|
#!/usr/bin/env python3
import sys, os, subprocess
def generate(infile, outfile, fallback):
workdir = os.path.split(infile)[0]
if workdir == '':
workdir = '.'
try:
version = subprocess.check_output(['git', 'describe'], cwd=workdir).decode().strip()
except (subprocess.CalledProcessError, OSError, UnicodeDecodeError):
version = fallback
with open(infile) as f:
newdata = f.read().replace('@VERSION@', version)
try:
with open(outfile) as f:
olddata = f.read()
if olddata == newdata:
return
except OSError:
pass
with open(outfile, 'w') as f:
f.write(newdata)
if __name__ == '__main__':
infile = sys.argv[1]
outfile = sys.argv[2]
fallback = sys.argv[3]
generate(infile, outfile, fallback)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/65 build always/version_gen.py
|
#!/usr/bin/env python3
import sys
if __name__ == '__main__':
if len(sys.argv) != 2:
print(sys.argv[0], 'output_file')
sys.exit(1)
ifile = sys.stdin.read()
if ifile != 'This is a text only input file.\n':
print('Malformed input')
sys.exit(1)
with open(sys.argv[1], 'w+') as f:
f.write('This is a binary output file.')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/242 custom target feed/my_compiler.py
|
#!/usr/bin/env python3
import sys, os
template = '''#pragma once
#define THE_NUMBER {}
#define THE_ARG1 {}
#define THE_ARG2 {}
'''
input_file = os.path.join(os.environ['MESON_SOURCE_ROOT'], 'raw.dat')
output_file = os.path.join(os.environ['MESON_BUILD_ROOT'], 'generated.h')
with open(input_file) as f:
data = f.readline().strip()
with open(output_file, 'w') as f:
f.write(template.format(data, sys.argv[1], sys.argv[2]))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/100 postconf with args/postconf.py
|
#!/usr/bin/env python3
import sys, os
if len(sys.argv) != 3:
print("You is fail.")
sys.exit(1)
with open(sys.argv[1]) as f:
val = f.read().strip()
outdir = sys.argv[2]
outhdr = os.path.join(outdir, 'source%s.h' % val)
outsrc = os.path.join(outdir, 'source%s.cpp' % val)
with open(outhdr, 'w') as f:
f.write('int func%s();\n' % val)
with open(outsrc, 'w') as f:
f.write('''int func%s() {
return 0;
}
''' % val)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/58 multiple generators/mygen.py
|
#!/usr/bin/env python3
import sys
if len(sys.argv) > 1:
print(sys.argv[1])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/150 reserved targets/runtarget/echo.py
|
#!/usr/bin/env python3
import argparse
import os
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('dirname')
args = parser.parse_args()
with open(os.path.join(args.dirname, '1.txt'), 'w') as f:
f.write('')
with open(os.path.join(args.dirname, '2.txt'), 'w') as f:
f.write('')
if __name__ == "__main__":
main()
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/53 install script/customtarget.py
|
#!/usr/bin/env python3
import argparse
import os
import shutil
prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX']
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('dirname')
parser.add_argument('files', nargs='+')
parser.add_argument('--mode', action='store', default='create', choices=['create', 'copy'])
args = parser.parse_args()
dirname = os.path.join(prefix, args.dirname)
if not os.path.exists(dirname):
os.makedirs(dirname)
if args.mode == 'create':
for name in args.files:
with open(os.path.join(dirname, name), 'w') as f:
f.write('')
else:
for name in args.files:
shutil.copy(name, dirname)
if __name__ == "__main__":
main()
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/53 install script/myinstall.py
|
#!/usr/bin/env python3
import os
import sys
prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX']
dirname = os.path.join(prefix, sys.argv[1])
if not os.path.exists(dirname):
os.makedirs(dirname)
with open(os.path.join(dirname, sys.argv[2] + '.in'), 'w') as f:
f.write('')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/53 install script/src/myinstall.py
|
#!/usr/bin/env python3
import sys
import shutil
shutil.copyfile(sys.argv[1], sys.argv[2])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/157 custom target subdir depend files/copyfile.py
|
#!/usr/bin/env python3
import sys
import os
with open(sys.argv[1]) as fh:
content = fh.read().replace("{NAME}", sys.argv[2])
with open(os.path.join(sys.argv[3]), 'w', errors='replace') as fh:
fh.write(content)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/179 escape and unicode/file.py
|
#!/usr/bin/env python3
import os
import sys
for fh in os.listdir('.'):
if os.path.isfile(fh):
if fh.endswith('.c'):
sys.stdout.write(fh + '\0')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/179 escape and unicode/find.py
|
#!/usr/bin/env python3
import os
import sys
out = sys.argv[1]
os.mkdir(out)
for name in ('a', 'b', 'c'):
with open(os.path.join(out, name + '.txt'), 'w') as f:
f.write(name)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/202 custom target build by default/docgen.py
|
#!/usr/bin/env python3
import os, sys, argparse
h_templ = '''#pragma once
int %s(void);
'''
c_templ = '''#include"%s.h"
int %s(void) {
return 0;
}
'''
parser = argparse.ArgumentParser()
parser.add_argument('--searchdir', required=True)
parser.add_argument('--outdir', required=True)
parser.add_argument('ifiles', nargs='+')
options = parser.parse_args()
searchdir = options.searchdir
outdir = options.outdir
ifiles = options.ifiles
rel_ofiles = []
for ifile in ifiles:
if not ifile.startswith(options.searchdir):
sys.exit(f'Input file {ifile} does not start with search dir {searchdir}.')
rel_ofile = ifile[len(searchdir):]
if rel_ofile[0] == '/' or rel_ofile[0] == '\\':
rel_ofile = rel_ofile[1:]
rel_ofiles.append(os.path.splitext(rel_ofile)[0])
ofile_bases = [os.path.join(outdir, i) for i in rel_ofiles]
for i, ifile_name in enumerate(ifiles):
proto_name = open(ifile_name).readline().strip()
h_out = ofile_bases[i] + '.h'
c_out = ofile_bases[i] + '.c'
os.makedirs(os.path.split(ofile_bases[i])[0], exist_ok=True)
open(h_out, 'w').write(h_templ % (proto_name))
open(c_out, 'w').write(c_templ % (proto_name, proto_name))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/168 preserve gendir/genprog.py
|
#!/usr/bin/env python3
import sys
ifile = sys.argv[1]
ofile = sys.argv[2]
templ = '''#pragma once
int %s(void) {
return 42;
}
'''
funname = open(ifile).readline().strip()
open(ofile, 'w').write(templ % funname)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/169 source in dep/generated/genheader.py
|
#!/usr/bin/env python3
import sys
with open(sys.argv[1], 'w') as f:
f.write("#define FOO 0")
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/13 pch/generated/gen_custom.py
|
#!/usr/bin/env python3
import sys
with open(sys.argv[1]) as f:
content = f.read()
with open(sys.argv[2], 'w') as f:
f.write(content)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/13 pch/generated/gen_generator.py
|
#! /usr/bin/env python3
with open('x.c', 'w') as f:
print('int main(void) { return 0; }', file=f)
with open('y', 'w'):
pass
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/228 custom_target source/x.py
|
#!/usr/bin/env python3
# Generates a static library, object file, source
# file and a header file.
import sys, os
import subprocess
with open(sys.argv[1]) as f:
funcname = f.readline().strip()
outdir = sys.argv[2]
buildtype_args = sys.argv[3]
compiler_type = sys.argv[4]
compiler = sys.argv[5:]
if not os.path.isdir(outdir):
print('Outdir does not exist.')
sys.exit(1)
if compiler_type == 'msvc':
libsuffix = '.lib'
is_vs = True
if any(['clang-cl' in c for c in compiler]):
linker = 'llvm-lib'
else:
linker = 'lib'
else:
libsuffix = '.a'
is_vs = False
linker = 'ar'
objsuffix = '.o'
outo = os.path.join(outdir, funcname + objsuffix)
outa = os.path.join(outdir, funcname + libsuffix)
outh = os.path.join(outdir, funcname + '.h')
outc = os.path.join(outdir, funcname + '.c')
tmpc = 'diibadaaba.c'
tmpo = 'diibadaaba' + objsuffix
with open(outc, 'w') as f:
f.write('''#include"{}.h"
int {}_in_src(void) {{
return 0;
}}
'''.format(funcname, funcname))
with open(outh, 'w') as f:
f.write('''#pragma once
int {}_in_lib(void);
int {}_in_obj(void);
int {}_in_src(void);
'''.format(funcname, funcname, funcname))
with open(tmpc, 'w') as f:
f.write('''int %s_in_obj(void) {
return 0;
}
''' % funcname)
if is_vs:
subprocess.check_call(compiler + ['/nologo', '/c', buildtype_args, '/Fo' + outo, tmpc])
else:
subprocess.check_call(compiler + ['-c', '-o', outo, tmpc])
with open(tmpc, 'w') as f:
f.write('''int %s_in_lib() {
return 0;
}
''' % funcname)
if is_vs:
subprocess.check_call(compiler + ['/nologo', '/c', '/Fo' + tmpo, tmpc])
subprocess.check_call([linker, '/NOLOGO', '/OUT:' + outa, tmpo])
else:
subprocess.check_call(compiler + ['-c', '-o', tmpo, tmpc])
subprocess.check_call([linker, 'csr', outa, tmpo])
os.unlink(tmpo)
os.unlink(tmpc)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/95 manygen/subdir/manygen.py
|
#!/usr/bin/env python3
import sys
import shutil
shutil.copyfile(sys.argv[1], sys.argv[2])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/130 include order/ctsub/copyfile.py
|
#!/usr/bin/env python3
import sys, os
if __name__ == '__main__':
if len(sys.argv) != 3:
print(sys.argv[0], 'object', 'output')
sys.exit(1)
elif os.path.exists(sys.argv[1]):
with open(sys.argv[2], 'wb') as out:
pass
else:
sys.exit(1)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/216 custom target input extracted objects/check_object.py
|
#!/usr/bin/env python3
import sys
ifile = sys.argv[1]
ofile = sys.argv[2]
open(ofile, 'w').write(open(ifile).read())
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/110 allgenerate/converter.py
|
#!/usr/bin/env python3
import re
import sys
import shutil
import subprocess
exepath = sys.argv[1]
want_arch = sys.argv[2]
dummy_output = sys.argv[3]
with open(dummy_output, 'w') as f:
f.write('')
if not shutil.which('dumpbin'):
print('dumpbin not found, skipping')
sys.exit(0)
out = subprocess.check_output(['dumpbin', '/HEADERS', exepath],
universal_newlines=True)
for line in out.split('\n'):
m = re.match(r'.* machine \(([A-Za-z0-9]+)\)$', line)
if m:
arch = m.groups()[0].lower()
if arch == 'arm64':
arch = 'aarch64'
elif arch == 'x64':
arch = 'x86_64'
if arch != want_arch:
raise RuntimeError(f'Wanted arch {want_arch} but exe uses {arch}')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/226 link depends indexed custom target/check_arch.py
|
#!/usr/bin/env python3
import sys
with open(sys.argv[1], 'w') as f:
print('# this file does nothing', file=f)
with open(sys.argv[2], 'w') as f:
print('# this file does nothing', file=f)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/226 link depends indexed custom target/make_file.py
|
#!/usr/bin/env python3
print("Found")
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/97 find program path/program.py
|
#!/usr/bin/env python3
import time, sys
# Make sure other script runs first if dependency
# is missing.
time.sleep(0.5)
with open(sys.argv[1]) as f:
contents = f.read()
with open(sys.argv[2], 'w') as f:
f.write(contents)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/71 ctarget dependency/gen1.py
|
#!/usr/bin/env python3
import sys, os
from glob import glob
files = glob(os.path.join(sys.argv[1], '*.tmp'))
assert(len(files) == 1)
with open(files[0]) as ifile, open(sys.argv[2], 'w') as ofile:
ofile.write(ifile.read())
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/71 ctarget dependency/gen2.py
|
#!/usr/bin/env python3
import sys
import os
assert os.environ['MESONTESTING'] == 'picklerror'
assert os.environ['TEST_LIST_FLATTENING'] == '1'
with open(sys.argv[1]) as f:
if f.read() != 'contents\n':
sys.exit(1)
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/41 test args/tester.py
|
#!/usr/bin/env python3
import sys
import shutil
shutil.copyfile(sys.argv[1], sys.argv[2])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/41 test args/copyfile.py
|
#!/usr/bin/env python3
import sys, os
if len(sys.argv) != 3:
print(sys.argv[0], '<namespace>', '<output dir>')
name = sys.argv[1]
odir = sys.argv[2]
with open(os.path.join(odir, name + '.h'), 'w') as f:
f.write('int func();\n')
with open(os.path.join(odir, name + '.sh'), 'w') as f:
f.write('#!/bin/bash')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/140 custom target multiple outputs/generator.py
|
#!/usr/bin/env python3
import sys
print(sys.argv[1])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/217 test priorities/testprog.py
|
import shutil
import sys
if __name__ == '__main__':
if len(sys.argv) != 3:
raise Exception('Requires exactly 2 args')
shutil.copy2(sys.argv[1], sys.argv[2])
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/143 list of file sources/gen.py
|
#!/usr/bin/env python3
import sys
with open(sys.argv[1]) as ifile:
if ifile.readline().strip() != '42':
print('Incorrect input')
with open(sys.argv[2], 'w') as ofile:
ofile.write('Success\n')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/69 configure file in custom target/src/mycompiler.py
|
#!/usr/bin/env python3
import os
import sys
assert(os.path.exists(sys.argv[3]))
args = sys.argv[:-1]
if __name__ == '__main__':
assert os.environ['MY_COMPILER_ENV'] == 'value'
if len(args) != 3 or not args[1].startswith('--input') or \
not args[2].startswith('--output'):
print(args[0], '--input=input_file --output=output_file')
sys.exit(1)
with open(args[1].split('=')[1]) as f:
ifile = f.read()
if ifile != 'This is a text only input file.\n':
print('Malformed input')
sys.exit(1)
with open(args[2].split('=')[1], 'w') as ofile:
ofile.write('This is a binary output file.\n')
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/49 custom target/my_compiler.py
|
#!/usr/bin/env python3
import sys, os
from glob import glob
_, srcdir, depfile, output = sys.argv
depfiles = glob(os.path.join(srcdir, '*'))
quoted_depfiles = [x.replace(' ', r'\ ') for x in depfiles]
with open(output, 'w') as f:
f.write('I am the result of globbing.')
with open(depfile, 'w') as f:
f.write('{}: {}\n'.format(output, ' '.join(quoted_depfiles)))
|
nvtrust-main
|
infrastructure/kvm/qemu/qemu_source/meson/test cases/common/49 custom target/depfile/dep.py
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.