You can see the detail on the google formal setup guide:https://source.android.com/compatibility/cts/setup.html#desktop_setup
or you can Prepare a Desktop or Laptop with OS System Ubuntu 16.04 (64bit)
1、Java SDK set up
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install openjdk-7-jdk(For Android M or older)
sudo apt-get install openjdk-8-jdk(For Android N or newer)
2、sudo apt-get update
3、sudo apt-get install lib32stdc++6 lib32z1
4、ADB and AAPT configuration:
# sudo unzip -d /usr/local/sbin platform-tools-latest-linux.zip
# sudo apt-get install aapt
5、sudo dpkg-reconfigure dash -> select "no"
6、sudo sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"18d1\", ATTRS{idProduct}==\"4ee7\",MODE=\"0666\" > /etc/udev/rules.d/70-android.rules'
7、Download/Copy CTS package and Media package to PC at CTS/GTS/CTSv Package Path & Info according your test target
unzip filename.zip -d ~
unzip android-cts-media-1.4.zip -d ~