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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ members = [
"aarch32-cpu",
"aarch32-rt",
"aarch32-rt-macros",
"aarch32-tests",
]
resolver = "2"
15 changes: 15 additions & 0 deletions aarch32-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "aarch32-tests"
version = "0.4.0"
edition = "2024"
publish = false
description = "Qemu and insta based test suite"

[[test]]
name = "tests"
harness = false

[dev-dependencies]
insta = { version = "1", features = ["filters"] }
serde_json = "1"
libtest-mimic = "0.8"
68 changes: 68 additions & 0 deletions aarch32-tests/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
pub(crate) mod test_utils {
use std::path::{Path, PathBuf};
use std::process::Command;

/// `aarch32-tests/` -> repo root -> `<name>` (e.g. "examples/versatileab").
pub fn test_dir(name: &str) -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.join(name)
}

pub fn discover_bins(dir: &Path) -> Vec<String> {
let output = Command::new("cargo")
.current_dir(dir)
.args(["metadata", "--format-version=1", "--no-deps"])
.output()
.expect("failed to run cargo metadata");
assert!(
output.status.success(),
"cargo metadata failed: {}",
String::from_utf8_lossy(&output.stderr)
);

let meta: serde_json::Value =
serde_json::from_slice(&output.stdout).expect("cargo metadata produced invalid JSON");

let mut bins: Vec<String> = meta["packages"]
.as_array()
.into_iter()
.flatten()
.flat_map(|pkg| pkg["targets"].as_array().into_iter().flatten())
.filter(|target| {
target["kind"]
.as_array()
.is_some_and(|kinds| kinds.iter().any(|k| k.as_str() == Some("bin")))
})
.filter_map(|target| target["name"].as_str().map(String::from))
.collect();
bins.sort();
bins
}

pub fn run_bin(
dir: &Path,
bin: &str,
target: &str,
flags: &[&str],
rustflags: Option<&str>,
) -> String {
let mut cmd = Command::new("cargo");
cmd.current_dir(dir)
.arg("run")
.arg(format!("--target={target}"))
.args(flags)
.args(["--bin", bin]);

// Some variants (e.g. fpu-d32) need a target-feature/-cpu; pass it only to
// this cross build, never to the host test binary.
if let Some(rustflags) = rustflags {
cmd.env("RUSTFLAGS", rustflags);
}

let output = cmd.output().expect("failed to execute cargo run");

String::from_utf8_lossy(&output.stdout).into_owned()
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is an data abort exception example
data abort occurred Hsr { ec: Ok(DataAbortFromCurrent), il: ThirtyTwoBit, iss: 33 } Some(DataAbortFromCurrent(IssDataAbort { isv: false, sas: 0, sae: false, srt: 0, ar: false, fnv: false, ea: false, cm: false, wnr: false, dfsc: 21 }))
caught unaligned_from_a32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is an data abort exception example
data abort occurred Hsr { ec: Ok(DataAbortFromCurrent), il: ThirtyTwoBit, iss: 33 } Some(DataAbortFromCurrent(IssDataAbort { isv: false, sas: 0, sae: false, srt: 0, ar: false, fnv: false, ea: false, cm: false, wnr: false, dfsc: 21 }))
caught unaligned_from_a32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is an data abort exception example
data abort occurred Hsr { ec: Ok(DataAbortFromCurrent), il: ThirtyTwoBit, iss: 33 } Some(DataAbortFromCurrent(IssDataAbort { isv: false, sas: 0, sae: false, srt: 0, ar: false, fnv: false, ea: false, cm: false, wnr: false, dfsc: 21 }))
caught unaligned_from_t32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is an data abort exception example
data abort occurred Hsr { ec: Ok(DataAbortFromCurrent), il: ThirtyTwoBit, iss: 33 } Some(DataAbortFromCurrent(IssDataAbort { isv: false, sas: 0, sae: false, srt: 0, ar: false, fnv: false, ea: false, cm: false, wnr: false, dfsc: 21 }))
caught unaligned_from_t32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Found PERIPHBASE 0xf0000000
Creating GIC driver @ 0xf0000000 / 0xf0100000
Calling git.setup(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Found PERIPHBASE 0xf0000000
Creating GIC driver @ 0xf0000000 / 0xf0100000
Calling git.setup(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Found PERIPHBASE 0xf0000000
Creating GIC driver @ 0xf0000000 / 0xf0100000
Calling git.setup(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Found PERIPHBASE 0xf0000000
Creating GIC driver @ 0xf0000000 / 0xf0100000
Calling git.setup(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is semihosting! x = 1.000, y = 2.000
SCTLR { IE=0 TE=0 NMFI=0 EE=0 U=1 FI=0 DZ=1 BR=0 RR=0 V=0 I=0 Z=1 SW=0 C=0 A=0 M=0 }
CPSR { N=0 Z=1 C=1 V=0 Q=0 J=0 E=0 A=1 I=1 F=1 T=0 MODE=Ok(Hyp) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is semihosting! x = 1.000, y = 2.000
SCTLR { IE=0 TE=0 NMFI=0 EE=0 U=1 FI=0 DZ=1 BR=0 RR=0 V=0 I=0 Z=1 SW=0 C=0 A=0 M=0 }
CPSR { N=0 Z=1 C=1 V=0 Q=0 J=0 E=0 A=1 I=1 F=1 T=0 MODE=Ok(Hyp) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
x = 1, y = 2, z = 3.000
In hvc_handler, with Hsr { ec: Ok(Hvc), il: ThirtyTwoBit, iss: 0000abcd }, Some(Hvc(IssCall { imm16: abcd })), Frame { r0: 10000000, r1: 10000001, r2: 10000002, r3: 10000003, r4: 10000004, r5: 10000005 }
In hvc_handler, with Hsr { ec: Ok(Hvc), il: ThirtyTwoBit, iss: 00009876 }, Some(Hvc(IssCall { imm16: 9876 })), Frame { r0: 20000000, r1: 20000001, r2: 20000002, r3: 20000003, r4: 20000004, r5: 20000005 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
x = 1, y = 2, z = 3.000
In hvc_handler, with Hsr { ec: Ok(Hvc), il: ThirtyTwoBit, iss: 0000abcd }, Some(Hvc(IssCall { imm16: abcd })), Frame { r0: 10000000, r1: 10000001, r2: 10000002, r3: 10000003, r4: 10000004, r5: 10000005 }
In hvc_handler, with Hsr { ec: Ok(Hvc), il: ThirtyTwoBit, iss: 00009876 }, Some(Hvc(IssCall { imm16: 9876 })), Frame { r0: 20000000, r1: 20000001, r2: 20000002, r3: 20000003, r4: 20000004, r5: 20000005 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
x = 1, y = 2, z = 3.000
In hvc_handler, with Hsr { ec: Ok(Hvc), il: ThirtyTwoBit, iss: 0000abcd }, Some(Hvc(IssCall { imm16: abcd })), Frame { r0: 10000000, r1: 10000001, r2: 10000002, r3: 10000003, r4: 10000004, r5: 10000005 }
In hvc_handler, with Hsr { ec: Ok(Hvc), il: ThirtyTwoBit, iss: 00009876 }, Some(Hvc(IssCall { imm16: 9876 })), Frame { r0: 20000000, r1: 20000001, r2: 20000002, r3: 20000003, r4: 20000004, r5: 20000005 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
x = 1, y = 2, z = 3.000
In hvc_handler, with Hsr { ec: Ok(Hvc), il: ThirtyTwoBit, iss: 0000abcd }, Some(Hvc(IssCall { imm16: abcd })), Frame { r0: 10000000, r1: 10000001, r2: 10000002, r3: 10000003, r4: 10000004, r5: 10000005 }
In hvc_handler, with Hsr { ec: Ok(Hvc), il: ThirtyTwoBit, iss: 00009876 }, Some(Hvc(IssCall { imm16: 9876 })), Frame { r0: 20000000, r1: 20000001, r2: 20000002, r3: 20000003, r4: 20000004, r5: 20000005 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is a prefetch abort exception example
prefetch abort occurred Hsr { ec: Ok(PrefetchAbortFromCurrent), il: ThirtyTwoBit, iss: 00000022 }, Some(PrefetchAbortFromCurrent(IssPrefetchAbort { fnv: false, ea: false, ifsc: 22 }))
caught bkpt_from_a32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is a prefetch abort exception example
prefetch abort occurred Hsr { ec: Ok(PrefetchAbortFromCurrent), il: ThirtyTwoBit, iss: 00000022 }, Some(PrefetchAbortFromCurrent(IssPrefetchAbort { fnv: false, ea: false, ifsc: 22 }))
caught bkpt_from_a32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is a prefetch abort exception example
prefetch abort occurred Hsr { ec: Ok(PrefetchAbortFromCurrent), il: ThirtyTwoBit, iss: 00000022 }, Some(PrefetchAbortFromCurrent(IssPrefetchAbort { fnv: false, ea: false, ifsc: 22 }))
caught bkpt_from_t32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is a prefetch abort exception example
prefetch abort occurred Hsr { ec: Ok(PrefetchAbortFromCurrent), il: ThirtyTwoBit, iss: 00000022 }, Some(PrefetchAbortFromCurrent(IssPrefetchAbort { fnv: false, ea: false, ifsc: 22 }))
caught bkpt_from_t32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
x = 1, y = 2, z = 3.000
In hvc_handler, with Hsr { ec: Ok(Svc), il: ThirtyTwoBit, iss: 0000abcd }, Some(Svc(IssCall { imm16: abcd })), Frame { r0: 10000000, r1: 10000001, r2: 10000002, r3: 10000003, r4: 10000004, r5: 10000005 }
In hvc_handler, with Hsr { ec: Ok(Svc), il: ThirtyTwoBit, iss: 00009876 }, Some(Svc(IssCall { imm16: 9876 })), Frame { r0: 20000000, r1: 20000001, r2: 20000002, r3: 20000003, r4: 20000004, r5: 20000005 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
x = 1, y = 2, z = 3.000
In hvc_handler, with Hsr { ec: Ok(Svc), il: ThirtyTwoBit, iss: 0000abcd }, Some(Svc(IssCall { imm16: abcd })), Frame { r0: 10000000, r1: 10000001, r2: 10000002, r3: 10000003, r4: 10000004, r5: 10000005 }
In hvc_handler, with Hsr { ec: Ok(Svc), il: ThirtyTwoBit, iss: 00009876 }, Some(Svc(IssCall { imm16: 9876 })), Frame { r0: 20000000, r1: 20000001, r2: 20000002, r3: 20000003, r4: 20000004, r5: 20000005 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
x = 1, y = 2, z = 3.000
In hvc_handler, with Hsr { ec: Ok(Svc), il: SixteenBit, iss: 00000012 }, Some(Svc(IssCall { imm16: 12 })), Frame { r0: 10000000, r1: 10000001, r2: 10000002, r3: 10000003, r4: 10000004, r5: 10000005 }
In hvc_handler, with Hsr { ec: Ok(Svc), il: SixteenBit, iss: 00000032 }, Some(Svc(IssCall { imm16: 32 })), Frame { r0: 20000000, r1: 20000001, r2: 20000002, r3: 20000003, r4: 20000004, r5: 20000005 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
x = 1, y = 2, z = 3.000
In hvc_handler, with Hsr { ec: Ok(Svc), il: SixteenBit, iss: 00000012 }, Some(Svc(IssCall { imm16: 12 })), Frame { r0: 10000000, r1: 10000001, r2: 10000002, r3: 10000003, r4: 10000004, r5: 10000005 }
In hvc_handler, with Hsr { ec: Ok(Svc), il: SixteenBit, iss: 00000032 }, Some(Svc(IssCall { imm16: 32 })), Frame { r0: 20000000, r1: 20000001, r2: 20000002, r3: 20000003, r4: 20000004, r5: 20000005 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is a undef exception example
undefined abort occurred Hsr { ec: Ok(Unknown), il: ThirtyTwoBit, iss: 00000000 }, Some(Unknown(IssUnknown(0)))
caught udf_from_a32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is a undef exception example
undefined abort occurred Hsr { ec: Ok(Unknown), il: ThirtyTwoBit, iss: 00000000 }, Some(Unknown(IssUnknown(0)))
caught udf_from_a32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is a undef exception example
undefined abort occurred Hsr { ec: Ok(Unknown), il: ThirtyTwoBit, iss: 00000000 }, Some(Unknown(IssUnknown(0)))
caught udf_from_t32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is a undef exception example
undefined abort occurred Hsr { ec: Ok(Unknown), il: ThirtyTwoBit, iss: 00000000 }, Some(Unknown(IssUnknown(0)))
caught udf_from_t32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is an data abort exception example
data abort occurred
DFSR (Fault Status Register): Dfsr { fnv: false, cm: false, ext: false, wnr: false, status: Ok(AlignmentFault) }
caught fault on COUNTER
caught unaligned_from_a32
caught fault on COUNTER
Doing it again
data abort occurred
DFSR (Fault Status Register): Dfsr { fnv: false, cm: false, ext: false, wnr: false, status: Ok(AlignmentFault) }
caught fault on COUNTER
caught unaligned_from_a32
caught fault on COUNTER
Skipping instruction
Recovered from fault OK!
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is an data abort exception example
data abort occurred
DFSR (Fault Status Register): Dfsr { fnv: false, cm: false, ext: false, wnr: false, status: Ok(AlignmentFault) }
caught fault on COUNTER
caught unaligned_from_a32
caught fault on COUNTER
Doing it again
data abort occurred
DFSR (Fault Status Register): Dfsr { fnv: false, cm: false, ext: false, wnr: false, status: Ok(AlignmentFault) }
caught fault on COUNTER
caught unaligned_from_a32
caught fault on COUNTER
Skipping instruction
Recovered from fault OK!
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is an data abort exception example
data abort occurred
DFSR (Fault Status Register): Dfsr { fnv: false, cm: false, ext: false, wnr: false, status: Ok(AlignmentFault) }
caught fault on COUNTER
caught unaligned_from_t32
caught fault on COUNTER
Doing it again
data abort occurred
DFSR (Fault Status Register): Dfsr { fnv: false, cm: false, ext: false, wnr: false, status: Ok(AlignmentFault) }
caught fault on COUNTER
caught unaligned_from_t32
caught fault on COUNTER
Skipping instruction
Recovered from fault OK!
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Hello, this is an data abort exception example
data abort occurred
DFSR (Fault Status Register): Dfsr { fnv: false, cm: false, ext: false, wnr: false, status: Ok(AlignmentFault) }
caught fault on COUNTER
caught unaligned_from_t32
caught fault on COUNTER
Doing it again
data abort occurred
DFSR (Fault Status Register): Dfsr { fnv: false, cm: false, ext: false, wnr: false, status: Ok(AlignmentFault) }
caught fault on COUNTER
caught unaligned_from_t32
caught fault on COUNTER
Skipping instruction
Recovered from fault OK!
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
c_code_char_check(p) -> 2
c_code_unsigned_char_check(p) -> 2
c_code_signed_char_check(p) -> 2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
c_code_char_check(p) -> 2
c_code_unsigned_char_check(p) -> 2
c_code_signed_char_check(p) -> 2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
source: qemu-tests/tests/tests.rs
expression: stdout
---
Sine wave test (f32)...
( 0.0000) ..............................o
( 0.1253) .................................o
Expand Down
Loading