Skip to content

Commit

Permalink
Enable encode_unsigned_num_constraint by default (viperproject#1281)
Browse files Browse the repository at this point in the history
* Addresses viperproject#1215

* Skip memchr crate

* Add more tests

* Removed unneeded environment variable

* Skip failing crates

* Fix typo

* Skip failing crates

* Temporarily disable fail_fast

* Switch from native-tls to rustls

* Re-enable skipped crates

* Skip failing crates

* Skip failing crates

* disable failing crate

* Re-enable fail_fast

* Print errors with Display

* Disable encode_unsigned_num_constraints

* Fix typo in environment variable

* Remove unnecessairy compile flags
  • Loading branch information
Patrick-6 committed Jan 26, 2023
1 parent b6a1f57 commit 706512a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
1 change: 0 additions & 1 deletion prusti-tests/tests/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ fn run_no_verification(group_name: &str, filter: &Option<String>) {
fn run_verification_base(group_name: &str, filter: &Option<String>) {
let _temporary_env_vars = (
TemporaryEnvVar::set("PRUSTI_FULL_COMPILATION", "true"),
TemporaryEnvVar::set("PRUSTI_ENCODE_UNSIGNED_NUM_CONSTRAINT", "true"),
TemporaryEnvVar::set("PRUSTI_QUIET", "true"),
);

Expand Down
9 changes: 9 additions & 0 deletions prusti-tests/tests/verify/pass/issues/issue-1215-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use prusti_contracts::*;

fn main() {}

// #[requires(0 <= i)] // This should not be needed, if encode_unsigned_num_constraint=true is the default
#[requires(i < s.len())]
fn _test(s: &[i64], i: usize) -> i64 {
s[i]
}
28 changes: 28 additions & 0 deletions prusti-tests/tests/verify/pass/issues/issue-1215-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![allow(unused_comparisons)]
use prusti_contracts::*;

fn main() {}

fn _test_u8(x: u8) {
prusti_assert!(x >= 0);
}

fn _test_u16(x: u16) {
prusti_assert!(x >= 0);
}

fn _test_u32(x: u32) {
prusti_assert!(x >= 0);
}

fn _test_u64(x: u64) {
prusti_assert!(x >= 0);
}

fn _test_u128(x: u128) {
prusti_assert!(x >= 0);
}

fn _test_usize(x: usize) {
prusti_assert!(x >= 0);
}
2 changes: 1 addition & 1 deletion prusti-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ lazy_static::lazy_static! {
settings.set_default("check_foldunfold_state", false).unwrap();
settings.set_default("check_overflows", true).unwrap();
settings.set_default("check_panics", true).unwrap();
settings.set_default("encode_unsigned_num_constraint", false).unwrap();
settings.set_default("encode_unsigned_num_constraint", true).unwrap();
settings.set_default("encode_bitvectors", false).unwrap();
settings.set_default("simplify_encoding", true).unwrap();
settings.set_default("log", "").unwrap();
Expand Down
7 changes: 4 additions & 3 deletions test-crates/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn main() -> Result<(), Box<dyn Error>> {
java_home: Some(guest_java_home.clone()),
};

info!("Crate a new workspace...");
info!("Create a new workspace...");
// `Error: Compat { error: SandboxImagePullFailed(ExecutionFailed(ExitStatus(unix_wait_status(256)))) }` if
// docker daemon isn't running
let workspace = WorkspaceBuilder::new(workspace_path, "prusti-test-crates").init()?;
Expand Down Expand Up @@ -279,7 +279,7 @@ fn main() -> Result<(), Box<dyn Error>> {
});

if let Err(err) = build_status {
warn!("Error: {:?}", err);
warn!("Error: {}", err);
warn!("Output:\n{}", storage);

// Report the failure
Expand Down Expand Up @@ -323,6 +323,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.env("PRUSTI_LOG_DIR", "/tmp/prusti_log")
.env("PRUSTI_CHECK_PANICS", "false")
.env("PRUSTI_CHECK_OVERFLOWS", "false")
.env("PRUSTI_ENCODE_UNSIGNED_NUM_CONSTRAINT", "false")
// Do not report errors for unsupported language features
.env("PRUSTI_SKIP_UNSUPPORTED_FEATURES", "true");
match test_kind {
Expand All @@ -344,7 +345,7 @@ fn main() -> Result<(), Box<dyn Error>> {
});

if let Err(err) = verification_status {
error!("Error: {:?}", err);
error!("Error: {}", err);
error!("Output:\n{}", storage);

// Report the failure
Expand Down

0 comments on commit 706512a

Please sign in to comment.