[riot-notifications] [RIOT-OS/RIOT] tests/bloom_bytes: replace %f with fmt/print_float (#11053)

Gaƫtan Harter notifications at github.com
Thu Feb 21 16:25:39 CET 2019


### Contribution description

Even if using `%f` the `printf_float` module was not used.

When running the test on `samr21-xpro` and `arduino-mega2560` the float
is not printed correctly.

 * samr21-xpro ` false positive rate.`
 * arduino-mega2560 `? false positive rate.`

As the arduino-mega2560 does not handle printf_float use
`fmt/print_float`.

The output should be flushed before using fmt/print functions if
available as they do not use `printf` buffer.


### Testing procedure

Run the `tests/bloom_bytes` test on `samr21-xpro` and `arduino-mega2560` (or same family).

In master the `false positive rate` is not printed correctly.
The updated test can be run without the last commit to verify also it is failing.


New output with:

`samr21-xpro`

```
2019-02-21 15:59:12,498 - INFO # main(): Tmain(): This is RIOT! (Version: 2019.04-devel-242-ga554ef-pr/tests/bloom_bytes/float_handling)                                                                                                                                                  
2019-02-21 15:59:12,500 - INFO # Testing Bloom filter.                                                                                                                                                                                                                                    
2019-02-21 15:59:12,500 - INFO #                                                                                                                                                                                                                                                          
2019-02-21 15:59:12,501 - INFO # m: 4096 k: 8                                                                                                                                                                                                                                             
2019-02-21 15:59:12,502 - INFO #                                                                                                                                                                                                                                                          
2019-02-21 15:59:12,768 - INFO # adding 512 elements took 262ms                                                                                                                                                                                                                           
2019-02-21 15:59:15,227 - INFO # checking 10000 elements took 2448ms                                                                                                                                                                                                                      
2019-02-21 15:59:15,227 - INFO #                                                                                                                                                                                                                                                          
2019-02-21 15:59:15,230 - INFO # 267 elements probably in the filter.                                                                                                                                                                                                                     
2019-02-21 15:59:15,233 - INFO # 9733 elements not in the filter.                                                                                                                                                                                                                         
2019-02-21 15:59:15,236 - INFO # 0.026700 false positive rate.                                                                                                                                                                                                                            
2019-02-21 15:59:15,236 - INFO #                             
2019-02-21 15:59:15,237 - INFO # All done!
```

`arduino-mega2560`

```
2019-02-21 16:00:13,413 - INFO # main(): This is RIOT! (Version: 2019.04-devel-242-ga554ef-pr/tests/bloom_bytes/float_handling)                                                                                                                                                           
2019-02-21 16:00:13,438 - INFO # Testing Bloom filter.                                                                                                                                                                                                                                    
2019-02-21 16:00:13,438 - INFO #                                                                                                                                                                                                                                                          
2019-02-21 16:00:13,450 - INFO # m: 4096 k: 8                                                                                                                                                                                                                                             
2019-02-21 16:00:13,450 - INFO #
2019-02-21 16:00:20,200 - INFO # adding 512 elements took 6716ms
2019-02-21 16:01:02,354 - INFO # checking 10000 elements took 42126ms
2019-02-21 16:01:02,358 - INFO #
2019-02-21 16:01:02,395 - INFO # 267 elements probably in the filter.
2019-02-21 16:01:02,432 - INFO # 9733 elements not in the filter.
2019-02-21 16:01:02,461 - INFO # 0.026700 false positive rate.
2019-02-21 16:01:02,461 - INFO #
2019-02-21 16:01:02,473 - INFO # All done!
```

It is still working in `native`:

```
main(): This is RIOT! (Version: 2019.04-devel-243-g642f5e-pr/tests/bloom_bytes/float_handling)
Testing Bloom filter.

m: 4096 k: 8

adding 512 elements took 4ms
checking 10000 elements took 35ms

267 elements probably in the filter.
9733 elements not in the filter.
0.026699 false positive rate.

All done!
```

### Issues/PRs references

Fixes https://github.com/RIOT-OS/RIOT/issues/11052
You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/11053

-- Commit Summary --

  * tests/bloom_bytes: define regexp as raw strings
  * tests/bloom_bytes: replace %f with fmt/print_float
  * tests/bloom_bytes: explicitely expect a float

-- File Changes --

    M tests/bloom_bytes/Makefile (2)
    M tests/bloom_bytes/main.c (10)
    M tests/bloom_bytes/tests/01-run.py (10)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/11053.patch
https://github.com/RIOT-OS/RIOT/pull/11053.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11053
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190221/ce458573/attachment-0001.html>


More information about the notifications mailing list