From 1c9e4e01600d162ac8a3490193c5d98fa18c092b Mon Sep 17 00:00:00 2001 From: Michael Rogenmoser Date: Thu, 3 Aug 2023 17:12:10 +0200 Subject: [PATCH 1/9] test: add `cva6` test --- Cargo.lock | 1 + Cargo.toml | 1 + tests/cli_tests.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 51196ad..6b7c36c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -519,6 +519,7 @@ dependencies = [ "serde_json", "simple_logger", "sv-parser", + "tempfile", "term", "time", ] diff --git a/Cargo.toml b/Cargo.toml index 3a73dc2..cb68719 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,3 +37,4 @@ path = "src/lib.rs" assert_cmd = "2.0" predicates = "3" assert_fs = "1.0" +tempfile = "3.3" diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs index 45fbc48..943076c 100644 --- a/tests/cli_tests.rs +++ b/tests/cli_tests.rs @@ -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 { @@ -85,4 +87,51 @@ mod tests { Ok(()) } + + #[cfg(not(target_os = "windows"))] + #[test] + fn test_cva6() -> Result<(), Box> { + // 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 && echo hubus") + .output() + .expect("failed to execute process"); + io::stdout().write_all(&clone_output.stdout).unwrap(); + io::stderr().write_all(&clone_output.stderr).unwrap(); + println!("status: {}", clone_output.status); + 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(); + println!("status2: {}", bender_output.status); + 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("output.sv").as_os_str()) + .arg(Path::new("output.sv").as_os_str()) + .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); + + Ok(()) + } } From e08178ed7ac9c73d439c44d7e77b23c66280f6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Sch=C3=B6nleber?= Date: Thu, 16 Feb 2023 21:28:07 +0100 Subject: [PATCH 2/9] ci: add `bender` + `slang` install to `action` --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b791ef..0454a65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,15 @@ 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 + - name: Install slang + run: mkdir -p /tools/slang && chmod 777 /tools/slang && \ + cd /tools/slang && git clone https://github.com/MikePopoloski/slang.git && \ + cd slang && git checkout v2.0 && \ + cmake -B build && cmake --build build -j$(nproc) && \ + cmake --install build --strip + if: matrix.os == 'linux-latest' || matrix.os == 'macos-latest' - name: Build run: cargo build --verbose - name: Run tests From 619901da4a18544f8525b87f51b62c52958c62c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Sch=C3=B6nleber?= Date: Thu, 16 Feb 2023 21:46:54 +0100 Subject: [PATCH 3/9] test: `cva6` test add `slang` check --- tests/cli_tests.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs index 943076c..957d733 100644 --- a/tests/cli_tests.rs +++ b/tests/cli_tests.rs @@ -97,12 +97,11 @@ mod tests { 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 && echo hubus") + .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(); - println!("status: {}", clone_output.status); assert!(clone_output.status.success()); let bender_output = Command::new("sh") .current_dir(&tempdir) @@ -112,7 +111,6 @@ mod tests { .expect("failed to execute process"); io::stdout().write_all(&bender_output.stdout).unwrap(); io::stderr().write_all(&bender_output.stderr).unwrap(); - println!("status2: {}", bender_output.status); assert!(bender_output.status.success()); let mut cmd = Command::cargo_bin("morty")?; @@ -123,8 +121,11 @@ mod tests { .as_os_str(), ) .arg("-o") - //.arg(Path::new(&tempdir.path()).join("output.sv").as_os_str()) - .arg(Path::new("output.sv").as_os_str()) + .arg( + Path::new(&tempdir.path()) + .join("cva6/output.sv") + .as_os_str(), + ) .arg("--top") .arg("cva6"); let binding = cmd.assert().success(); @@ -132,6 +133,15 @@ mod tests { 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(()) } } From 6a3b08e8db69ad137ff1acbaee40b5ef74487418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Sch=C3=B6nleber?= Date: Thu, 16 Feb 2023 22:35:49 +0100 Subject: [PATCH 4/9] test: remove `--top cva6` from `cva6` test --- tests/cli_tests.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs index 957d733..d89b72c 100644 --- a/tests/cli_tests.rs +++ b/tests/cli_tests.rs @@ -125,9 +125,10 @@ mod tests { Path::new(&tempdir.path()) .join("cva6/output.sv") .as_os_str(), - ) - .arg("--top") - .arg("cva6"); + ); + // 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(); From 2af8e1889ef693c7ac65ce7c935cefd572dd050c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Sch=C3=B6nleber?= Date: Thu, 16 Feb 2023 22:50:42 +0100 Subject: [PATCH 5/9] ci: use correct name for `ubuntu-latest` --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0454a65..892c38a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: cd slang && git checkout v2.0 && \ cmake -B build && cmake --build build -j$(nproc) && \ cmake --install build --strip - if: matrix.os == 'linux-latest' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' - name: Build run: cargo build --verbose - name: Run tests From e69648d88d6e116c3c9a2bf93c97a818ba0d552a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Sch=C3=B6nleber?= Date: Thu, 16 Feb 2023 22:55:47 +0100 Subject: [PATCH 6/9] ci: move `slang` install to allowed path --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 892c38a..cd0ffa9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,8 +56,8 @@ jobs: - name: Install bender run: cargo install bender - name: Install slang - run: mkdir -p /tools/slang && chmod 777 /tools/slang && \ - cd /tools/slang && git clone https://github.com/MikePopoloski/slang.git && \ + run: mkdir -p $HOME/tools/slang && chmod 777 $HOME/tools/slang && \ + cd $HOME/tools/slang && git clone https://github.com/MikePopoloski/slang.git && \ cd slang && git checkout v2.0 && \ cmake -B build && cmake --build build -j$(nproc) && \ cmake --install build --strip From f15d0693173e32785f3761b08b4cdec5df8b0e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Sch=C3=B6nleber?= Date: Fri, 17 Feb 2023 11:17:29 +0100 Subject: [PATCH 7/9] ci: update `slang` install for ci --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd0ffa9..013684e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,11 +56,12 @@ jobs: - name: Install bender run: cargo install bender - name: Install slang - run: mkdir -p $HOME/tools/slang && chmod 777 $HOME/tools/slang && \ - cd $HOME/tools/slang && git clone https://github.com/MikePopoloski/slang.git && \ - cd slang && git checkout v2.0 && \ - cmake -B build && cmake --build build -j$(nproc) && \ - cmake --install build --strip + 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 && cmake --build build -j$(nproc) + cmake --install build --strip if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' - name: Build run: cargo build --verbose From 83d7602f1b46bf6f5c79ac3fdad6aed77e878b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Sch=C3=B6nleber?= Date: Fri, 17 Feb 2023 12:25:33 +0100 Subject: [PATCH 8/9] ci: run `cva6` pickle test only on linux --- .github/workflows/ci.yml | 3 ++- tests/cli_tests.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 013684e..6eb3686 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,7 @@ jobs: 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 @@ -62,7 +63,7 @@ jobs: echo $PWD cmake -B build && cmake --build build -j$(nproc) cmake --install build --strip - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + if: matrix.os == 'ubuntu-latest' - name: Build run: cargo build --verbose - name: Run tests diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs index d89b72c..8369fdc 100644 --- a/tests/cli_tests.rs +++ b/tests/cli_tests.rs @@ -88,7 +88,7 @@ mod tests { Ok(()) } - #[cfg(not(target_os = "windows"))] + #[cfg(target_os = "linux")] #[test] fn test_cva6() -> Result<(), Box> { // debug with -- --nocapture From 88cff0504782c48319387150de409d3a6e798156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Sch=C3=B6nleber?= Date: Fri, 17 Feb 2023 14:01:46 +0100 Subject: [PATCH 9/9] ci: install `slang` to prefix location --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6eb3686..9bbbcde 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,8 +61,8 @@ jobs: 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 && cmake --build build -j$(nproc) - cmake --install build --strip + 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