Skip to content
This repository has been archived by the owner on Nov 9, 2019. It is now read-only.

Build misc_testsuite from source #70

Merged
merged 3 commits into from
Aug 24, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:

steps:
- checkout: self
submodules: true
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
Expand All @@ -38,6 +39,8 @@ jobs:
rustc --version
displayName: Install rust (Win)
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- script: rustup target add wasm32-wasi
displayName: Install wasm32-wasi target
- script: |
powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf %TEMP%\LLVM-8.0.0-win64.exe https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/LLVM-8.0.0-win64.exe"
%TEMP%\LLVM-8.0.0-win64.exe /S /NCRC
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "misc_testsuite"]
path = misc_testsuite
url = https://github.com/cranestation/wasi-misc-tests
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ crate-type = ["rlib", "staticlib", "cdylib"]

[workspace]
members = ["wasi-common-cbindgen"]
exclude = ["winx"]
exclude = ["winx", "misc_testsuite"]
23 changes: 22 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,39 @@ use std::env;
use std::fs::{read_dir, DirEntry, File};
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};

fn main() {
let out_dir =
PathBuf::from(env::var("OUT_DIR").expect("The OUT_DIR environment variable must be set"));
let mut out = File::create(out_dir.join("misc_testsuite_tests.rs"))
.expect("error generating test source file");

build_tests("misc_testsuite").expect("building tests");
test_directory(&mut out, "misc_testsuite").expect("generating tests");
}

fn build_tests(testsuite: &str) -> io::Result<()> {
let mut cmd = Command::new("cargo");
cmd.args(&["build", "--release", "--target=wasm32-wasi"])
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.current_dir(testsuite);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it work to add a --target-dir to put this build's target somewhere inside OUT _DIR, or the outer cargo build's target dir, to fix cargo clean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I thought it would conflict with the cargo locks on build directory, but it appears it doesn't.

let output = cmd.output()?;

let status = output.status;
if !status.success() {
panic!(
"Building tests failed: exit code: {}",
status.code().unwrap()
);
}

Ok(())
}

fn test_directory(out: &mut File, testsuite: &str) -> io::Result<()> {
let mut dir_entries: Vec<_> = read_dir(testsuite)
let mut dir_entries: Vec<_> = read_dir(format!("{}/target/wasm32-wasi/release", testsuite))
.expect("reading testsuite directory")
.map(|r| r.expect("reading testsuite directory entry"))
.filter(|dir_entry| {
Expand Down
1 change: 1 addition & 0 deletions misc_testsuite
Submodule misc_testsuite added at 5b706d
Binary file removed misc_testsuite/big_random_buf.wasm
Binary file not shown.
Binary file removed misc_testsuite/clock_time_get.wasm
Binary file not shown.
Binary file removed misc_testsuite/close_preopen.wasm
Binary file not shown.
Binary file removed misc_testsuite/dangling_symlink.wasm
Binary file not shown.
Binary file removed misc_testsuite/directory_seek.wasm
Binary file not shown.
Binary file removed misc_testsuite/fd_filestat_set.wasm
Binary file not shown.
Binary file removed misc_testsuite/file_allocate.wasm
Binary file not shown.
Binary file removed misc_testsuite/file_pread_pwrite.wasm
Binary file not shown.
Binary file removed misc_testsuite/file_seek_tell.wasm
Binary file not shown.
Binary file removed misc_testsuite/file_unbuffered_write.wasm
Binary file not shown.
Binary file removed misc_testsuite/interesting_paths.wasm
Binary file not shown.
Binary file removed misc_testsuite/isatty.wasm
Binary file not shown.
Binary file removed misc_testsuite/nofollow_errors.wasm
Binary file not shown.
Binary file removed misc_testsuite/path_filestat.wasm
Binary file not shown.
Binary file removed misc_testsuite/path_rename.wasm
Binary file not shown.
Binary file removed misc_testsuite/readlink.wasm
Binary file not shown.
Binary file removed misc_testsuite/readlink_no_buffer.wasm
Binary file not shown.
Binary file removed misc_testsuite/remove_nonempty_directory.wasm
Binary file not shown.
Binary file removed misc_testsuite/renumber.wasm
Binary file not shown.
Binary file removed misc_testsuite/sched_yield.wasm
Binary file not shown.
Binary file removed misc_testsuite/symlink_loop.wasm
Binary file not shown.
Binary file removed misc_testsuite/truncation_rights.wasm
Binary file not shown.
Binary file removed misc_testsuite/unlink_directory.wasm
Binary file not shown.