Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow tests to be run in other places than /tmp #739

Merged
merged 7 commits into from Oct 8, 2021

Conversation

theguy147
Copy link
Collaborator

@theguy147 theguy147 commented Oct 1, 2021

feat: allow tests to be run in other places than /tmp

Description/Motivation/Screenshots

Today I tested GEF on a non-rooted Android device and had to manually make quite some changes to have the tests run because I didn't have access to the tmp/ filesystem.

This PR allows changing the defaults for TMPDIR (where the binaries are compiled to and used for the tests and where trace-run saves the traces while testing) by setting an environment variable for easier testing in different environments.

Changes:

  • Allow changing TMPDIR by using an environment variable of the same name instead of having hard coded paths for testing (default is still /tmp as before).
  • Don't copy gef.py to TMPDIR but leave it in-place for testing (because there doesn't seem to be a need to copy it over)
  • Allow changing GEF_PATH by using an environment variable to use quickly switch between different gef.py versions without VCS (useful for automated testing of different GEF versions)
  • Makefile targets are set to .PHONY now
  • Create TMPDIR if it doesn't exist
  • Remove cleaning steps from test target in Makefile so e.g. the binaries don't need to be rebuild between every test run (instead introduce separate clean target).
  • Allow running single test modules with e.g. make TestGefCommandsUnit (capitalized)
  • Allow running single tests (or several) using patterns with e.g. make test_cmd_elf_info (specifically that one test) or make test_cmd_heap_ (every test starting with "test_cmd_heap")

EDIT:

  • Allow debugging tests on failure by setting DEBUG environment variable: DEBUG=1 make test
  • get_shellcode() now saves the downloaded shellcode to gef.tempdir instead of a hardcoded /tmp

How Has This Been Tested?

Architecture Yes/No Comments
x86-32 ✔️
x86-64 ✔️
ARM ✖️
AARCH64 ✖️
MIPS ✖️
POWERPC ✖️
SPARC ✖️
RISC-V ✖️
make test ✔️

Checklist

  • My PR was done against the dev branch, not master.
  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • My change adds tests as appropriate.
  • I have read and agree to the CONTRIBUTING document.

@theguy147 theguy147 mentioned this pull request Oct 1, 2021
5 tasks
@theguy147 theguy147 self-assigned this Oct 1, 2021
tests/helpers.py Outdated Show resolved Hide resolved
tests/helpers.py Outdated Show resolved Hide resolved
tests/runtests.py Outdated Show resolved Hide resolved
Copy link
Owner

@hugsy hugsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty awesome

@hugsy hugsy added this to the Release: 2021.10 milestone Oct 8, 2021
@Grazfather Grazfather merged commit 078ce33 into hugsy:dev Oct 8, 2021
@theguy147 theguy147 deleted the test_filepaths branch October 8, 2021 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants