forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 4
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
trying reuse filetests #211
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6718bf0
trying reuse filetests
MCJOHN974 bfa4c6f
stage-1: cleanup
MCJOHN974 fc8d077
restore arithmetic.clif
MCJOHN974 7076d72
removing outdated comments
MCJOHN974 28e2159
newline in the end of arithmetic.clif
MCJOHN974 de489ea
Merge branch 'main' into viktar/filetests
MCJOHN974 73ae77c
dedup
MCJOHN974 1f09832
filetests: zkasm-building
MCJOHN974 8edd7c5
review fixes
MCJOHN974 c747cd4
review fixes v2
MCJOHN974 1f8eaea
Merge branch 'main' into viktar/filetests
MCJOHN974 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,18 @@ | ||
test run-zkasm | ||
|
||
|
||
function %add_i64(i64, i64) -> i64 { | ||
block0(v0: i64,v1: i64): | ||
v2 = iadd v0, v1 | ||
return v2 | ||
} | ||
; run: %add_i64(0, 0) == 0 | ||
; run: %add_i64(0, 1) == 1 | ||
|
||
function %sub_i64(i64, i64) -> i64 { | ||
block0(v0: i64,v1: i64): | ||
v2 = isub v0, v1 | ||
return v2 | ||
} | ||
; run: %sub_i64(0, 0) == 0 | ||
; run: %sub_i64(0, 1) == -1 |
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,85 @@ | ||
//! Test command for compiling CLIF files to .zkasm, running it, and verifying their results | ||
//! | ||
//! using [RunCommand](cranelift_reader::RunCommand)s. | ||
|
||
use crate::runone::FileUpdate; | ||
use crate::subtest::SubTest; | ||
use cranelift_codegen::isa::TargetIsa; | ||
use cranelift_codegen::settings::Flags; | ||
use cranelift_codegen::{self, ir}; | ||
use cranelift_reader::{parse_run_command, RunCommand, TestCommand, TestFile}; | ||
use std::borrow::Cow; | ||
|
||
use crate::zkasm_codegen; | ||
|
||
struct TestRunZkasm; | ||
|
||
pub fn subtest(parsed: &TestCommand) -> anyhow::Result<Box<dyn SubTest>> { | ||
assert_eq!(parsed.command, "run-zkasm"); | ||
if !parsed.options.is_empty() { | ||
anyhow::bail!("No options allowed on {}", parsed); | ||
} | ||
Ok(Box::new(TestRunZkasm)) | ||
} | ||
|
||
impl SubTest for TestRunZkasm { | ||
fn name(&self) -> &'static str { | ||
"run-zkasm" | ||
} | ||
|
||
fn is_mutating(&self) -> bool { | ||
false | ||
} | ||
|
||
fn needs_isa(&self) -> bool { | ||
false | ||
} | ||
|
||
/// Runs the entire subtest for a given target | ||
/// TODO: in zkasm we don't really run test for given target, we run for zkasm target | ||
fn run_target<'a>( | ||
&self, | ||
testfile: &TestFile, | ||
_: &mut FileUpdate, | ||
_: &'a str, | ||
_: &'a Flags, | ||
_: Option<&'a dyn TargetIsa>, | ||
) -> anyhow::Result<()> { | ||
let mut zkasm_functions: Vec<Vec<String>> = Vec::new(); | ||
let mut invocations: Vec<Vec<String>> = Vec::new(); | ||
for (func, details) in &testfile.functions { | ||
zkasm_functions.push(zkasm_codegen::compile_clif_function(func)); | ||
for comment in details.comments.iter() { | ||
if let Some(command) = parse_run_command(comment.text, &func.signature)? { | ||
match command { | ||
RunCommand::Print(_) => { | ||
todo!() | ||
} | ||
RunCommand::Run(invoke, compare, expected) => { | ||
invocations | ||
.push(zkasm_codegen::compile_invocation(invoke, compare, expected)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
let zkasm_program = zkasm_codegen::build_test_zkasm(zkasm_functions, invocations); | ||
println!("{}", zkasm_program); | ||
// TODO: instead of printing run program, using something like this: | ||
// match zkasm_runner::run_zkasm(&zkasm_program) { | ||
// // TODO: Probably here is a good place to collect info generated by assert-hostfunction | ||
// // and somehow show it | ||
// Ok(_) => Ok(()), | ||
// Err(e) => Err(e), | ||
// } | ||
Ok(()) | ||
} | ||
|
||
fn run( | ||
&self, | ||
_func: Cow<ir::Function>, | ||
_context: &crate::subtest::Context, | ||
) -> anyhow::Result<()> { | ||
unreachable!() | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use existing
arithmetic.clif
or is there some reason it wouldn't work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arithmetic.clif
panics for now, and changes to fix it worth separate PR