Skip to content

Commit 159ad7a

Browse files
committed
Update fuzzer
1 parent 24bb9ef commit 159ad7a

File tree

1 file changed

+45
-41
lines changed

1 file changed

+45
-41
lines changed

src/fuzzer/fuzzer.rs

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ fn write_file(filename: str, content: str) {
1111
result::get(
1212
io::file_writer(filename, [io::create, io::truncate]))
1313
.write_str(content);
14-
// Work around https://github.com/graydon/rust/issues/726
15-
std::run::run_program("chmod", ["644", filename]);
1614
}
1715

1816
fn contains(haystack: str, needle: str) -> bool {
1917
str::find(haystack, needle) != -1
2018
}
2119

2220
fn find_rust_files(&files: [str], path: str) {
23-
if str::ends_with(path, ".rs") {
21+
if str::ends_with(path, ".rs") && !contains(path, "utf8") {
22+
// ignoring "utf8" tests: https://github.com/graydon/rust/pull/1470 ?
2423
files += [path];
2524
} else if fs::path_is_dir(path)
2625
&& !contains(path, "compile-fail")
@@ -95,6 +94,9 @@ pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
9594
// https://github.com/graydon/rust/issues/928
9695
//ast::expr_cast(_, _) { false }
9796

97+
// https://github.com/graydon/rust/issues/1458
98+
ast::expr_call(_, _, _) { false }
99+
98100
_ { true }
99101
}
100102
}
@@ -139,11 +141,16 @@ fn steal(crate: ast::crate, tm: test_mode) -> stolen_stuff {
139141
{exprs: *exprs, tys: *tys}
140142
}
141143

142-
// https://github.com/graydon/rust/issues/652
144+
143145
fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
144146
alt e {
147+
// https://github.com/graydon/rust/issues/652
145148
ast::expr_if(_, _, _) { false }
146149
ast::expr_block(_) { false }
150+
151+
// expr_call is also missing a constraint
152+
ast::expr_fn_block(_, _) { false }
153+
147154
_ { true }
148155
}
149156
}
@@ -168,10 +175,7 @@ fn replace_expr_in_crate(crate: ast::crate, i: uint, newexpr: ast::expr, tm: tes
168175
if i_ + 1u == *j_ && safe_to_replace_expr(original, tm_) {
169176
newexpr_
170177
} else {
171-
alt(original) {
172-
ast::expr_fail(_) { original /* Don't replace inside fail: https://github.com/graydon/rust/issues/930 */ }
173-
_ { fold::noop_fold_expr(original, fld) }
174-
}
178+
fold::noop_fold_expr(original, fld)
175179
}
176180
}
177181
let afp =
@@ -322,9 +326,7 @@ fn check_running(exe_filename: str) -> happiness {
322326
log(error, "comb comb comb: " + comb);
323327
}
324328

325-
if contains(comb, "Assertion failed: (0), function alloc, file ../src/rt/rust_obstack.cpp") {
326-
known_bug("https://github.com/graydon/rust/issues/32 / https://github.com/graydon/rust/issues/445")
327-
} else if contains(comb, "Assertion failed:") {
329+
if contains(comb, "Assertion failed:") {
328330
failed("C++ assertion failure")
329331
} else if contains(comb, "leaked memory in rust main loop") {
330332
// might also use exit code 134
@@ -333,40 +335,31 @@ fn check_running(exe_filename: str) -> happiness {
333335
} else if contains(comb, "src/rt/") {
334336
failed("Mentioned src/rt/")
335337
} else if contains(comb, "malloc") {
336-
failed("Mentioned malloc")
337-
} else if contains(comb, "Out of stack space, sorry") {
338-
known_bug("https://github.com/graydon/rust/issues/32 / https://github.com/graydon/rust/issues/445")
338+
//failed("Mentioned malloc")
339+
known_bug("https://github.com/graydon/rust/issues/1461")
339340
} else {
340341
alt p.status {
341342
0 { passed }
342343
100 { cleanly_rejected("running: explicit fail") }
343344
101 | 247 { cleanly_rejected("running: timed out") }
344-
245 | 246 | 138 | 252 { known_bug("https://github.com/graydon/rust/issues/32 ??") }
345+
245 | 246 | 138 | 252 { known_bug("https://github.com/graydon/rust/issues/1466") }
345346
136 | 248 { known_bug("SIGFPE - https://github.com/graydon/rust/issues/944") }
346347
rc { failed("Rust program ran but exited with status " + int::str(rc)) }
347348
}
348349
}
349350
}
350351

351352
fn check_compiling(filename: str) -> happiness {
352-
/*
353353
let p = std::run::program_output(
354-
"/Users/jruderman/code/rust/build/stage1/rustc",
355-
["-c", filename]);
356-
*/
357-
358-
let p = std::run::program_output("bash", ["-c", "DYLD_LIBRARY_PATH=/Users/jruderman/code/rust/build/stage0/lib:/Users/jruderman/code/rust/build/rustllvm/ /Users/jruderman/code/rust/build/stage1/rustc " + filename]);
354+
"/Users/jruderman/code/rust/build/x86_64-apple-darwin/stage1/bin/rustc",
355+
[filename]);
359356

360357
//#error("Status: %d", p.status);
361358
if p.err != "" {
362359
if contains(p.err, "Ptr must be a pointer to Val type") {
363360
known_bug("https://github.com/graydon/rust/issues/897")
364-
} else if contains(p.err, "(castIsValid(op, S, Ty) && \"Invalid cast!\"), function Create") {
365-
known_bug("https://github.com/graydon/rust/issues/901")
366-
} else if contains(p.err, "cast() argument of incompatible type!") {
367-
known_bug("https://github.com/graydon/rust/issues/973")
368-
} else if contains(p.err, "cast<Ty>() argument of incompatible type!") {
369-
known_bug("https://github.com/graydon/rust/issues/973")
361+
} else if contains(p.err, "Assertion failed: ((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && \"Calling a function with a bad signature!\"), function init") {
362+
known_bug("https://github.com/graydon/rust/issues/1459")
370363
} else {
371364
log(error, "Stderr: " + p.err);
372365
failed("Unfamiliar error message")
@@ -375,23 +368,24 @@ fn check_compiling(filename: str) -> happiness {
375368
passed
376369
} else if contains(p.out, "Out of stack space, sorry") {
377370
known_bug("Recursive types - https://github.com/graydon/rust/issues/742")
378-
} else if contains(p.out, "Assertion !cx.terminated failed") {
379-
known_bug("https://github.com/graydon/rust/issues/893")
380-
// } else if contains(p.out, "upcall fail 'non-exhaustive match failure', ../src/comp/middle/trans.rs") {
381-
} else if contains(p.out, "trans_rec expected a rec but found _|_") {
382-
known_bug("https://github.com/graydon/rust/issues/924")
383371
} else if contains(p.out, "Assertion") && contains(p.out, "failed") {
384372
log(error, "Stdout: " + p.out);
385373
failed("Looks like an llvm assertion failure")
386374

387-
} else if contains(p.out, "internal compiler error fail called with unsupported type _|_") {
388-
known_bug("https://github.com/graydon/rust/issues/942")
389-
} else if contains(p.out, "internal compiler error Translating unsupported cast") {
390-
known_bug("https://github.com/graydon/rust/issues/932")
391-
} else if contains(p.out, "internal compiler error sequence_element_type called on non-sequence value") {
392-
known_bug("https://github.com/graydon/rust/issues/931")
375+
} else if contains(p.out, "upcall fail 'option none'") {
376+
known_bug("https://github.com/graydon/rust/issues/1463")
377+
} else if contains(p.out, "upcall fail 'non-exhaustive match failure', ../src/comp/middle/typeck.rs:1554") {
378+
known_bug("https://github.com/graydon/rust/issues/1462")
379+
} else if contains(p.out, "upcall fail 'Assertion cx.fcx.llupvars.contains_key(did.node) failed'") {
380+
known_bug("https://github.com/graydon/rust/issues/1467")
381+
} else if contains(p.out, "Taking the value of a method does not work yet (issue #435)") {
382+
known_bug("https://github.com/graydon/rust/issues/435")
393383
} else if contains(p.out, "internal compiler error bit_num: asked for pred constraint, found an init constraint") {
394384
known_bug("https://github.com/graydon/rust/issues/933")
385+
} else if contains(p.out, "internal compiler error") && contains(p.out, "called on non-fn type") {
386+
known_bug("https://github.com/graydon/rust/issues/1460")
387+
} else if contains(p.out, "internal compiler error fail called with unsupported type _|_") {
388+
known_bug("https://github.com/graydon/rust/issues/1465")
395389
} else if contains(p.out, "internal compiler error unimplemented") {
396390
known_bug("Something unimplemented")
397391
} else if contains(p.out, "internal compiler error") {
@@ -453,7 +447,8 @@ fn content_is_dangerous_to_compile(code: str) -> bool {
453447
["xfail-test",
454448
"-> !", // https://github.com/graydon/rust/issues/897
455449
"tag", // typeck hang with ty variants: https://github.com/graydon/rust/issues/742 (from dup #900)
456-
"with" // tstate hang with expr variants: https://github.com/graydon/rust/issues/948
450+
"with", // tstate hang with expr variants: https://github.com/graydon/rust/issues/948
451+
"import comm" // mysterious hang: https://github.com/graydon/rust/issues/1464
457452
];
458453

459454
for p: str in dangerous_patterns { if contains(code, p) { ret true; } }
@@ -468,7 +463,6 @@ fn content_might_not_converge(code: str) -> bool {
468463
"spawn", // precedence issues?
469464
"bind", // precedence issues?
470465
" be ", // don't want to replace its child with a non-call: "Non-call expression in tail call"
471-
"&!", // https://github.com/graydon/rust/issues/972
472466
"\n\n\n\n\n" // https://github.com/graydon/rust/issues/850
473467
];
474468

@@ -477,7 +471,13 @@ fn content_might_not_converge(code: str) -> bool {
477471
}
478472

479473
fn file_might_not_converge(filename: str) -> bool {
480-
let confusing_files = ["expr-alt.rs"]; // pretty-printing "(a = b) = c" vs "a = b = c" and wrapping
474+
let confusing_files = [
475+
"expr-alt.rs", // pretty-printing "(a = b) = c" vs "a = b = c" and wrapping
476+
"block-arg-in-ternary.rs", // wrapping
477+
"move-3-unique.rs", // 0 becomes (0), but both seem reasonable. wtf?
478+
"move-3.rs", // 0 becomes (0), but both seem reasonable. wtf?
479+
];
480+
481481

482482
for f in confusing_files { if contains(filename, f) { ret true; } }
483483

@@ -528,6 +528,7 @@ fn check_convergence(files: [str]) {
528528
fn check_variants(files: [str], cx: context) {
529529
for file in files {
530530
if cx.mode == tm_converge && file_might_not_converge(file) {
531+
#error("Skipping convergence test based on file_might_not_converge");
531532
cont;
532533
}
533534

@@ -566,8 +567,11 @@ fn main(args: [str]) {
566567
let root = args[1];
567568

568569
find_rust_files(files, root);
570+
#error("== check_convergence ==");
569571
check_convergence(files);
572+
#error("== check_variants: converge ==");
570573
check_variants(files, { mode: tm_converge });
574+
#error("== check_variants: run ==");
571575
check_variants(files, { mode: tm_run });
572576

573577
#error("Fuzzer done");

0 commit comments

Comments
 (0)