{"action":"created","issue":{"url":"https://api.github.com/repos/cpputest/cpputest/issues/460","labels_url":"https://api.github.com/repos/cpputest/cpputest/issues/460/labels{/name}","comments_url":"https://api.github.com/repos/cpputest/cpputest/issues/460/comments","events_url":"https://api.github.com/repos/cpputest/cpputest/issues/460/events","html_url":"https://github.com/cpputest/cpputest/issues/460","id":53028315,"number":460,"title":"Testing platform-specific code (-p on GCC in particular)","user":{"login":"arstrube","id":4686469,"avatar_url":"https://avatars.githubusercontent.com/u/4686469?v=3","gravatar_id":"","url":"https://api.github.com/users/arstrube","html_url":"https://github.com/arstrube","followers_url":"https://api.github.com/users/arstrube/followers","following_url":"https://api.github.com/users/arstrube/following{/other_user}","gists_url":"https://api.github.com/users/arstrube/gists{/gist_id}","starred_url":"https://api.github.com/users/arstrube/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arstrube/subscriptions","organizations_url":"https://api.github.com/users/arstrube/orgs","repos_url":"https://api.github.com/users/arstrube/repos","events_url":"https://api.github.com/users/arstrube/events{/privacy}","received_events_url":"https://api.github.com/users/arstrube/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2014-12-29T09:09:58Z","updated_at":"2015-02-17T10:00:37Z","closed_at":null,"body":"I have felt uneasy before about platform-specific code never receiving any direct testing.\r\n\r\nI am not sure that #ifdef'ing these tests into the main test executables is the way to go, either.\r\n\r\nI am about to add some more code (that needs tests) to the platform-specific run-in-separate process function. I propose to look at the testing issue in a wider context and to come up with a concept how platform-specific code can be tested.\r\n\r\nNaturally, we will focus on what can be tested with GCC and Travis-CI. It might make sense to create a separate test executable (so as to not unnecessarily bloat the Travis build). It might also make sense to put the tests into their respective platform-specific locations.\r\n\r\nContributors for other platforms could contribute tests to be run on those platforms only.\r\n\r\nWhat are your thoughts?"},"comment":{"url":"https://api.github.com/repos/cpputest/cpputest/issues/comments/74643299","html_url":"https://github.com/cpputest/cpputest/issues/460#issuecomment-74643299","issue_url":"https://api.github.com/repos/cpputest/cpputest/issues/460","id":74643299,"user":{"login":"arstrube","id":4686469,"avatar_url":"https://avatars.githubusercontent.com/u/4686469?v=3","gravatar_id":"","url":"https://api.github.com/users/arstrube","html_url":"https://github.com/arstrube","followers_url":"https://api.github.com/users/arstrube/followers","following_url":"https://api.github.com/users/arstrube/following{/other_user}","gists_url":"https://api.github.com/users/arstrube/gists{/gist_id}","starred_url":"https://api.github.com/users/arstrube/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arstrube/subscriptions","organizations_url":"https://api.github.com/users/arstrube/orgs","repos_url":"https://api.github.com/users/arstrube/repos","events_url":"https://api.github.com/users/arstrube/events{/privacy}","received_events_url":"https://api.github.com/users/arstrube/received_events","type":"User","site_admin":false},"created_at":"2015-02-17T10:00:37Z","updated_at":"2015-02-17T10:00:37Z","body":"Just noticed how totally off-topic I went with this discussion :-(.\r\n\r\nActually, I have some code ready to submit for running in a separate process, with improved failure messages. What I am looking for is some guidance with how to add tests for it (I ran my own in a separate project). The thing I'd need to do for testing is roughly:\r\n\r\n- Run tests in a separate process (not by running a separate executable with -p). \r\n- Make the test cases crash for a variety of reasons\r\n- Intercept the results / messages and check them against expected results / messages\r\n\r\nI have seen some similar test cases (that test certain output strings) but so far, non that I could directly model.\r\n\r\nMy own tests look like this, but they require manual checking at this point. So they are not really good unit tests.\r\n\r\n```c++\r\nTEST_GROUP(Separate_Process) {};\r\n\r\nTEST(Separate_Process, thisTestIsStillRunAndSucceeds) {\r\n    LONGS_EQUAL(1, 1);\r\n}\r\n\r\nTEST(Separate_Process, thisTestIsStillRunAndFails) {\r\n    LONGS_EQUAL(3, 1);\r\n}\r\n\r\nTEST(Separate_Process, thisTestIsStillRunAndCrashesWithDivisionByZero) {\r\n\tint bar = 0;\r\n\tLONGS_EQUAL(0, 1/bar);\r\n}\r\n\r\nTEST(Separate_Process, thisTestCrashesWithCoreDump) {\r\n\tint* value = NULL;\r\n\tLONGS_EQUAL(15, *value);\r\n}\r\n```\r\n"}}