4 # # Query the python server for artifacts
5 # RUN: DEBUGINFOD_CACHE_PATH=%t python %s --server-path %S/Inputs \
6 # RUN: --tool-cmd 'llvm-debuginfod-find --dump --executable abcdef' | \
7 # RUN: FileCheck %s --check-prefix=EXECUTABLE
8 # RUN: DEBUGINFOD_CACHE_PATH=%t python %s --server-path %S/Inputs \
9 # RUN: --tool-cmd 'llvm-debuginfod-find --dump --source=/directory/file.c abcdef' | \
10 # RUN: FileCheck %s --check-prefix=SOURCE
11 # RUN: DEBUGINFOD_CACHE_PATH=%t python %s --server-path %S/Inputs \
12 # RUN: --tool-cmd 'llvm-debuginfod-find --dump --debuginfo abcdef' | \
13 # RUN: FileCheck %s --check-prefix=DEBUGINFO
15 # EXECUTABLE: fake_executable
16 # SOURCE: int foo = 0;
17 # DEBUGINFO: fake_debuginfo
19 # # The artifacts should still be present in the cache without needing to query
21 # RUN: DEBUGINFOD_CACHE_PATH=%t llvm-debuginfod-find --dump --executable abcdef | \
22 # RUN: FileCheck %s --check-prefix=EXECUTABLE
23 # RUN: DEBUGINFOD_CACHE_PATH=%t llvm-debuginfod-find --dump \
24 # RUN: --source=/directory/file.c abcdef | \
25 # RUN: FileCheck %s --check-prefix=SOURCE
26 # RUN: DEBUGINFOD_CACHE_PATH=%t llvm-debuginfod-find --dump --debuginfo abcdef | \
27 # RUN: FileCheck %s --check-prefix=DEBUGINFO
30 # This script is used to test the debuginfod client within a host tool.
31 # It first stands up a Python HTTP static file server and then executes the tool.
32 # This way the tool can make debuginfod HTTP requests to the static file server.
42 # Serves files at the server_path, then runs the tool with specified args.
43 # Sets the DEBUGINFOD_CACHE_PATH env var to point at the given cache_directory.
44 # Sets the DEBUGINFOD_URLS env var to point at the local server.
45 def test_tool(server_path, tool_args):
46 httpd = http.server.ThreadingHTTPServer(
47 ('',0), functools.partial(
48 http.server.SimpleHTTPRequestHandler,
49 directory=server_path))
50 port = httpd.server_port
51 thread = threading.Thread(target=httpd.serve_forever)
55 env['DEBUGINFOD_URLS'] = 'http://localhost:%s' % port
56 process = subprocess.Popen(
60 print('nontrivial return code %s' % code)
68 parser = argparse.ArgumentParser()
69 parser.add_argument('--server-path', default='./')
70 parser.add_argument('--tool-cmd', required=True, type=str)
71 args = parser.parse_args()
72 result = test_tool(args.server_path,
73 args.tool_cmd.split())
76 if __name__ == '__main__':