Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Testing with Soletta flows

Bruno Bottazzini edited this page Jun 13, 2016 · 4 revisions

Soletta™ Framework has, in its testing infrastructure, the part that tests its nodes, tied up together in FBP syntax (you can find that in the src/test-fbp directory). Doing like that, one is able to test flow nodes either by issuing sol-fbp-runner or by executing a binary with the code given by sol-fbp-generator run on the .fbp.

Those tests are made possible by the use of a special family of nodes — the test ones. The main nodes are presented there as the generators and validators. The former ease the task of generating sequential packages to feed other nodes input ports (thus testing whatever behavior you want), while the latter ease the task of verifying that the packets coming from the tested nodes output ports match a given criteria (thus validating the test). Let's see an example:

gen(test/boolean-generator:sequence="TTTFTTTTF")

buffer(boolean/buffer:samples=3)
validator(test/boolean-validator:sequence="TFF")

gen OUT -> IN buffer
buffer OUT -> IN validator
validator OUT -> RESULT test(test/result)

Here we have a boolean generator, that will output that pre-defined sequence of values declared (T is true, F is false). There's a boolean buffer node receiving that output on its input port. The buffer holds 3 samples at a time and its default operation option is all_true, meaning it will output true if and only if after it's full, all samples in it are true. If you follow the boolean pattern coming from the gen node, we see that condition will hold true once and then never again, so that the expected buffer output is TFF — exactly what we put on the validator node. The validator node will only output true if the expected pattern occurs on its input. If more packets then are expected come, it will output a packet on it error port.

Because this is a testing flow and we don't want Soletta main loop to run forever, but to stop telling us the test passed or not, we have to make use of the test/result node. That one will exit Soletta with no error code, if fed with a true boolean packet, or with an error code otherwise.

Generators and validators, are naturally there for other Soletta primitive packet types, namely byte, integer, floating point, blob and string.

Clone this wiki locally