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

testing: revive core unit tests #69

Closed
derekbruening opened this issue Nov 27, 2014 · 3 comments
Closed

testing: revive core unit tests #69

derekbruening opened this issue Nov 27, 2014 · 3 comments

Comments

@derekbruening
Copy link
Contributor

From [email protected] on March 03, 2009 18:22:47

in converting to cmake ( issue #19 ) I threw out the old unit test rules b/c
we had so few tests and they were mostly broken

this case covers reviving not just the build rules but also writing more
tests and adding them to our nightly or pre-commit test suites

Original issue: http://code.google.com/p/dynamorio/issues/detail?id=69

@derekbruening
Copy link
Contributor Author

From [email protected] on October 25, 2011 19:28:53

I would really like to be able to write unit tests for code in DynamoRIO. How can we go about doing this?

I see two issues:
A. How do we build DR in such a way that we can access the functions under test?
B. Which testing framework do we use?

On Linux, A is easy, because we can just remove -fvisibility=hidden when building unit tests, and suddenly everything is exported, and our test exe just links against libdynamorio.so. On Windows, we could add a macro like EXPORT_FOR_TESTING or some shorter name and sprinkle that throughout the code when we want to call something from a test, but that's fairly ugly. If we do that, we should leave -fvisibility alone so the export behavior is consistent across platforms.

For B, My preference would be to use gtest, since that integrates well into the buildbot and it's familiar to any developers we might want to attract within Google. I also looked for a good straight C test framework for students to use when TAing 6.172, and I couldn't find any. The main drawback of gtest is that it adds a build dependency, and we'd have to either request users to add it or create a third_party directory. I think gtest being C++ is a non-issue because these unit tests will all be tiny little exes that don't need to run alongside an application and therefore will have no resource conflicts. The unit test code can be C++ and still use DynamoRIO conventions, with the exception of the recommendation against using underscores in test names: https://code.google.com/p/googletest/wiki/FAQ#Why_should_not_test_case_names_and_test_names_contain_underscore

Owner: [email protected]

@derekbruening
Copy link
Contributor Author

From [email protected] on October 26, 2011 07:01:57

The unit tests that we had in place had access to static functions and variables as well (a critical feature), and were built as an executable (note the main() function). The idea was that each file would have its own tests and be built as its own executable. The code is under a _UNIT_TEST define. See vmareas.c, options.c, utils.c, stats.c.

@derekbruening
Copy link
Contributor Author

From [email protected] on February 23, 2012 10:47:23

This issue was closed by revision r1269 .

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant