Skip to content

Commit ffbb666

Browse files
committed
Small fixes and rewrite the quick example
1 parent c1aa5d3 commit ffbb666

File tree

7 files changed

+20
-3799
lines changed

7 files changed

+20
-3799
lines changed

README.md

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,40 @@ Tavor ([Sindarin](https://en.wikipedia.org/wiki/Sindarin) for woodpecker) is a f
44

55
### <a name="quick-example"></a>A quick example
66

7-
Imagine that you want to test a vending machine which ejects a product after receiving 100 credits. It is possible to input 25 and 50 credit coins into the machine. After receiving enough credits the machine ejects a product and resets the credit counter to zero. To simplify the example the machine does not handle credit overflows. A representation of the states and actions of the machine could look like this:
7+
We want to test a service which processes an XML structure. The structure can contain groups and items. A group contains other groups or items. An Item consists of an attribute `name` with an alphanumeric value. The item's value contains a number. This structure sounds simple but allows an enormous variety of possible outcomes. It is therefore hard to test since a tester has to think about every important possibility if the generation of the test data is done manually. Doing this manually is cumbersome and error-prone. Tavor can be used to automate the generation.
88

9-
![Basic states and actions](examples/quick/basic.png "Basic states and actions")
10-
11-
This state machine can be defined using the following [Tavor format](#format):
9+
The described structure can be defined using the following [Tavor format](#format):
1210

1311
```tavor
14-
START = Credit0
12+
START = Entity |
1513
16-
Credit0 = "Credit0" "\n" ( Coin25 Credit25 | Coin50 Credit50 | )
17-
Credit25 = "Credit25" "\n" ( Coin25 Credit50 | Coin50 Credit75 )
18-
Credit50 = "Credit50" "\n" ( Coin25 Credit75 | Coin50 Credit100 )
19-
Credit75 = "Credit75" "\n" Coin25 Credit100
20-
Credit100 = "Credit100" "\n" Vend Credit0
14+
Entity = Group | Item
2115
22-
Coin25 = "Coin25" "\n"
23-
Coin50 = "Coin50" "\n"
16+
Group = "<group>" +(Entity) "</group>"
2417
25-
Vend = "Vend" "\n"
18+
Item = "<item name=\"" +([\w]) "\">" +([0-9]) "</item>"
2619
```
27-
(Please note that the new line escape sequences `\n` are just defined to make the output prettier)
2820

29-
You can download this file called [`basic.tavor` from here](examples/quick/basic.tavor).
21+
This file called `basic.tavor` can be downloaded [from here](examples/quick/basic.tavor).
3022

3123
Tavor can then be used to [fuzz](#fuzzing) the format by issuing the following command:
3224

3325
```bash
3426
tavor --format-file basic.tavor fuzz
3527
```
3628

37-
This command outputs on every call random paths through the defined graph. Here are some example outputs:
29+
This command prints on every call a random generation of the given structure. Here are some example generations:
3830

39-
```
40-
Credit0
31+
```xml
32+
<item name="k">2</item>
4133
```
4234

43-
```
44-
Credit0
45-
Coin50
46-
Credit50
47-
Coin50
48-
Credit100
49-
Vend
50-
Credit0
35+
```xml
36+
<group><item name="kO">37</item></group>
5137
```
5238

53-
```
54-
Credit0
55-
Coin25
56-
Credit25
57-
Coin50
58-
Credit75
59-
Coin25
60-
Credit100
61-
Vend
62-
Credit0
39+
```xml
40+
<group><item name="V">37</item><group><item name="S">88</item></group></group>
6341
```
6442

6543
Generating data like this is just one example of the capabilities of Tavor. Please have a look at [the complete example](#complete-example) with a complete overview over the basic features or keep reading to find out more about the background and capabilities of Tavor.
@@ -218,7 +196,7 @@ The complete example has its own [page which can be found here](/doc/complete-ex
218196

219197
## <a name="precompiled"></a>Where are the precompiled binaries?
220198

221-
You can find all precompiled binaries on the [release page](https://github.com/zimmski/tavor/releases). Currently only 32 and 64 bit Linux binaries are provided. Other architectures are currently not supported, but might work. Please have a look at the [feature request section](#feature-request) if you need them to work or you want more binaries for different architectures.
199+
You can find all precompiled binaries on the [release page](https://github.com/zimmski/tavor/releases). Currently only 32 and 64 bit Linux binaries are provided. Other architectures are currently not supported, but might work. Please have a look at the [feature request section](#feature-request) if you need them to work or if you want more binaries for different architectures.
222200

223201
## <a name="build"></a>How do I build Tavor?
224202

doc/complete-example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This example provides a complete overview of Tavor. It does not utilize every single feature but every component which should give you an idea on how Tavor can be used in your own projects. The example tests an implementation of the following state machine.
44

5-
![Basic states and actions](/examples/quick/basic.png "Basic states and actions")
5+
![Basic states and actions](/examples/complete/fsm.png "Basic states and actions")
66

77
The example uses the *Tavor format* to define this state machine and the *Tavor binary* to generate key-driven test files. An *executor* translates keys of a file into actions for the implementation under test. After successfully testing the original implementation, some bugs will be introduced to show the failure of some tests as well as automatically delta-debugging the failed key-driven test files.
88

0 commit comments

Comments
 (0)