xref: /aosp_15_r20/external/toolchain-utils/binary_search_tool/README.testing.md (revision 760c253c1ed00ce9abd48f8546f08516e57485fe)
1# Testing the binary search tool
2
3This file explains how to set up and run the various kinds of bisection tests.
4
5The bisection tool comes with several sets of tests which you should
6run after updating any of the bisection tool scripts OR after updating
7the Android compiler wrapper (to make sure the wrapper will still work
8correctly with bisection).
9
10## Before you start.
11
12Before you can run the tests, your PYTHONPATH environment variable
13must be correct.  This means that it must include both the
14toolchain-utils directory and the `binary_search_tool` directory.  The
15easiest way to set it is:
16
17```
18$ cd toolchain-utils
19$ export PYTHONPATH=`pwd`:${PYTHONPATH}
20$ cd binary_search_tool
21$ export PYTHONPATH=`pwd`:${PYTHONPATH}
22```
23
24
25## Running the unittests.
26
27To run the basic unit tests:
28
29```
30$ cd toolchain-utils/binary_search_tool/test
31$ ./binary_search_tool_test.py
32```
33
34# Running the bisection tests, testing the compiler wrapper.
35
36If you want to run the bisection tests, and test the compiler wrapper
37(to make sure the `POPULATE_GOOD` and `POPULATE_BAD` stages are still
38working properly) you can do the following.
39
40If you are testing with the ANDROID COMPILER WRAPPER, you need to to some
41preliminary setup:
42
43Set up the compiler wrapper to replace GCC:
44
45```
46$ cd <android-root/prebuilts/clang/host/linux-x86/clang-368880/bin
47$ cp clang gcc
48$ whereis gcc
49gcc: /usr/bin/gcc /usr/lib/gcc /usr/bin/X11/gcc /usr/share/man/man1/gcc.1.gz
50$ cd /usr/bin
51$ ls -l gcc
52lrwxrwxrwx 1 root root 7 Feb  3 17:00 gcc -> gcc-4.8*
53$ sudo mv gcc gcc.real
54$ sudo ln -s \
55    <android-root>/prebuilts/clang/host/linux-x86/clang-3688880/bin/gcc gcc
56```
57
58Move to the correct directory, then run the test script:
59
60```
61$ cd toolchain-utils/binary_search_tool
62$ ./run_bisect_tests.py
63```
64
65If you are testing with the CHROMEOS COMPILER WRAPPER, you MUST run the
66tests from INSIDE your CHROOT (but you don't need to do any special setup):
67
68```
69$ cd <path-to-chromeos-root>
70$ cros_sdk
71$ cd ~/trunk/src/third_party/toolchain-utils
72```
73
74Set up your `PYTHONPATH`:
75
76```
77$ export PYTHONPATH=`pwd`:${PYTHONPATH}
78$ cd binary_search_tool
79$ export PYTHONPATH=`pwd`:${PYTHONPATH}
80```
81
82Run the test script:
83
84```
85$ ./run_bisect_tests.py
86```
87
88
89## Running the bisection tests, without testing the compiler wrapper.
90
91```
92$ cd toolchain-utils/binary_search_tool
93$ ./full_bisect_test/run-test-nowrapper.sh
94```
95