Skip to content
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
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.aarch64-apple-darwin]
runner = "./test-runner.sh"

[target.x86_64-apple-darwin]
runner = "./test-runner.sh"
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

name: Build

on:
pull_request:
push:
branches:
- main

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Install toolchain from rust-toolchain.toml
run: rustup show
- name: Install missing targets
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
- name: Test
run: cargo test --no-fail-fast
env:
RUST_BACKTRACE: 1
16 changes: 16 additions & 0 deletions test-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# Test runner wrapper that codesigns the test binary before running it

TEST_BINARY="$1"
shift

# Codesign the test binary on macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
ENTITLEMENTS="$(dirname "$0")/app.entitlements"
if [[ -f "$ENTITLEMENTS" ]]; then
codesign --entitlements "$ENTITLEMENTS" --force -s - "$TEST_BINARY" 2>/dev/null || true
fi
fi

# Run the test
exec "$TEST_BINARY" "$@"
4 changes: 2 additions & 2 deletions tests/hvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ fn vm_create() {
mem[EL1_USER_PAYLOAD_ADDRESS as usize..EL1_USER_PAYLOAD_ADDRESS as usize + sz]
.clone_from_slice(&el1_user_payload);
//map the vec at address 0
map_mem(mem, 0, MemPerm::ExecAndWrite).unwrap();
map_mem(mem, 0, MemPerm::ExecWrite).unwrap();

let vcpu = VirtualCpu::new().unwrap();
let vcpu = VirtualCpu::new(0).unwrap();

vcpu.write_register(Register::CPSR, 0x3c4).unwrap();
vcpu.write_register(Register::PC, EL1_USER_PAYLOAD_ADDRESS)
Expand Down