You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #1068 - fitzgen:predicate-script, r=pepyakin
Factor out a general purpose predicate script from the `csmith` driver
This allows it to be used by both fuzzers and when using `creduce`. See each commit for details.
r? @pepyakin
-[Using `creduce` to Minimize Test Cases](#using-creduce-to-minimize-test-cases)
28
+
-[Getting `creduce`](#getting-creduce)
28
29
-[Isolating Your Test Case](#isolating-your-test-case)
29
30
-[Writing a Predicate Script](#writing-a-predicate-script)
30
31
@@ -337,11 +338,25 @@ $ RUST_LOG=bindgen cargo test
337
338
338
339
## Using `creduce` to Minimize Test Cases
339
340
340
-
If you are hacking on `bindgen` and find a test case that causes an unexpected
341
-
panic, results in bad Rust bindings, or some other incorrectness in `bindgen`,
342
-
then using `creduce` can help reduce the test case to a minimal one.
341
+
If you find a test case that triggers an unexpected panic in `bindgen`, causes
342
+
`bindgen` to emit bindings that won't compile, define structs with the wrong
343
+
size/alignment, or results in any other kind of incorrectness, then using
344
+
`creduce` can help reduce the test case to a minimal one that still exhibits
345
+
that same bad behavior.
343
346
344
-
[Follow these instructions for building and/or installing `creduce`.](https://github.com/csmith-project/creduce/blob/master/INSTALL)
347
+
***Reduced test cases are SUPER helpful when filing bug reports!***
348
+
349
+
### Getting `creduce`
350
+
351
+
Often, you can install `creduce` from your OS's package manager:
352
+
353
+
```
354
+
$ sudo apt install creduce
355
+
$ brew install creduce
356
+
$ # Etc...
357
+
```
358
+
359
+
[Otherwise, follow these instructions for building and/or installing `creduce`.](https://github.com/csmith-project/creduce/blob/master/INSTALL)
345
360
346
361
Running `creduce` requires two things:
347
362
@@ -352,7 +367,7 @@ Running `creduce` requires two things:
352
367
353
368
With those two things in hand, running `creduce` looks like this:
354
369
355
-
$ creduce ./predicate.sh ./isolated_test_case.h
370
+
$ creduce ./predicate.sh ./isolated-test-case.h
356
371
357
372
### Isolating Your Test Case
358
373
@@ -369,12 +384,9 @@ standalone test case.
369
384
370
385
### Writing a Predicate Script
371
386
372
-
Writing a `predicate.sh` script for a `bindgen` test case is fairly
373
-
straightforward. One potential gotcha is that `creduce` can and will attempt to
374
-
reduce test cases into invalid C/C++ code. That might be useful for C/C++
375
-
compilers, but we generally only care about valid C/C++ input headers.
376
-
377
-
Here is a skeleton predicate script:
387
+
Writing a `predicate.sh` script for a `bindgen` test case is straightforward. We
388
+
already have a general purpose predicate script that you can use, you just have
389
+
to wrap and configure it.
378
390
379
391
```bash
380
392
#!/usr/bin/env bash
@@ -384,39 +396,61 @@ Here is a skeleton predicate script:
384
396
# * we access any undefined variable.
385
397
set -eu
386
398
387
-
# Print out Rust backtraces on panic. Useful for minimizing a particular panic.
388
-
export RUST_BACKTRACE=1
399
+
# Invoke the general purpose predicate script that comes in the
400
+
# `bindgen` repository.
401
+
#
402
+
# You'll need to replace `--whatever-flags` with things that are specific to the
403
+
# incorrectness you're trying to pin down. See below for details.
0 commit comments