Skip to content

Commit

Permalink
Undo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
georgwiese committed Jun 26, 2024
1 parent 8a230f8 commit 1962732
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
15 changes: 9 additions & 6 deletions pipeline/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn verify_test_file(
.from_file(resolve_test_file(file_name))
.with_prover_inputs(inputs)
.add_external_witness_values(external_witness_values);
verify_pipeline(pipeline)
verify_pipeline(pipeline, BackendType::EStarkDump)
}

pub fn verify_asm_string<S: serde::Serialize + Send + Sync + 'static>(
Expand All @@ -44,12 +44,15 @@ pub fn verify_asm_string<S: serde::Serialize + Send + Sync + 'static>(
pipeline = pipeline.add_data_vec(&data);
}

verify_pipeline(pipeline).unwrap();
verify_pipeline(pipeline, BackendType::EStarkDump).unwrap();
}

pub fn verify_pipeline(pipeline: Pipeline<GoldilocksField>) -> Result<(), String> {
// TODO: Also test EStarkDumpComposite
let mut pipeline = pipeline.with_backend(BackendType::EStarkDump, None);
pub fn verify_pipeline(
pipeline: Pipeline<GoldilocksField>,
backend: BackendType,
) -> Result<(), String> {
// TODO: Also test Composite variants
let mut pipeline = pipeline.with_backend(backend, None);

let tmp_dir = mktemp::Temp::new_dir().unwrap();
if pipeline.output_dir().is_none() {
Expand Down Expand Up @@ -253,7 +256,7 @@ pub fn assert_proofs_fail_for_invalid_witnesses_pilcom(
.from_file(resolve_test_file(file_name))
.set_witness(convert_witness(witness));

assert!(verify_pipeline(pipeline.clone()).is_err());
assert!(verify_pipeline(pipeline.clone(), BackendType::EStarkDump).is_err());
}

pub fn assert_proofs_fail_for_invalid_witnesses_estark(
Expand Down
4 changes: 3 additions & 1 deletion riscv/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use powdr_backend::BackendType;
use powdr_number::GoldilocksField;
use powdr_pipeline::{test_util::verify_pipeline, Pipeline};
use std::path::PathBuf;
Expand All @@ -8,6 +9,7 @@ pub fn verify_riscv_asm_string<S: serde::Serialize + Send + Sync + 'static>(
contents: &str,
inputs: Vec<GoldilocksField>,
data: Option<Vec<(u32, S)>>,
backend: BackendType,
) {
let temp_dir = mktemp::Temp::new_dir().unwrap().release();

Expand All @@ -31,5 +33,5 @@ pub fn verify_riscv_asm_string<S: serde::Serialize + Send + Sync + 'static>(
powdr_riscv_executor::ExecMode::Fast,
Default::default(),
);
verify_pipeline(pipeline).unwrap();
verify_pipeline(pipeline, backend).unwrap();
}
9 changes: 8 additions & 1 deletion riscv/tests/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod common;

mod instruction_tests {
use crate::common::verify_riscv_asm_string;
use powdr_backend::BackendType;
use powdr_number::GoldilocksField;
use powdr_riscv::asm::compile;
use powdr_riscv::Runtime;
Expand All @@ -15,7 +16,13 @@ mod instruction_tests {
false,
);

verify_riscv_asm_string::<()>(&format!("{name}.asm"), &powdr_asm, Default::default(), None);
verify_riscv_asm_string::<()>(
&format!("{name}.asm"),
&powdr_asm,
Default::default(),
None,
BackendType::EStarkDump,
);
}

include!(concat!(env!("OUT_DIR"), "/instruction_tests.rs"));
Expand Down
19 changes: 17 additions & 2 deletions riscv/tests/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,17 @@ fn many_chunks_memory() {
}

fn verify_riscv_crate(case: &str, inputs: Vec<GoldilocksField>, runtime: &Runtime) {
verify_riscv_crate_with_backend(case, inputs, runtime, BackendType::EStarkDump)
}

fn verify_riscv_crate_with_backend(
case: &str,
inputs: Vec<GoldilocksField>,
runtime: &Runtime,
backend: BackendType,
) {
let powdr_asm = compile_riscv_crate::<GoldilocksField>(case, runtime);
verify_riscv_asm_string::<()>(&format!("{case}.asm"), &powdr_asm, inputs, None);
verify_riscv_asm_string::<()>(&format!("{case}.asm"), &powdr_asm, inputs, None, backend);
}

fn verify_riscv_crate_with_data<S: serde::Serialize + Send + Sync + 'static>(
Expand All @@ -349,7 +358,13 @@ fn verify_riscv_crate_with_data<S: serde::Serialize + Send + Sync + 'static>(
) {
let powdr_asm = compile_riscv_crate::<GoldilocksField>(case, runtime);

verify_riscv_asm_string(&format!("{case}.asm"), &powdr_asm, inputs, Some(data));
verify_riscv_asm_string(
&format!("{case}.asm"),
&powdr_asm,
inputs,
Some(data),
BackendType::EStarkDump,
);
}

fn compile_riscv_crate<T: FieldElement>(case: &str, runtime: &Runtime) -> String {
Expand Down

0 comments on commit 1962732

Please sign in to comment.