Skip to content

Commit

Permalink
Add second MIR bug (69039).
Browse files Browse the repository at this point in the history
  • Loading branch information
e45lee committed Nov 13, 2020
1 parent 555c082 commit d0515e0
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
36 changes: 36 additions & 0 deletions perses-docker/dataset/rust-69039.rs
@@ -0,0 +1,36 @@
#![feature(generators, generator_trait)]

use std::{
io,
ops::{Generator, GeneratorState},
};

fn my_scenario() -> impl Generator<String, Yield = &'static str, Return = String> {
|_arg: String| {
let my_name = yield "What is your name?";
let my_mood = yield "How are you feeling?";
format!("{} is {}", my_name.trim(), my_mood.trim())
}
}

fn main() {
let mut my_session = Box::pin(my_scenario());

loop {
let mut line = String::new();

match my_session.as_mut().resume(line) {
GeneratorState::Yielded(prompt) => {
println!("{}", prompt);
}
GeneratorState::Complete(v) => {
println!("{}", v);
break;
}
}

line = String::new();
io::stdin().read_line(&mut line).unwrap();
}
}

2 changes: 2 additions & 0 deletions perses-docker/dataset/rust-69039.setup.sh
@@ -0,0 +1,2 @@
#!/bin/bash
exit 0
52 changes: 52 additions & 0 deletions perses-docker/dataset/rust-69039.sh
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

set -o nounset

readonly FILE="${INPUT}"

readonly BUGGY_RUSTC_VERSION="nightly-2020-02-10"
readonly CORRECT_RUSTC_VERSION="nightly-2020-11-05"
rustup toolchain install "${BUGGY_RUSTC_VERSION}" --force
rustup toolchain install "${CORRECT_RUSTC_VERSION}" --force

readonly EXE_WRONG="./wrong.out"
if ! timeout -s 9 60 rustup run "${BUGGY_RUSTC_VERSION}" rustc -o "${EXE_WRONG}" "${FILE}"; then
exit 1
fi

readonly EXE_CORRECT="./correct.out"
if ! timeout -s 9 60 rustup run "${CORRECT_RUSTC_VERSION}" rustc -o "${EXE_CORRECT}" "${FILE}" ; then
exit 1
fi

readonly EXE_CORRECT_2="./correct_2.out"
if ! timeout -s 9 60 rustup run "${CORRECT_RUSTC_VERSION}" rustc -Z mir-opt-level=2 -o "${EXE_CORRECT_2}" "${FILE}" ; then
exit 1
fi

readonly OUTPUT_WRONG="wrong_output.txt"

if (echo -e "a\nb" | timeout -s 9 30 "${EXE_WRONG}") &> "${OUTPUT_WRONG}" ; then
exit 1
fi

if ! grep "Segmentation fault" "${OUTPUT_WRONG}" ; then
exit 1
fi

readonly OUTPUT_CORRECT_1="correct_output.txt"
readonly OUTPUT_CORRECT_2="correct_output_2.txt"
if ! timeout -s 9 30 echo -e "a\nb" | "${EXE_CORRECT}" &> "${OUTPUT_CORRECT_1}" ; then
exit 1
fi

if ! timeout -s 9 30 echo -e "a\nb" | "${EXE_CORRECT_2}" &> "${OUTPUT_CORRECT_2}" ; then
exit 1
fi

if ! diff "${OUTPUT_CORRECT_1}" "${OUTPUT_CORRECT_2}" ; then
exit 1
fi

exit 0

0 comments on commit d0515e0

Please sign in to comment.