Skip to content

Add check that gdb is on the path #4420

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 1 commit into from
Mar 24, 2019

Conversation

xbauch
Copy link
Contributor

@xbauch xbauch commented Mar 22, 2019

No functional change only wrapped the test-cases in if-statements checking
that gdb can be called. The rest is clang-formatting.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • 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).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@@ -104,94 +104,111 @@ void gdb_api_internals_test()
TEST_CASE("gdb api internals test", "[core][memory-analyzer]")
{
#ifdef RUN_GDB_API_TESTS
gdb_api_internals_test();
int has_gdb = system("gdb --version");
Copy link
Contributor

Choose a reason for hiding this comment

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

How about bool has_gdb = (system("gdb --version") == 0);?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@xbauch xbauch force-pushed the fix/gdb-api-unit-test branch from 65a30ea to b3c6c40 Compare March 22, 2019 14:50
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 65a30ea).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105460761
Status will be re-evaluated on next push.
Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)

  • the author is not in the list of contributors (e.g. first-time contributors).

  • the compatibility was already broken by an earlier merge.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: b3c6c40).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105462720

@@ -104,94 +104,111 @@ void gdb_api_internals_test()
TEST_CASE("gdb api internals test", "[core][memory-analyzer]")
{
#ifdef RUN_GDB_API_TESTS
gdb_api_internals_test();
bool has_gdb = system("gdb --version") == 0;
Copy link
Member

Choose a reason for hiding this comment

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

const

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

}
catch(const gdb_interaction_exceptiont &e)
{
std::cerr
Copy link
Member

Choose a reason for hiding this comment

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

Don't we use message handlers in unit tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At least not consistently, I found a few other tests that call std:cerr. Should I modify this one?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@peterschrammel What value would the use of message handlers add here?

#endif
}

TEST_CASE("gdb api test", "[core][memory-analyzer]")
{
#ifdef RUN_GDB_API_TESTS
compile_test_file();

bool has_gdb = system("gdb --version") == 0;
Copy link
Member

Choose a reason for hiding this comment

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

const

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@@ -104,94 +104,111 @@ void gdb_api_internals_test()
TEST_CASE("gdb api internals test", "[core][memory-analyzer]")
{
#ifdef RUN_GDB_API_TESTS
gdb_api_internals_test();
const bool has_gdb = system("gdb --version") == 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer if run("gdb", {"gdb", "--version"}) (from util/run.{h,cpp}) were used in place of system (system is really heavy-weight as it starts a shell). But I do acknowledge that we already use system in this file, though I think that call should equally be replaced.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced. The other use was replaced in the next commit.

#endif
}

TEST_CASE("gdb api test", "[core][memory-analyzer]")
{
#ifdef RUN_GDB_API_TESTS
compile_test_file();

const bool has_gdb = system("gdb --version") == 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As above - or maybe even factor out this check (and the SECTION) into a separate procedure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
catch(const gdb_interaction_exceptiont &e)
{
std::cerr
Copy link
Collaborator

Choose a reason for hiding this comment

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

@peterschrammel What value would the use of message handlers add here?

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: 2af9fff).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105533191

@martin-cs
Copy link
Collaborator

OK, so today I'm going to be that bell-end that uses a simple patch to complain about something only semi-related. Given that : why only gdb? I believe there are various other tools that implement compatable text annd / or protocol interfaces. Explicitly testing for gdb seems to tie us to that.

( Comment not review so you can (and I will not be even the slightest bit offended) ignore this. )

@xbauch xbauch force-pushed the fix/gdb-api-unit-test branch from 2af9fff to b20e39c Compare March 23, 2019 20:37
@xbauch
Copy link
Contributor Author

xbauch commented Mar 23, 2019

@martin-cs The context is that this particular unit-test hangs indefinitely if the system does not have gdb on the PATH. I guess if there are other tools with similar interface they don't cause this problem (or at least not when running unit).

@tautschnig
Copy link
Collaborator

@xbauch clang-format asks for reformatting two lines.

@xbauch xbauch force-pushed the fix/gdb-api-unit-test branch from b20e39c to 3a1aa7c Compare March 23, 2019 21:45
@martin-cs
Copy link
Collaborator

@xbauch : thanks for the explanation.

@xbauch xbauch force-pushed the fix/gdb-api-unit-test branch from 3a1aa7c to 96e9646 Compare March 24, 2019 09:52
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: 96e9646).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105574298

{
REQUIRE(has_gdb);
}
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't this now always return false, and thus effectively disable all the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tautschnig sorry about this type: should be fixed now.

No functional change.  Only wraps the test cases in an if-statements checking
the presence of gdb.
@xbauch xbauch force-pushed the fix/gdb-api-unit-test branch from 96e9646 to 01da544 Compare March 24, 2019 17:03
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: 01da544).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105588250

@tautschnig tautschnig merged commit ccd30dd into diffblue:develop Mar 24, 2019
@xbauch xbauch deleted the fix/gdb-api-unit-test branch June 10, 2019 12:30
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.

8 participants