Update homework 1 and 2

This commit is contained in:
Jeehoon Kang
2020-03-26 03:38:20 +09:00
parent 241a66fcc1
commit 8938a7ad8f
40 changed files with 5171 additions and 1504 deletions

View File

@@ -34,7 +34,7 @@ cargo test --release # release build test
cargo test <test-name> # run a particular test
```
`<test-name>` can be `test_ast_print`, `ir_smoke`, ...
`<test-name>` can be `test_examples_write_c`, `test_examples_irgen`, ...
## Fuzzing
@@ -44,10 +44,7 @@ cargo test <test-name> # run a particular test
```sh
# Ubuntu 18.04 or higher
apt install -y make cmake python3
# MacOS
xcode-select install
brew install cmake python3
apt install -y csmith libcsmith-dev creduce
```
### Run
@@ -59,5 +56,28 @@ python3 tests/fuzz.py --help # print options
python3 tests/fuzz.py --print -n10 # test C AST printer for 10 times
```
We use [Csmith](https://embed.cs.utah.edu/csmith/) to randomly generate C source codes. Csmith will
be automatically downloaded and built by the test script.
We use `csmith` to randomly generate C source codes. `csmith` will be automatically downloaded and
built by the test script. For more information, we refer to the
[Csmith](https://embed.cs.utah.edu/csmith/) homepage.
### Reduce
When the fuzzer finds a buggy input program for your compiler, it is highly likely that the input
program is too big to manually inspect. We use `creduce` that reduces the buggy input program as
much as possible.
Suppose `tests/test_polished.c` is the buggy input program. Then the following script reduces the
program to `tests/test_reduced.c`:
```sh
python3 tests/fuzz.py --reduce <fuzz-option>
```
`<fuzz-option>` can be `--print` or `--irgen`. It shall be the one used in [Run](#run).
### How it reduces test case?
The script performs unguided test-case reduction using `creduce`: given a buggy program, it randomly
reduces the program; check if the reduced program still fails on the test, and if so, replaces the
given program with the reduced one; repeat until you get a small enough buggy program. For more
information, we refer to the [Creduce](https://embed.cs.utah.edu/creduce/) homepage.