sasa issueshttps://gricad-gitlab.univ-grenoble-alpes.fr/verimag/synchrone/sasa/-/issues2021-03-03T08:31:21+01:00https://gricad-gitlab.univ-grenoble-alpes.fr/verimag/synchrone/sasa/-/issues/16Drive rdbg tests in a more portable way2021-03-03T08:31:21+01:00Gabriel B. Sant'Annabaiocchi.gabriel@gmail.comDrive rdbg tests in a more portable wayTests using rdbg simulate user input by piping `echo` output to rdbg, eg. in `test/dijkstra-ring/Makefile`:
```make
rdbg_test: ring.ml
echo "\nnr\nsd\nq\n" | rdbg -o ring.rif -l 10000 -sut "$(sasa) -vl 1 ring.dot -dd"
```
But [this ...Tests using rdbg simulate user input by piping `echo` output to rdbg, eg. in `test/dijkstra-ring/Makefile`:
```make
rdbg_test: ring.ml
echo "\nnr\nsd\nq\n" | rdbg -o ring.rif -l 10000 -sut "$(sasa) -vl 1 ring.dot -dd"
```
But [this is not portable](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html) as we are using escaped characters:
> It is not possible to use echo portably across all POSIX systems unless both -n (as the first argument) **and escape sequences** are omitted.
In fact, in my own machine the command above causes rdbg to interpret "\nnr\nsd\nq\n" as a single user input, yielding the error
```
invalid key (\nnr\nsd\nq\n), try again
```
Posix suggests using `printf` instead:
> New applications are encouraged to use printf instead of echo.Gabriel B. Sant'Annabaiocchi.gabriel@gmail.comGabriel B. Sant'Annabaiocchi.gabriel@gmail.com