{"action":"created","issue":{"url":"https://api.github.com/repos/modm-io/modm/issues/26","repository_url":"https://api.github.com/repos/modm-io/modm","labels_url":"https://api.github.com/repos/modm-io/modm/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/modm-io/modm/issues/26/comments","events_url":"https://api.github.com/repos/modm-io/modm/issues/26/events","html_url":"https://github.com/modm-io/modm/pull/26","id":327089335,"number":26,"title":"[test] SpiMasterMock for device driver unittests","user":{"login":"rleh","id":2820734,"avatar_url":"https://avatars0.githubusercontent.com/u/2820734?v=4","gravatar_id":"","url":"https://api.github.com/users/rleh","html_url":"https://github.com/rleh","followers_url":"https://api.github.com/users/rleh/followers","following_url":"https://api.github.com/users/rleh/following{/other_user}","gists_url":"https://api.github.com/users/rleh/gists{/gist_id}","starred_url":"https://api.github.com/users/rleh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rleh/subscriptions","organizations_url":"https://api.github.com/users/rleh/orgs","repos_url":"https://api.github.com/users/rleh/repos","events_url":"https://api.github.com/users/rleh/events{/privacy}","received_events_url":"https://api.github.com/users/rleh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-28T18:00:18Z","updated_at":"2018-05-29T01:04:24Z","closed_at":"2018-05-28T23:38:28Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/modm-io/modm/pulls/26","html_url":"https://github.com/modm-io/modm/pull/26","diff_url":"https://github.com/modm-io/modm/pull/26.diff","patch_url":"https://github.com/modm-io/modm/pull/26.patch"},"body":"To be able to test drivers for external peripherals connected via SPI to the microcontroller I propose `SpiMasterMock`.\r\n\r\n`SpiMasterMock` utilizes the same interface as all *SpiMaster*-implementations (`BitBangSpiMaster`, `SpiMasterX`, ...), has no hardware dependencies and buffers the data sent from the device driver.\r\n\r\nUnittests can access the buffer using\r\n```C++\r\nstd::size_t length = SpiMasterMock::getTxBufferLength();\r\n\r\nuint8_t buffer[length];\r\nSpiMasterMock::popTxBuffer(buffer);\r\n```\r\nand compare it to the expected byte-sequence.\r\n\r\nAdditionally the unittest may inject data that the device driver reads from *SpiMasterMock*:\r\n```C++\r\nuint8_t buffer[] = {0x80, 0xFF, 0x00, 0x42};\r\nSpiMasterMock::appendRxBuffer(buffer, 4);\r\n```\r\n---\r\nAs an example the unittest for the Ltc2984 driver is extended."},"comment":{"url":"https://api.github.com/repos/modm-io/modm/issues/comments/392625191","html_url":"https://github.com/modm-io/modm/pull/26#issuecomment-392625191","issue_url":"https://api.github.com/repos/modm-io/modm/issues/26","id":392625191,"user":{"login":"rleh","id":2820734,"avatar_url":"https://avatars0.githubusercontent.com/u/2820734?v=4","gravatar_id":"","url":"https://api.github.com/users/rleh","html_url":"https://github.com/rleh","followers_url":"https://api.github.com/users/rleh/followers","following_url":"https://api.github.com/users/rleh/following{/other_user}","gists_url":"https://api.github.com/users/rleh/gists{/gist_id}","starred_url":"https://api.github.com/users/rleh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rleh/subscriptions","organizations_url":"https://api.github.com/users/rleh/orgs","repos_url":"https://api.github.com/users/rleh/repos","events_url":"https://api.github.com/users/rleh/events{/privacy}","received_events_url":"https://api.github.com/users/rleh/received_events","type":"User","site_admin":false},"created_at":"2018-05-29T01:04:24Z","updated_at":"2018-05-29T01:04:24Z","author_association":"CONTRIBUTOR","body":"I discovered one issue: The second unittest that uses `SpiMasterMock` might get data from the first unittest instead of empty buffers.\r\n\r\nTwo possible solutions:\r\n* Add a dummy template parameter to the class.\r\n* Add a `init()`/`clear()` function to the class.\r\nOther ideas?\r\n\r\ncc @salkinium "}}
{"actor":{"display_login":"rleh"}}