xref: /aosp_15_r20/external/toolchain-utils/binary_search_tool/sysroot_wrapper/testing_test.py (revision 760c253c1ed00ce9abd48f8546f08516e57485fe)
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright 2020 The ChromiumOS Authors
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Test for sysroot_wrapper bisector.
8
9All files in bad_files will be determined to be bad. This test was made for
10chromeos-chrome built for a daisy board, if you are using another package you
11will need to change the base_path accordingly.
12"""
13
14
15import subprocess
16import sys
17import os
18
19base_path = (
20    "/var/cache/chromeos-chrome/chrome-src-internal/src/out_daisy/"
21    "Release/obj/"
22)
23bad_files = [
24    os.path.join(base_path, "base/base.cpu.o"),
25    os.path.join(base_path, "base/base.version.o"),
26    os.path.join(base_path, "apps/apps.launcher.o"),
27]
28
29bisect_dir = os.environ.get("BISECT_DIR", "/tmp/sysroot_bisect")
30
31
32def Main(_):
33    for test_file in bad_files:
34        test_file = test_file.strip()
35        cmd = ["grep", test_file, os.path.join(bisect_dir, "BAD_SET")]
36        ret = subprocess.call(
37            cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
38        )
39        if not ret:
40            return 1
41    return 0
42
43
44if __name__ == "__main__":
45    sys.exit(Main(sys.argv[1:]))
46