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