Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnatsel committed Nov 9, 2024
1 parent bdf0413 commit c5fe62a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions cargo-auditable/src/object_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,33 +219,40 @@ fn loongarch_features(target_triple: &str) -> String {

#[cfg(test)]
mod tests {
use std::collections::HashMap;

use super::*;
use crate::target_info::parse_rustc_target_info;

#[test]
fn test_riscv_abi_detection() {
// real-world target with double floats
let features = riscv_features("riscv64gc-unknown-linux-gnu");
let info = HashMap::from([("target_os".to_owned(), "linux".to_owned())]);
let features = riscv_features("riscv64gc-unknown-linux-gnu", &info);
assert!(features.contains('c'));
assert!(features.contains('d'));
assert!(features.contains('f'));
// real-world target without floats
let features = riscv_features("riscv32imac-unknown-none-elf");
let info = HashMap::from([("target_os".to_owned(), "none".to_owned())]);
let features = riscv_features("riscv32imac-unknown-none-elf", &info);
assert!(features.contains('c'));
assert!(!features.contains('d'));
assert!(!features.contains('f'));
// real-world target without floats or compression
let features = riscv_features("riscv32i-unknown-none-elf");
let info = HashMap::from([("target_os".to_owned(), "none".to_owned())]);
let features = riscv_features("riscv32i-unknown-none-elf", &info);
assert!(!features.contains('c'));
assert!(!features.contains('d'));
assert!(!features.contains('f'));
// made-up target without compression and with single floats
let features = riscv_features("riscv32if-unknown-none-elf");
let info = HashMap::from([("target_os".to_owned(), "none".to_owned())]);
let features = riscv_features("riscv32if-unknown-none-elf", &info);
assert!(!features.contains('c'));
assert!(!features.contains('d'));
assert!(features.contains('f'));
// real-world Android riscv target
let features = riscv_features("riscv64-linux-android");
let info = HashMap::from([("target_os".to_owned(), "android".to_owned())]);
let features = riscv_features("riscv64-linux-android", &info);
assert!(features.contains('c'));
assert!(features.contains('d'));
assert!(features.contains('f'));
Expand Down
2 changes: 1 addition & 1 deletion rust-audit-info/Cargo.lock

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

0 comments on commit c5fe62a

Please sign in to comment.