Reviewed-on: #5
azkoyen_technical_test
Azkoyen technical test implementation. Implemented (mostly) on standard c++ 17 framework, but with Qt wherever was necessary.
Development approach
A Test-Driven Development (TDD) workflow was followed throughout the project. Every component — from the lowest-level file reader to the GUI window — has a corresponding Google Test suite that was written before (or alongside) the production code. This ensures each module behaves correctly in isolation and makes regressions immediately visible.
SysfsRead class
SysfsReader (include/SysfsRead.hpp, src/core/SysfsRead.cxx) is the lowest-level component. It opens a sysfs-like file and translates its raw text content into a SysfsStatus enum:
| File content | Status |
|---|---|
"1" |
Enabled |
"error: temp too high" |
ErrorTempTooHigh |
| empty / whitespace-only | Empty |
| file missing | Unreachable |
| anything else | UnexpectedValue |
The reader never throws on I/O errors; every outcome is expressed through the enum so callers can react without exception handling. A helper trim_in_place strips trailing whitespace and newlines before comparison.
Tests: tests/test_sysfs_read.cxx — covers all five status branches by writing controlled content to a temporary file.
Producer class / thread
Producer (include/Producer.hpp, src/core/Producer.cxx) runs a worker std::thread that periodically polls the SysfsReader and, when the status is Enabled, generates a random integer and forwards it through an injected send_fn callback. The polling interval is 1 second under normal conditions and 7 seconds when the sysfs file reports ErrorTempTooHigh (cool-down).
UnixIpcBridge
Note
why unix domain sockets? Because I have more experience with them under linux than with posix shared memmory and semaphore, and I find them easier to unit-test.
UnixIpcBridge (include/UnixIpcBridge.hpp, src/core/UnixIpcBridge.cxx) is a small helper that connects to a UNIX domain socket and sends a single int per call. It opens a new connection for each value, which keeps the protocol stateless and simple.
Tests: tests/test_unix_ipc.cxx — spins up a fake socket server, sends values through the bridge, and asserts they arrive correctly.