this repo has no description
at trunk 72 lines 1.8 kB view raw
1#!/usr/bin/env python3 2# Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com) 3 4import os 5import re 6import shutil 7import subprocess 8import sys 9 10 11LLDB_CMDS = os.path.join(os.path.dirname(__file__), "test_lldb_support.lldb") 12CPP_FILE = os.path.join(os.path.dirname(__file__), "test_lldb_support.cpp") 13EXP_LINE_RE = re.compile(r"^// (exp|re): (.+)$") 14 15 16def main(): 17 if not shutil.which("lldb"): 18 print("lldb not found; not running tests") 19 return 0 20 21 if len(sys.argv) != 2: 22 print(f"Usage: {sys.argv[0]} <build root>", file=sys.stderr) 23 return 1 24 25 build_root = sys.argv[1] 26 lldb_command = [ 27 "lldb", 28 "-x", 29 "-s", 30 LLDB_CMDS, 31 "--", 32 os.path.join(build_root, "test_lldb_support"), 33 ] 34 proc = subprocess.run( 35 lldb_command, encoding="utf-8", stdout=subprocess.PIPE, stdin=subprocess.DEVNULL 36 ) 37 38 failed = [] 39 found = 0 40 stdout = proc.stdout 41 for line in open(CPP_FILE, "r"): 42 line = line.strip() 43 match = EXP_LINE_RE.match(line) 44 if not match: 45 continue 46 kind = match[1] 47 pattern = match[2] 48 if kind == "exp": 49 pattern = f"^{re.escape(pattern)}$" 50 else: 51 pattern = f"^{pattern}$" 52 if re.search(pattern, stdout, re.MULTILINE): 53 found += 1 54 else: 55 failed.append(pattern) 56 57 if failed: 58 print(f"Missing {len(failed)} patterns:", file=sys.stderr) 59 for pattern in failed: 60 print(f" {pattern}", file=sys.stderr) 61 print( 62 f"\nRun the following command to reproduce:\n > {' '.join(lldb_command)}", 63 file=sys.stderr, 64 ) 65 return 1 66 67 print(f"{found} patterns found") 68 return 0 69 70 71if __name__ == "__main__": 72 sys.exit(main())