Skip to content

Commit

Permalink
in depth testing (#15)
Browse files Browse the repository at this point in the history
* add in-depth testing framework; add additional validation and documentation
* fix for overflow
* fixes for __safe_add and __safe_sub
* additional fixes for increment and decrement
* cppcheck fixes
* attempt to fix fsanitize option failure
* add coverage and more cleaning
  • Loading branch information
barrust authored Nov 11, 2020
1 parent 75534ca commit 187af43
Show file tree
Hide file tree
Showing 9 changed files with 1,342 additions and 61 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#local
dist/*
!dist/.gitkeep
*.gcno
*.gcda
*.gcov

# Prerequisites
*.d
Expand Down
90 changes: 90 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
language: c


jobs:
include:
# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
packages:
- g++-4.9
env:
- MATRIX_EVAL="CC=gcc-4.9"
- STD="-std=gnu99"
- CCFLAGS="-fsanitize=undefined"

# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
packages:
- gcc-5
env:
- MATRIX_EVAL="CC=gcc-5"

# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
packages:
- gcc-6
env:
- MATRIX_EVAL="CC=gcc-6"
- CCFLAGS="-fsanitize=undefined"

# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
packages:
- gcc-7
env:
- MATRIX_EVAL="CC=gcc-7"
- CCFLAGS="-fsanitize=undefined"

- os: linux
addons:
apt:
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
packages:
- gcc-8
env:
- MATRIX_EVAL="CC=gcc-8"
- CCFLAGS="-fsanitize=undefined"

- os: linux
addons:
apt:
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
packages:
- gcc-9
env:
- MATRIX_EVAL="CC=gcc-9"
- CCFLAGS="-fsanitize=undefined"


before_install:
- eval "${MATRIX_EVAL}"

install:
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -qq cppcheck; fi

script:
- make test
- ./dist/test
- if [ $TRAVIS_OS_NAME == linux ]; then cppcheck --error-exitcode=1 --inline-suppr --enable=warning,performance,information,style --template='{file}:{line},{severity},{id},{message}' ./src/ ; fi
- gcov ./dist/*.gcno

after_success:
- bash <(curl -s https://codecov.io/bash)
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
## Current Version

### Version 0.1.7
* Added count-min sketch merge functionality; thanks to [jonahharris](https://github.com/jonahharris)

### Version 0.1.6
* Remove the python version with the recommendation of using `pyprobables` instead
* Ensure appropriate `const` usage for `char*`
* Improve the hashing to be more efficient

### Version 0.1.5
* Fix for non gcc overflow checks
* Fix for non gcc overflow checks; thank to [meixsh](https://github.com/meixsh)
* Added python sub classes:
* StreamThreshold
* Those elements that meet the threshold are maintained in a dictionary
Expand Down
24 changes: 18 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,34 @@ CC=gcc
TESTDIR=tests
DISTDIR=dist
SRCDIR=src
CCFLAGS=-lm -Wall -Wpedantic -Winline

COMPFLAGS=-lm -Wall -Wpedantic -Winline


all: count_min_sketch
$(CC) $(DISTDIR)/count_min_sketch.o $(TESTDIR)/count_min_sketch_test.c $(CCFLAGS) -o ./$(DISTDIR)/cms
$(CC) $(DISTDIR)/count_min_sketch.o $(TESTDIR)/count_min_sketch_test.c $(CCFLAGS) $(COMPFLAGS) -o ./$(DISTDIR)/cms

debug: CCFLAGS += -g
debug: COMPFLAGS += -g
debug: all

release: CCFLAGS += -O3
release: COMPFLAGS += -O3
release: all

sanitize: COMPFLAGS += -fsanitize=undefined
sanitize: test

test: COMPFLAGS += -coverage
test: count_min_sketch
$(CC) $(DISTDIR)/count_min_sketch.o $(TESTDIR)/test_cms.c $(CCFLAGS) $(COMPFLAGS) -lcrypto -o ./$(DISTDIR)/test -g

clean:
if [ -f "./$(DISTDIR)/count_min_sketch.o" ]; then rm -r ./$(DISTDIR)/count_min_sketch.o; fi
if [ -f "./$(DISTDIR)/cms" ]; then rm -r ./$(DISTDIR)/cms; fi
if [ -f "./$(DISTDIR)/test" ]; then rm -rf ./$(DISTDIR)/*.gcno; fi
if [ -f "./$(DISTDIR)/test" ]; then rm -rf ./$(DISTDIR)/*.gcda; fi
if [ -f "./$(DISTDIR)/test" ]; then rm -r ./$(DISTDIR)/test; fi
rm -f ./*.gcno
rm -f ./*.gcda
rm -f ./*.gcov

count_min_sketch:
$(CC) -c $(SRCDIR)/count_min_sketch.c -o $(DISTDIR)/count_min_sketch.o $(CCFLAGS)
$(CC) -c $(SRCDIR)/count_min_sketch.c -o $(DISTDIR)/count_min_sketch.o $(CCFLAGS) $(COMPFLAGS) -g
35 changes: 35 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "70...100"

status:
project:
default:
# basic settings
target: "85%"
base: auto
threshold: 15
patch:
default:
target: "50%"
changes: no

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach,diff,flags,tree"
behavior: default
require_changes: no

ignore:
- "./tests/"
Loading

0 comments on commit 187af43

Please sign in to comment.