Skip to content

Commit

Permalink
Add linking and test
Browse files Browse the repository at this point in the history
  • Loading branch information
swernli committed Feb 10, 2025
1 parent 1d8e460 commit 0439de8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ fn bind_functions(module: &Module, execution_engine: &ExecutionEngine) -> Result
bind!(__quantum__qis__arctan2__body, 2);
bind!(__quantum__qis__assertmeasurementprobability__body, 6);
bind!(__quantum__qis__assertmeasurementprobability__ctl, 6);
bind!(__quantum__qis__barrier__body, 0);
bind!(__quantum__qis__ccx__body, 3);
bind!(__quantum__qis__cnot__body, 2);
bind!(__quantum__qis__cos__body, 1);
Expand Down
Binary file added runner/tests/resources/barrier.bc
Binary file not shown.
15 changes: 15 additions & 0 deletions runner/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use std::io::BufWriter;

use runner::{run_bitcode, run_file, OUTPUT};

// This group of tests verifies the behavior of QIR execution with a series of quantum gate checks based on the Choi–Jamiołkowski Isomorphism.
Expand Down Expand Up @@ -339,3 +341,16 @@ fn mixed_output_recording_calls_fail() {
result.unwrap_err().to_lowercase()
);
}

#[test]
fn barrier_is_noop() {
OUTPUT.with(|output| {
let mut output = output.borrow_mut();
output.use_std_out(false);
});
let bitcode = include_bytes!("resources/barrier.bc");
let mut stream = BufWriter::new(Vec::new());
let result = run_bitcode(bitcode, None, 1, &mut stream);
assert!(result.is_ok());
assert_eq!(String::from_utf8(stream.into_inner().unwrap()).unwrap(), "START\nMETADATA\tentry_point\nMETADATA\toutput_labeling_schema\nMETADATA\tqir_profiles\tbase_profile\nMETADATA\trequired_num_qubits\t1\nMETADATA\trequired_num_results\t1\nOUTPUT\tRESULT\t0\nEND\t0\n");
}

0 comments on commit 0439de8

Please sign in to comment.