Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yugr/flakyiterators
A fast and dirty checker based on libclang which detects non-deterministic iteration
https://github.com/yugr/flakyiterators
flaky-tests libclang nondeterminism static-analysis
Last synced: about 6 hours ago
JSON representation
A fast and dirty checker based on libclang which detects non-deterministic iteration
- Host: GitHub
- URL: https://github.com/yugr/flakyiterators
- Owner: yugr
- License: mit
- Created: 2021-09-12T10:03:34.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-07-01T19:52:15.000Z (over 2 years ago)
- Last Synced: 2023-03-08T22:25:44.308Z (over 1 year ago)
- Topics: flaky-tests, libclang, nondeterminism, static-analysis
- Language: C++
- Homepage:
- Size: 45.9 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![License](http://img.shields.io/:license-MIT-blue.svg)](https://github.com/yugr/FlakyIterators/blob/master/LICENSE.txt)
[![Build Status](https://github.com/yugr/FlakyIterators/actions/workflows/ci.yml/badge.svg)](https://github.com/yugr/FlakyIterators/actions)
[![codecov](https://codecov.io/gh/yugr/FlakyIterators/branch/master/graph/badge.svg)](https://codecov.io/gh/yugr/FlakyIterators)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/yugr/FlakyIterators.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/yugr/FlakyIterators/alerts/)
[![Coverity Scan](https://scan.coverity.com/projects/yugr-FlakyIterators/badge.svg)](https://scan.coverity.com/projects/yugr-FlakyIterators)A fast and dirty checker which detects non-deterministic iteration e.g.
```
std::unordered_map<...> map;
for (auto [k, v] : map) {
...
}std::map map;
for (auto [k, v] : map) {
...
}
```Warnings are reported only if functions with predefined names (e.g. `printf`)
are encountered in a loop.# Comparison with Clang Static Analyzer
CSA's [PointerIteration](https://clang.llvm.org/docs/analyzer/checkers.html#alpha-nondeterminism-pointeriteration-c) does not report nondeterministic iteration neither over ordered containers of pointers, nor over unordered containers of non-pointers.
# How to build
To build, install (on Debian/Ubuntu) `llvm`, `libclang-dev` and `libpcre3-dev`:
```
$ sudo apt-get install llvm libclang-dev libpcre3-dev
```
and run
```
$ make clean all
```To build debug or sanitized versions run `make` with `DEBUG=1`, `ASAN=1` or `UBSAN=1`.
# How to use
Run `bin/find-flaky` on files you are interested in:
```
$ bin/find-flaky tests/3-unordered-map-notok.cc
find-flaky: warning: calling IO function 'printf' inside flaky loop
```By default tool looks for most common IO functions (like `printf`)
but you provide your own patterns:
```
$ cat patterns.txt
# A useful comment
my_debug_fun
# Another one
other_fun
$ bin/find-flaky --patterns patterns.txt ...
```Custom compile flags (usually `-D` and `-I`) can be supplied with `--cflags` parameter and
verbosity can be set with `-v` flag.
For additional options run `bin/find-flaky -h`.# How to test
Build and then run
```
$ make test
Found no errors
```# TODO
* support other loop types