Skip to content

Fix CMake syntax to enable memory analyzer tests #5932

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

Merged
merged 4 commits into from
Mar 31, 2021

Conversation

tautschnig
Copy link
Collaborator

"option" requires the help text as second, not as third argument. This
resulted in memory analyzer tests being disabled no matter what the OS
being built on.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link

codecov bot commented Mar 18, 2021

Codecov Report

Merging #5932 (0e6b393) into develop (e76d811) will increase coverage by 0.01%.
The diff coverage is 84.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5932      +/-   ##
===========================================
+ Coverage    75.12%   75.13%   +0.01%     
===========================================
  Files         1435     1444       +9     
  Lines       156301   157261     +960     
===========================================
+ Hits        117416   118165     +749     
- Misses       38885    39096     +211     
Impacted Files Coverage Δ
src/memory-analyzer/gdb_api.cpp 86.89% <50.00%> (ø)
unit/memory-analyzer/gdb_api.cpp 86.46% <94.73%> (ø)
src/util/std_expr.h 92.62% <0.00%> (-0.53%) ⬇️
src/memory-analyzer/gdb_api.h 88.88% <0.00%> (ø)
.../memory-analyzer/memory_analyzer_parse_options.cpp 53.48% <0.00%> (ø)
...rc/memory-analyzer/memory_analyzer_parse_options.h 100.00% <0.00%> (ø)
src/memory-analyzer/analyze_symbol.cpp 72.60% <0.00%> (ø)
src/memory-analyzer/analyze_symbol.h 88.23% <0.00%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f7dcb5...0e6b393. Read the comment docs.

@tautschnig tautschnig removed their assignment Mar 18, 2021
Comment on lines 27 to 42
compile_test_filet() : compiled("test", "")
{
temporary_filet tmp("test", ".c");
std::ofstream of(tmp().c_str());
REQUIRE(of.is_open());

of << "int x;\n"
"float y;\n"
"char z;\n"
"\n"
"char *s = \"abc\";\n"
"int *p;\n"
"void *vp;\n"
"int *np = 0;\n"
"void *vp_string;\n"
"\n"
"void checkpoint()\n"
"{\n"
"}\n"
"void checkpoint2()\n"
"{\n"
"}\n"
"\n"
"void func()\n"
"{\n"
" checkpoint2();\n"
"}\n"
"\n"
"int main()\n"
"{\n"
" x = 8;\n"
" y = 2.5;\n"
" z = 'c';\n"
"\n"
" p = &x;\n"
" vp = (void *)&x;\n"
" vp_string = s;\n"
"\n"
" checkpoint();\n"
"\n"
" return 0;\n"
"}\n";
of.close();

REQUIRE(run("gcc", {"gcc", "-g", "-o", compiled(), tmp()}) == 0);
}

temporary_filet compiled;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems unnecessarily ugly, is there a reason to do it this way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If, as was the case before, we keep the contents in a separate file, then this file must either be included in the compiled unit test binary (e.g., via #include), or else the compiled unit test binary necessarily relies on the source tree being present as well. It seems reasonable to assume that the source tree will be present, but then also the exact location of the file must be known.

I made these changes as I found the above conditions not to be satisfied in my ad-hoc testing for I wasn't aware where the unit test had to be run from to make things work. That being said, we have the same problem in other unit tests. So maybe it's not all that important to fix if people are concerned about this approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the motivation, I was more considering that there might be a prettier way to have the text inside the file.

Comment on lines 119 to 92
std::ofstream of(tmp().c_str());
REQUIRE(of.is_open());

of << "abc\n"
"aaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
"xyz";
of.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, is this the best way to do this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've modified this to use ansi-c/file_converter and #include them instead.

@tautschnig tautschnig force-pushed the memory-analyzer-tests branch from 6e20e6d to d748fa0 Compare March 22, 2021 09:42
@tautschnig tautschnig force-pushed the memory-analyzer-tests branch from d748fa0 to 047fb2e Compare March 22, 2021 14:47
@tautschnig tautschnig self-assigned this Mar 30, 2021
When gdb wasn't available, the forked child would not terminate and the
parent would wait forever.
Make the unit tests less fragile by not relying on a particular
directory that they are being run from. Test files had to be loaded from
a specific location; instead, place them in the source code and generate
temporary files at runtime.
"option" requires the help text as second, not as third argument. This
resulted in memory analyzer tests being disabled no matter what the OS
being built on.
This test isn't strictly dependent on memory-analyzer being available,
but is only of interest if that is the case.
@tautschnig tautschnig merged commit 11149ef into diffblue:develop Mar 31, 2021
@tautschnig tautschnig deleted the memory-analyzer-tests branch March 31, 2021 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants