Skip to content

Program Analysis Testing

Ryan Sullivant edited this page May 31, 2022 · 5 revisions

Testing Suites

GCC Plugin

Test Python file: automatates/tests/program_analysis/GCC2GrFN/test_gcc_plugin_c.py This suite runs the GCC plugin to create a gcc_ast.json file, and compares the created file from an expected json file. To perform the comparison, we the SimpleNamespace from Python's types module. Basically, SimpleNamespace allows us to use dot . access on elements of the json instead of dictionary like access. In the test file, we define functions to compare the generated gcc json with the expected gcc json. These comparison functions only check a limited number of fields from the json, but they are easily extensible.

One thing to note with this test suite is the inclusion of the global list GLOBAL_NAMES_TO_SKIP. These identifiers are skipped when comparing the global variables of the created and expected jsons. This list of identifiers was added because the globals found when running the plugin locally vs running the plugin through Github Actions did not match. The globals from included standard library files are added to the json by the plugin, and their was a difference between the local and remote standard library files. This difference meant local expected jsons and newly generated jsons on Github Actions would not match, which necessitated the introduction of the list GLOBAL_NAMES_TO_SKIP.

GCC to CAST

The GCC to CAST testing suite utilizes pytest's parameterize functionality to automatically generate tests based on generated test data. More specifically, `

CAST to AnnCAST

CAST to GrFN

Clone this wiki locally