Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/nix/test/mount/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1 kB image not shown  

Quelle  test_nmount.rs

  Sprache: Rust
 

use crate::*;
use nix::{
    errno::Errno,
    mount::{unmount, MntFlags, Nmount},
};
use std::{ffi::CString, fs::File, path::Path};
use tempfile::tempdir;

#[test]
fn ok() {
    require_mount!("nullfs");

    let mountpoint = tempdir().unwrap();
    let target = tempdir().unwrap();
    let _sentry = File::create(target.path().join("sentry")).unwrap();

    let fstype = CString::new("fstype").unwrap();
    let nullfs = CString::new("nullfs").unwrap();
    Nmount::new()
        .str_opt(&fstype, &nullfs)
        .str_opt_owned("fspath", mountpoint.path().to_str().unwrap())
        .str_opt_owned("target", target.path().to_str().unwrap())
        .nmount(MntFlags::empty())
        .unwrap();

    // Now check that the sentry is visible through the mountpoint
    let exists = Path::exists(&mountpoint.path().join("sentry"));

    // Cleanup the mountpoint before asserting
    unmount(mountpoint.path(), MntFlags::empty()).unwrap();

    assert!(exists);
}

#[test]
fn bad_fstype() {
    let mountpoint = tempdir().unwrap();
    let target = tempdir().unwrap();
    let _sentry = File::create(target.path().join("sentry")).unwrap();

    let e = Nmount::new()
        .str_opt_owned("fspath", mountpoint.path().to_str().unwrap())
        .str_opt_owned("target", target.path().to_str().unwrap())
        .nmount(MntFlags::empty())
        .unwrap_err();

    assert_eq!(e.error(), Errno::EINVAL);
    assert_eq!(e.errmsg(), Some("Invalid fstype"));
}

Messung V0.5 in Prozent
C=82 H=100 G=91

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-08-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.