MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / checks_incompatible_target

Function checks_incompatible_target

tests/all/module.rs:10–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9#[test]
10fn checks_incompatible_target() -> Result<()> {
11 // For platforms that Cranelift supports make sure a mismatch generates an
12 // error
13 if cfg!(target_arch = "x86_64")
14 || cfg!(target_arch = "aarch64")
15 || cfg!(target_arch = "s390x")
16 || cfg!(target_arch = "riscv64")
17 {
18 let mut target = target_lexicon::Triple::host();
19 target.operating_system = target_lexicon::OperatingSystem::Unknown;
20 assert_invalid_target(&target.to_string())?;
21 }
22
23 // Otherwise make sure that the wrong pulley target is rejected on all
24 // platforms.
25 let wrong_pulley = if cfg!(target_pointer_width = "32") {
26 "pulley64"
27 } else {
28 "pulley32"
29 };
30 assert_invalid_target(wrong_pulley)?;
31
32 return Ok(());
33
34 fn assert_invalid_target(target: &str) -> Result<()> {
35 match Module::new(&Engine::new(Config::new().target(target)?)?, "(module)") {
36 Ok(_) => unreachable!(),
37 Err(e) => assert!(
38 format!("{e:?}").contains("configuration does not match the host"),
39 "bad error: {e:?}"
40 ),
41 }
42
43 Ok(())
44 }
45}
46
47#[test]
48fn caches_across_engines() {

Callers

nothing calls this directly

Calls 3

assert_invalid_targetFunction · 0.85
OkFunction · 0.85
to_stringMethod · 0.45

Tested by

no test coverage detected