pwndbg/setup-test-tools.sh

45 lines
1.1 KiB
Bash
Raw Normal View History

Unit test fix (#868) * Fixed the failed unit testing; Improved the Dockerfile, again. * Fixed missing new line joiner in the Dockerfile. * Fixed the default Python version from 2 to 3. * Moved the installation of the nasm and golang packages to the setup script. * Fixed the extra quotes which fails the sudo check. * Added to the Git ignore file the output files assembled and linked in the test binaries. * Removed the output files from test binaries. * Added to the Git ignore file the virtual environment directory. * Added sudo to the remove and link the Python3 binary. * Added commands related to GO, to check why is failing. * Fixed the installation of GO, only install if not exists in Ubuntu. * Fixed the first test built in Assembler. Checks if it is working in GitHub. * Fixed the problem with all the assembler tests; Extracted the asserts into methods, avoiding duplicates. * Fixed some test, should be fail the Travis tests. * Fixed one test for Travis. * Fixed the asserts, now find all ecpected items into the output. * Fixed the split message, joined again. * Fixed the last error test for loads binary. * Fixed one missing number in the comparison. * Fixed the first Lint errors. * Added comment in the Dockerfile. The commented line about `git submodule`. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075767 * Removed NASM and Go from the setup. Created a new bash script to install them and added to the Dockerfile. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Added the setup script in the GitHub test workflow. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Testing the emulate cases. It should be fail. I commented the emulation for the address 0x401000. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 * Fixed the different start addresses in the assembler test. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075485 * Experimenting with the python location. Commented the remove python binary and added some logs. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170 * Removed the commands about delete Python and link the Python3. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170
2020-12-31 11:35:52 +08:00
#!/bin/bash -e
echo "# --------------------------------------"
echo "# Install testing tools."
echo "# Only works with Ubuntu / APT."
echo "# --------------------------------------"
# If we are a root in a Docker container and `sudo` doesn't exist
# lets overwrite it with a function that just executes things passed to sudo
# (yeah it won't work for sudo executed with flags)
if [ -f /.dockerenv ] && ! hash sudo 2>/dev/null && whoami | grep root; then
sudo() {
${*}
}
fi
linux() {
uname | grep -i Linux &>/dev/null
}
install_apt() {
sudo apt-get update || true
sudo apt-get install -y nasm
test -f /usr/bin/go || sudo apt-get install -y golang
}
if linux; then
distro=$(grep "^ID=" /etc/os-release | cut -d'=' -f2 | sed -e 's/"//g')
case $distro in
"ubuntu")
install_apt
;;
*) # we can add more install command for each distros.
echo "\"$distro\" is not supported distro. Will search for 'apt' or 'dnf' package managers."
if hash apt; then
install_apt
else
echo "\"$distro\" is not supported and your distro don't have apt or dnf that we support currently."
exit
fi
;;
esac
fi