Skip to content

Cva6 pickle test #60

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ jobs:
curl https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
if: matrix.os == 'macos-latest'
- name: Install bender
run: cargo install bender
if: matrix.os == 'ubuntu-latest'
- name: Install slang
run: |
sudo mkdir -p /tools && sudo chmod 777 /tools
cd /tools && git clone https://github.com/MikePopoloski/slang.git && cd slang && git checkout v2.0
echo $PWD
cmake -B build && make -C build && cmake --install build --prefix /tools/install
echo "PATH=$PATH:/tools/install/bin" >> ${GITHUB_ENV}
if: matrix.os == 'ubuntu-latest'
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ path = "src/lib.rs"
assert_cmd = "2.0"
predicates = "3"
assert_fs = "1.0"
tempfile = "3.3"
60 changes: 60 additions & 0 deletions tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use predicates::prelude::*; // Used for writing assertions
use std::path::Path;
use std::process::Command; // Run programs
// use std::fs::File;
use std::io::{self, Write};
use tempfile;

#[cfg(test)]
mod tests {
Expand Down Expand Up @@ -85,4 +87,62 @@ mod tests {

Ok(())
}

#[cfg(target_os = "linux")]
#[test]
fn test_cva6() -> Result<(), Box<dyn std::error::Error>> {
// debug with -- --nocapture
let tempdir = tempfile::tempdir()?;
println!("tempdir: {:?}", tempdir.path());
let clone_output = Command::new("sh")
.current_dir(&tempdir)
.arg("-c")
.arg("git clone https://github.com/pulp-platform/cva6.git --branch bender-changes && cd cva6 && git submodule update --init --recursive")
.output()
.expect("failed to execute process");
io::stdout().write_all(&clone_output.stdout).unwrap();
io::stderr().write_all(&clone_output.stderr).unwrap();
assert!(clone_output.status.success());
let bender_output = Command::new("sh")
.current_dir(&tempdir)
.arg("-c")
.arg("cd cva6 && bender sources -f -t cv64a6_imafdc_sv39 > sources.json")
.output()
.expect("failed to execute process");
io::stdout().write_all(&bender_output.stdout).unwrap();
io::stderr().write_all(&bender_output.stderr).unwrap();
assert!(bender_output.status.success());

let mut cmd = Command::cargo_bin("morty")?;
cmd.arg("-f")
.arg(
Path::new(&tempdir.path())
.join("cva6/sources.json")
.as_os_str(),
)
.arg("-o")
.arg(
Path::new(&tempdir.path())
.join("cva6/output.sv")
.as_os_str(),
);
// TODO: add --top test when it is working
//.arg("--top")
//.arg("cva6");
let binding = cmd.assert().success();
let output = &binding.get_output().stdout;
let output_str = String::from_utf8(output.clone()).unwrap();
println!("output: {}", output_str);

let slang_output = Command::new("sh")
.current_dir(&tempdir)
.arg("-c")
.arg("cd cva6 && echo $PATH && slang output.sv --top cva6 -Wrange-width-oob")
.output()
.expect("failed to execute process");
io::stdout().write_all(&slang_output.stdout).unwrap();
io::stderr().write_all(&slang_output.stderr).unwrap();
assert!(slang_output.status.success());
Ok(())
}
}