]> Repositorios git - scryer-prolog.git/commitdiff
move test to tests/scryer/ffi.rs
authorThierry Marianne <[email protected]>
Wed, 4 Mar 2026 12:57:17 +0000 (13:57 +0100)
committerThierry Marianne <[email protected]>
Wed, 4 Mar 2026 13:01:17 +0000 (14:01 +0100)
Signed-off-by: Thierry Marianne <[email protected]>
tests/scryer/ffi.rs
tests/scryer/issues.rs

index abe5c9b76aaedf6e628af3dca21f0bf95c6ff1e2..bbc24c5015e2b1082d66daf17cf180ccab6b8d10 100644 (file)
@@ -302,3 +302,24 @@ fn ffi_heap() {
         r#"133742"#,
     );
 }
+
+#[test]
+#[cfg_attr(miri, ignore = "ffi")]
+fn ffi_utf8_panic() {
+    let dynlib_path = build_dynamic_library(
+        "ffi_utf8_panic",
+        r##"
+                #[unsafe(no_mangle)]
+                extern "C" fn ffi_invalid_utf8_cstr() -> *const core::ffi::c_char {
+                    b"Invalid\xFFUTF8\x00".as_ptr() as *const _
+                }
+            "##,
+    );
+
+    load_module_test_with_input(
+        "tests-pl/ffi_utf8_panic.pl",
+        format!("LIB={dynlib_path:?}."),
+        // Evaluates to: 'Invalid\xFFUTF8\n'
+        "[73,110,118,97,108,105,100,255,85,84,70,56]\n",
+    );
+}
index 6bfd68711d04f541d8e08cbf728b7cecf37da6a1..bedaa9bfaab9fb22f92c5b2dbbd5cf09e8730703 100644 (file)
@@ -151,49 +151,3 @@ fn http_open_hanging() {
     );
 }
 
-#[test]
-#[cfg_attr(miri, ignore = "ffi")]
-fn ffi_utf8_panic() {
-    let tmp_dir: &std::path::Path = env!("CARGO_TARGET_TMPDIR").as_ref();
-    let name = "ffi_utf8_panic";
-    let src = r##"
-        #[unsafe(no_mangle)]
-        extern "C" fn ffi_invalid_utf8_cstr() -> *const core::ffi::c_char {
-            c"Invalid\xFFUTF8".as_ptr()
-        }
-    "##;
-
-    let mut child = std::process::Command::new("rustc")
-        .stdin(std::process::Stdio::piped())
-        .args(["--edition", "2024"])
-        .arg(format!("--target={}", current_platform::CURRENT_PLATFORM))
-        .arg("--crate-type=dylib")
-        .arg(format!("--crate-name={name}"))
-        .arg("--out-dir")
-        .arg(tmp_dir)
-        .arg("-")
-        .spawn()
-        .unwrap();
-
-    use std::io::Write;
-    child
-        .stdin
-        .take()
-        .unwrap()
-        .write_all(src.as_bytes())
-        .unwrap();
-    assert!(child.wait().unwrap().success());
-
-    let dynlib_path = tmp_dir.join(format!(
-        "{}{name}{}",
-        std::env::consts::DLL_PREFIX,
-        std::env::consts::DLL_SUFFIX
-    ));
-
-    crate::helper::load_module_test_with_input(
-        "tests-pl/ffi_utf8_panic.pl",
-        format!("LIB={dynlib_path:?}."),
-        // Evaluates to: 'Invalid\xFFUTF8\n'
-        "[73,110,118,97,108,105,100,255,85,84,70,56]\n",
-    );
-}