forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[transactional tests][bytecode verifier] Start bytecode verifier test…
… migration - Added two tests to start (small example for this PR) - Improved VM error printing Closes: aptos-labs#8904
- Loading branch information
1 parent
0f90c56
commit e2b392f
Showing
12 changed files
with
155 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "bytecode-verifier-transactional-tests" | ||
version = "0.1.0" | ||
authors = ["Diem Association <[email protected]>"] | ||
publish = false | ||
edition = "2018" | ||
license = "Apache-2.0" | ||
|
||
[dependencies] | ||
diem-workspace-hack = { path = "../../../common/workspace-hack" } | ||
|
||
[dev-dependencies] | ||
datatest-stable = "0.1.1" | ||
move-command-line-common = { path = "../../move-command-line-common" } | ||
move-transactional-test-runner = { path = "../../testing-infra/transactional-test-runner" } | ||
|
||
[[test]] | ||
name = "tests" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) The Diem Core Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#![forbid(unsafe_code)] | ||
|
||
// Empty src/lib.rs to get rusty-tags working. |
37 changes: 37 additions & 0 deletions
37
language/bytecode-verifier/transactional-tests/tests/reference_safety/eq_bad.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
processed 4 tasks | ||
|
||
task 0 'publish'. lines 1-13: | ||
Error: Unable to publish module '00000000000000000000000000000001::Tester'. Got VMError: { | ||
major_status: READREF_EXISTS_MUTABLE_BORROW_ERROR, | ||
sub_status: None, | ||
location: 0x1::Tester, | ||
indices: [(FunctionDefinition, 0)], | ||
offsets: [(FunctionDefinitionIndex(0), 6)], | ||
} | ||
|
||
task 1 'publish'. lines 15-27: | ||
Error: Unable to publish module '00000000000000000000000000000001::Tester2'. Got VMError: { | ||
major_status: READREF_EXISTS_MUTABLE_BORROW_ERROR, | ||
sub_status: None, | ||
location: 0x1::Tester2, | ||
indices: [(FunctionDefinition, 0)], | ||
offsets: [(FunctionDefinitionIndex(0), 6)], | ||
} | ||
|
||
task 2 'publish'. lines 29-41: | ||
Error: Unable to publish module '00000000000000000000000000000001::Tester3'. Got VMError: { | ||
major_status: READREF_EXISTS_MUTABLE_BORROW_ERROR, | ||
sub_status: None, | ||
location: 0x1::Tester3, | ||
indices: [(FunctionDefinition, 0)], | ||
offsets: [(FunctionDefinitionIndex(0), 6)], | ||
} | ||
|
||
task 3 'publish'. lines 43-55: | ||
Error: Unable to publish module '00000000000000000000000000000001::Tester4'. Got VMError: { | ||
major_status: READREF_EXISTS_MUTABLE_BORROW_ERROR, | ||
sub_status: None, | ||
location: 0x1::Tester4, | ||
indices: [(FunctionDefinition, 0)], | ||
offsets: [(FunctionDefinitionIndex(0), 6)], | ||
} |
15 changes: 8 additions & 7 deletions
15
...suite/tests/move/borrow_tests/eq_bad.mvir → ...-tests/tests/reference_safety/eq_bad.mvir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,55 @@ | ||
//# publish --address 0x1 | ||
module Tester { | ||
eqtest1() { | ||
let x: u64; | ||
let r: &mut u64; | ||
|
||
x = 0; | ||
r = &mut x; | ||
// invalid read of mutable ref, does not currently own its data | ||
_ = copy(r) == copy(r); | ||
return; | ||
} | ||
} | ||
// check: READREF_EXISTS_MUTABLE_BORROW_ERROR | ||
|
||
//! new-transaction | ||
//# publish --address 0x1 | ||
module Tester2 { | ||
eqtest2() { | ||
let x: u64; | ||
let r: &mut u64; | ||
|
||
x = 0; | ||
r = &mut x; | ||
// invalid read of mutable ref, does not currently own its data | ||
_ = copy(r) == move(r); | ||
return; | ||
} | ||
} | ||
// check: READREF_EXISTS_MUTABLE_BORROW_ERROR | ||
|
||
//! new-transaction | ||
//# publish --address 0x1 | ||
module Tester3 { | ||
neqtest1() { | ||
let x: u64; | ||
let r: &mut u64; | ||
|
||
x = 0; | ||
r = &mut x; | ||
// invalid read of mutable ref, does not currently own its data | ||
_ = copy(r) != copy(r); | ||
return; | ||
} | ||
} | ||
// check: READREF_EXISTS_MUTABLE_BORROW_ERROR | ||
|
||
//! new-transaction | ||
//# publish --address 0x1 | ||
module Tester4 { | ||
neqtest2() { | ||
let x: u64; | ||
let r: &mut u64; | ||
|
||
x = 0; | ||
r = &mut x; | ||
// invalid read of mutable ref, does not currently own its data | ||
_ = copy(r) != move(r); | ||
return; | ||
} | ||
} | ||
// check: READREF_EXISTS_MUTABLE_BORROW_ERROR |
1 change: 1 addition & 0 deletions
1
language/bytecode-verifier/transactional-tests/tests/reference_safety/eq_ok.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
processed 1 task |
3 changes: 3 additions & 0 deletions
3
...tsuite/tests/move/borrow_tests/eq_ok.mvir → ...l-tests/tests/reference_safety/eq_ok.mvir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
language/bytecode-verifier/transactional-tests/tests/tests.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) The Diem Core Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pub const TEST_DIR: &str = "tests"; | ||
use move_transactional_test_runner::vm_test_harness::run_test; | ||
|
||
datatest_stable::harness!(run_test, TEST_DIR, r".*\.(mvir|move)$"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters