• Stars
    star
    596
  • Rank 72,320 (Top 2 %)
  • Language
    C
  • License
    ISC License
  • Created almost 10 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

property-based testing for C: generate input to find obscure bugs, then reduce to minimal failing input

theft: property-based testing for C

theft is a C library for property-based testing. Where example-based testing checks test results for specific input, theft tests assert general properties ("for any possible input, [some condition] should hold"), generate input, and search for counter-examples that make the test fail. If theft finds any failures, it also knows how to generate and test simpler variants of the input, and then report the simplest counter-example found.

theft is distributed under the ISC license.

Installation

theft does not depend on anything beyond C99 and a Unix-like environment. Its internal tests use greatest, but there is not any coupling between them. It contains implementations of the Mersenne Twister PRNG and the FNV-1a hashing algorithm - see their files for copyright info.

To build, using GNU make:

$ make

Note: You may need to call it as gmake, especially if building on BSD.

To build and run the tests:

$ make test

This will produce example output from several falsifiable properties, and confirm that failures have been found.

To install libtheft and its headers:

$ make install    # using sudo, if necessary

theft can also be vendored inside of projects -- in that case, just make sure the headers in ${VENDOR}/theft/inc/ are added to the -I include path, and ${VENDOR}/theft/build/libtheft.a is linked.

Usage

For usage documentation, see doc/usage.md.

Properties

For some examples of properties to test, see doc/properties.md.

Shrinking and Auto-shrinking

For more info about shrinking and auto-shrinking, see doc/shrinking.md.

Forking

theft can fork before running properties, to shrink failures that make the code under test crash or exceed an optional timeout. For more info, see doc/forking.md.

More Repositories

1

greatest

A C testing library in 1 file. No dependencies, no dynamic allocation. ISC licensed.
C
1,449
star
2

guff

a plot device
C
270
star
3

ff

fuzzy-completion for finding files
C
156
star
4

tamale

TAble MAtching Lua Extension - An Erlang-style pattern-matching library for Lua
Lua
146
star
5

autoclave

repeatedly run programs until they break, and be ready to attach a debugger
C
141
star
6

socket99

Wrapper library for the BSD sockets API with a nicer C99 interface
C
139
star
7

lunatest

xUnit-style + randomized unit testing framework for Lua (and C projects using Lua, etc.)
Lua
80
star
8

sample

filter for random sampling of input
C
70
star
9

tangram

Jumprope-based local content store
Lua
55
star
10

skiplist

skiplist library for C.
C
52
star
11

mpool

memory pool allocator
C
48
star
12

loom

a lock-less thread pool for C99
C
43
star
13

wn

"what next?" - simple command-line task-interdependency tracker
Lua
42
star
14

curlbash

locally save and checksum/review before curl | bash-ing installers
Shell
36
star
15

parade

run multiple shell commands in parallel and coordinate their output
C
32
star
16

spooky

C library for OOK Manchester encoding, decoding, and dynamic clock recovery
C
32
star
17

lua-ukanren

Lua port of of microKanren, a minimal logic programming engine.
Lua
31
star
18

glean

lightweight search engine for local text docs
C
28
star
19

oscar

mark/sweep garbage collector for C
C
28
star
20

markdown_to_reveal

minimal plumbing to convert slides in markdown to reveal.js presentations via pandoc
CSS
27
star
21

sidereal

Redis library for Lua, with optional non-blocking mode and Lua-style lists & sets.
Lua
27
star
22

lua-memcached

A Lua client for memcached, with optional non-blocking mode.
Lua
21
star
23

skel

tiny command-line skeleton/snippet thing
C
21
star
24

skiparray

unrolled skip list library for C
C
20
star
25

hashchop

C library to deterministically chunk byte streams with a rolling hash
C
20
star
26

lua-sqlite

wrapper for sqlite3
C
19
star
27

lua-bdd

Binary decision diagram library (Lua)
Lua
17
star
28

ansible_thinkpad

Example Ansible-based setup for a 6th gen. Thinkpad X1 Carbon
Shell
16
star
29

lua-mpd

A Lua client library for mpd.
Lua
15
star
30

mqtt_demo

example using mosquitto MQTT client library
C
15
star
31

bluebottle

C library for bit-banging async serial communication (UARTs)
C
12
star
32

hopscotch

An implementation of Tarjan's Strongly Connected Components algorithm
C
12
star
33

GPL_v-3

GPL, version -3
11
star
34

zwiebel

A simple work/break interval timer for Emacs
Emacs Lisp
9
star
35

lua-bcrypt

bcrypt wrapper for Lua
Lua
9
star
36

lookup

Search for a file in parent directories, up to / .
C
7
star
37

denv

setenv via files in directory (standalone envdir clone)
C
6
star
38

motorcycle-el

motorcycle animation for the emacs modeline
Emacs Lisp
5
star
39

one_weird_C_trick

weird c vararg function pointer trick
C
5
star
40

idlewait

suspend execution until system load is low (with optional timeout)
C
5
star
41

ministat

quick adaptation of PHK's FreeBSD ministat for OpenBSD
C
5
star
42

slides-completing_the_circuit

slides: "Completing the Circuit: From Arduino to General Embedded Hardware"
CSS
5
star
43

lua-ev

libev wrapper for Lua, including most watchers
C
4
star
44

lua-endhook

Lua library to run a hook after the main script is read
Lua
4
star
45

git-nethack

git-nethack, so you can hack while you hack
Shell
3
star
46

wifi

simple OpenBSD wifi network auth manager script
3
star
47

lua-xosd

XOSD wrapper for Lua
C
3
star
48

rollavg

rolling average of file stream
C
3
star
49

presentation-Configuring_a_laptop_with_Ansible

Slides for DevOps West Michigan - "Configuring a Laptop with Ansible"
CSS
3
star
50

study-grade_up

a study in sorting stable algorithms for an APL-style grade-up operation
C
2
star
51

callaloo_web

Minimal web server for publishing current callaloo MQTT events
C
2
star
52

betwixt

Python impl. of the Burrows-Wheeler Transform for my !!Con 2015 talk
Python
1
star
53

presentation-write-a-parser-today

slides for "Write a parser today!" presentation
1
star