Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper tests for CI #69

Closed
Manishearth opened this issue Mar 5, 2017 · 9 comments
Closed

Add proper tests for CI #69

Manishearth opened this issue Mar 5, 2017 · 9 comments
Assignees

Comments

@Manishearth
Copy link
Member

It should cd to a test crate directory, that contains a single function which panics on an input of size 6 or something, then fuzz init, edit the fuzz target to call this function, run the fuzz target, and ensure a crashfile is produced of the correct length.

@Manishearth
Copy link
Member Author

@ner0x652 want to work on this?

@Manishearth Manishearth changed the title Add proper CI Add proper tests for CI Mar 5, 2017
@0xcpu
Copy link
Contributor

0xcpu commented Mar 5, 2017

@Manishearth If it doesn't need beyond intermediate level of Rust knowledge, then YES! (tomorrow after work)

@Manishearth
Copy link
Member Author

It would mostly be a shell script that does the steps above. We'd probably check in the test crate to be fuzzed.

@Manishearth
Copy link
Member Author

Willing to help if you need any.

@Manishearth Manishearth assigned Manishearth and 0xcpu and unassigned Manishearth Mar 5, 2017
@0xcpu
Copy link
Contributor

0xcpu commented Mar 5, 2017

Good! 👍

@0xcpu
Copy link
Contributor

0xcpu commented Mar 6, 2017

@Manishearth left 2 links on IRC, in case you didn't see them here is what I wrote:
This is deploy.sh in scripts folder:

# This script leaves in /scripts, go to parent, this should be needed only locally
cd ..
mkdir etc && cd etc 
cargo new testcrate
cd testcrate

testcrate_lib_source="
pub fn test_func(slice: &[u8]) {
    if slice.len() == 7 {
        panic!(\"I'm afraid of number 7\");
    }
}
"
echo "$testcrate_lib_source" > src/lib.rs

cargo build
cargo-fuzz init

fuzzer_script_source="
#![no_main]
extern crate libfuzzer_sys;
extern crate testcrate;

use testcrate::test_func;

#[export_name=\"rust_fuzzer_test_input\"]
pub extern fn go(data: &[u8]) {
    test_func(data);
}
"
echo "$fuzzer_script_source" > fuzz/fuzzers/fuzzer_script_1.rs

cargo-fuzz run fuzzer_script_1

And this is the new travis.yml

language: rust

rust:
  - stable
  - beta
  - nightly

os:
  - linux

matrix:
  fast_finish: true

notifications:
  email: false

deploy:
  provider: script
  script: scripts/deploy.sh
  on:
    branch: master

Is this (close to) what you were thinking of?

@Manishearth
Copy link
Member Author

Just check in the testcrate into etc/. Then, in the script, cd to the crate and fuzz it.

Also, use sed to replace the body of go() in the fuzz script instead of overwriting it wholesale. We need to be sure that changes to the template still work.

@Manishearth
Copy link
Member Author

Fixed in #92 . Thanks, @ner0x652 !

@0xcpu
Copy link
Contributor

0xcpu commented Mar 30, 2017

Thank you @Manishearth , too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants