{"id":16113249,"url":"https://github.com/patryk27/avr-tester","last_synced_at":"2025-03-16T08:32:41.311Z","repository":{"id":57698298,"uuid":"495965976","full_name":"Patryk27/avr-tester","owner":"Patryk27","description":"`#[test]` meets simavr!","archived":false,"fork":false,"pushed_at":"2024-10-29T19:53:26.000Z","size":203,"stargazers_count":23,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-14T20:02:11.223Z","etag":null,"topics":["avr","framework","microcontroller","rust","simavr","test","testing"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Patryk27.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-24T19:45:11.000Z","updated_at":"2025-02-20T00:26:08.000Z","dependencies_parsed_at":"2024-01-02T16:02:13.430Z","dependency_job_id":null,"html_url":"https://github.com/Patryk27/avr-tester","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":"0.038461538461538436","last_synced_commit":"5bccb21834c21d1d26eca5234b00e10571610db8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patryk27%2Favr-tester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patryk27%2Favr-tester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patryk27%2Favr-tester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patryk27%2Favr-tester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Patryk27","download_url":"https://codeload.github.com/Patryk27/avr-tester/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243807367,"owners_count":20350992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avr","framework","microcontroller","rust","simavr","test","testing"],"created_at":"2024-10-09T20:10:41.905Z","updated_at":"2025-03-16T08:32:41.300Z","avatar_url":"https://github.com/Patryk27.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# avr-tester \u0026emsp; [![crates-badge]][crates-link] [![docs-badge]][docs-link]\n\n[crates-badge]: https://img.shields.io/crates/v/avr-tester.svg\n[crates-link]: https://crates.io/crates/avr-tester\n[docs-badge]: https://img.shields.io/docsrs/avr-tester\n[docs-link]: https://docs.rs/avr-tester\n\nFramework for testing [AVR] binaries, powered by [simavr].\n\ntl;dr get your microcontroller's firmware black-box-tested in seconds!\n\n[AVR]: https://en.wikipedia.org/wiki/AVR_microcontrollers\n[simavr]: https://github.com/buserror/simavr\n\n## Getting started\n\nCreate a crate dedicated to your firmware's tests:\n\n```shell\n$ cargo new firmware-tests --lib\n```\n\n... add `avr-tester` as its dependency:\n\n```toml\n# firmware-tests/Cargo.toml\n\n[dependencies]\navr-tester = \"0.3\"\n```\n\n... and start writing tests:\n\n```rust\n// firmware-tests/src/lib.rs\n\nuse avr_tester::*;\n\nfn avr() -\u003e AvrTester {\n    AvrTester::atmega328p()\n        .with_clock_of_16_mhz()\n        .load(\"../../firmware/target/atmega328p/release/firmware.elf\")\n}\n\n// Assuming `firmware` implements a ROT-13 encoder:\n\n#[test]\nfn short_text() {\n    let mut avr = avr();\n\n    // Let's give our firmware a moment to initialize:\n    avr.run_for_ms(1);\n\n    // Now, let's send the string:\n    avr.uart0().write(\"Hello, World!\");\n\n    // ... give the AVR a moment to retrieve it \u0026 send back, encoded:\n    avr.run_for_ms(1);\n\n    // ... and, finally, let's assert the outcome:\n    assert_eq!(\"Uryyb, Jbeyq!\", avr.uart0().read::\u003cString\u003e());\n}\n\n#[test]\nfn long_text() {\n    let mut avr = avr();\n\n    avr.run_for_ms(1);\n    avr.uart0().write(\"Lorem ipsum dolor sit amet, consectetur adipiscing elit\");\n    avr.run_for_ms(10);\n\n    assert_eq!(\n        \"Yberz vcfhz qbybe fvg nzrg, pbafrpgrghe nqvcvfpvat ryvg\",\n        avr.uart0().read::\u003cString\u003e(),\n    );\n}\n```\n\n... having the tests ready, just run `cargo test` inside `firmware-tests` :-)\n\nSince AvrTester emulates an actual AVR, you don't have to modify your firmware\nat all - it can use timers, GPIOs etc. and everything should just work ™.\n\nIn fact, your project doesn't even have to be written in Rust - you can create\nRust tests for a firmware written in C, Zig and anything else!\n\n## Features\n\n- [Analog pins](avr-tester/tests/examples/analog_pins.rs),\n- [Custom components](avr-tester/tests/examples/shift_register.rs),\n- [Digital pins](avr-tester/tests/examples/digital_pins.rs),\n- [SPIs](avr-tester/tests/examples/spi.rs),\n- [TWIs](avr-tester/tests/examples/twi.rs) (aka I2C),\n- [Timeouts](avr-tester/tests/examples/timeout.rs),\n- [UARTs](avr-tester/tests/examples/uart.rs).\n\nSee more: \u003c./avr-tester/tests/examples\u003e.\n\n## Supported platforms\n\nSee: [simavr-ffi](https://github.com/Patryk27/simavr-ffi).\n\n## Roadmap\n\nFollowing features are supported by simavr, but haven't been yet exposed in\nAvrTester:\n\n- Interrupts,\n- EEPROM,\n- Watchdog,\n- USB.\n\nYour firmware can use those features, you just won't be able to test them.\n\n## Caveats\n\n- Triggering AVR's sleep mode will cause the Rust code to panic, because the\n  only way to wake an AVR is to trigger an interrupt and those are not yet\n  supported.\n\n## Contributing\n\nPull requests are very much welcome!\n\n### Tests\n\nUse `just test` to test AvrTester (so meta!) -- note that you might need some\nadditional dependencies:\n\n#### ... using Nix (Linux / Mac)\n\n```shell\n$ nix develop\n# and then `just test`\n```\n\n#### ... on Ubuntu\n\n```shell\n$ sudo apt install avr-libc gcc-avr\n# and then `just test`\n```\n\n## License\n\nCopyright (c) 2022 Patryk Wychowaniec \u003cpwychowaniec@pm.me\u003e.    \nLicensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatryk27%2Favr-tester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatryk27%2Favr-tester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatryk27%2Favr-tester/lists"}