{"action":"created","issue":{"url":"https://api.github.com/repos/cgreen-devs/cgreen/issues/6","labels_url":"https://api.github.com/repos/cgreen-devs/cgreen/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/cgreen-devs/cgreen/issues/6/comments","events_url":"https://api.github.com/repos/cgreen-devs/cgreen/issues/6/events","html_url":"https://github.com/cgreen-devs/cgreen/issues/6","id":104380844,"number":6,"title":"exit behavior of forked processed messes with lcov/gcov","user":{"login":"gardenia","id":49684,"avatar_url":"https://avatars.githubusercontent.com/u/49684?v=3","gravatar_id":"","url":"https://api.github.com/users/gardenia","html_url":"https://github.com/gardenia","followers_url":"https://api.github.com/users/gardenia/followers","following_url":"https://api.github.com/users/gardenia/following{/other_user}","gists_url":"https://api.github.com/users/gardenia/gists{/gist_id}","starred_url":"https://api.github.com/users/gardenia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gardenia/subscriptions","organizations_url":"https://api.github.com/users/gardenia/orgs","repos_url":"https://api.github.com/users/gardenia/repos","events_url":"https://api.github.com/users/gardenia/events{/privacy}","received_events_url":"https://api.github.com/users/gardenia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-02T00:27:48Z","updated_at":"2015-09-02T05:59:41Z","closed_at":null,"body":"[ mailing list issue (manually) imported from http://sourceforge.net/p/cgreen/mailman/cgreen-devel/thread/CANvsC2voB3-GpT%2BQ05fEXdjJJee5sQF2fzGN1ByTd0OsswinpA@mail.gmail.com/\r\n]\r\n\r\nIt appears that cgreen's \"run in a child process\" model is messing up\r\nmy coverage data somehow.  Or maybe that isn't the reason at all.  But\r\nit certainly seems to affect the outcome.  When I google I don't see\r\nmuch discussion of this as a common problem apart from some mutterings\r\nabout GTEST in this context but not enough for me to think it is a\r\nwell known problem.\r\n\r\nWhen I examine the ENV variables in both cases they look the same.\r\nWhen I run strace it looks like they are both trying to write gcda\r\nfiles to the same place.\r\n\r\nI can boil it down to a suite with one test.  If I use\r\n\"run_test_suite\" (which runs in a child process) my test run yields no\r\ncoverage output.  If I use \"run_single_test\" (which runs in the\r\ncurrent process) it works as expected.\r\n\r\nSteps to reproduce (see below source file):\r\n\r\n```\r\n## this produces 45% line coverage\r\nlcov --base-directory . --directory . --zerocounters -q\r\n./test.exe\r\nlcov --base-directory . --directory . -c -o coverage.info\r\n genhtml -o coverage coverage.info\r\n```\r\n```\r\n## this produces 100% line coverage\r\nlcov --base-directory . --directory . --zerocounters -q\r\n./test.exe xxx # <- don't fork child process\r\nlcov --base-directory . --directory . -c -o coverage2.info\r\ngenhtml -o coverage coverage2.info\r\n```\r\nWhat am I missing?\r\n\r\nCheers,\r\nColm\r\n\r\n\r\n```\r\n// test.c\r\n//\r\n// compile with: -g -fprofile-arcs -ftest-coverage\r\n\r\n#include <stdio.h>\r\n#include <stdlib.h>\r\n#include <string.h>\r\n\r\n#include <cgreen/cgreen.h>\r\n\r\nint do_something()\r\n{\r\n    return -2;\r\n}\r\n\r\nEnsure (xxx)\r\n{\r\n    assert_that(do_something(), is_equal_to(-2));\r\n}\r\n\r\nint main(int argc, char **argv) {\r\n    TestSuite *suite = create_test_suite();\r\n\r\n    add_test(suite, xxx);\r\n\r\n    if (argc > 1) {\r\n        return run_single_test(suite, argv[1], create_text_reporter());\r\n    }\r\n\r\n    return run_test_suite(suite, create_text_reporter());\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/cgreen-devs/cgreen/issues/comments/136945815","html_url":"https://github.com/cgreen-devs/cgreen/issues/6#issuecomment-136945815","issue_url":"https://api.github.com/repos/cgreen-devs/cgreen/issues/6","id":136945815,"user":{"login":"thoni56","id":204496,"avatar_url":"https://avatars.githubusercontent.com/u/204496?v=3","gravatar_id":"","url":"https://api.github.com/users/thoni56","html_url":"https://github.com/thoni56","followers_url":"https://api.github.com/users/thoni56/followers","following_url":"https://api.github.com/users/thoni56/following{/other_user}","gists_url":"https://api.github.com/users/thoni56/gists{/gist_id}","starred_url":"https://api.github.com/users/thoni56/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoni56/subscriptions","organizations_url":"https://api.github.com/users/thoni56/orgs","repos_url":"https://api.github.com/users/thoni56/repos","events_url":"https://api.github.com/users/thoni56/events{/privacy}","received_events_url":"https://api.github.com/users/thoni56/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T05:59:41Z","updated_at":"2015-09-02T05:59:41Z","body":"One suggestion would be to do what Jeb did in the post referred. Wrap it in #ifdef GCOV. That would mean that you get a choice, ungarbled output or coverage. I'm thinking that if your gcov'ing you would not care that much about posssibly garbled output or even run in an environment where you wouldn't even notice."}}