products/Sources/formale Sprachen/C/Firefox/third_party/rust/webrtc-sdp/examples/sdps/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 3 kB image not shown  

SSL test_inotify.rs

  Interaktion und
PortierbarkeitRust
 

use nix::errno::Errno;
use nix::sys::inotify::{AddWatchFlags, InitFlags, Inotify};
use std::ffi::OsString;
use std::fs::{rename, File};

#[test]
pub fn test_inotify() {
    let instance = Inotify::init(InitFlags::IN_NONBLOCK).unwrap();
    let tempdir = tempfile::tempdir().unwrap();

    instance
        .add_watch(tempdir.path(), AddWatchFlags::IN_ALL_EVENTS)
        .unwrap();

    let events = instance.read_events();
    assert_eq!(events.unwrap_err(), Errno::EAGAIN);

    File::create(tempdir.path().join("test")).unwrap();

    let events = instance.read_events().unwrap();
    assert_eq!(events[0].name, Some(OsString::from("test")));
}

#[test]
pub fn test_inotify_multi_events() {
    let instance = Inotify::init(InitFlags::IN_NONBLOCK).unwrap();
    let tempdir = tempfile::tempdir().unwrap();

    instance
        .add_watch(tempdir.path(), AddWatchFlags::IN_ALL_EVENTS)
        .unwrap();

    let events = instance.read_events();
    assert_eq!(events.unwrap_err(), Errno::EAGAIN);

    File::create(tempdir.path().join("test")).unwrap();
    rename(tempdir.path().join("test"), tempdir.path().join("test2")).unwrap();

    // Now there should be 5 events in queue:
    //   - IN_CREATE on test
    //   - IN_OPEN on test
    //   - IN_CLOSE_WRITE on test
    //   - IN_MOVED_FROM on test with a cookie
    //   - IN_MOVED_TO on test2 with the same cookie

    let events = instance.read_events().unwrap();
    assert_eq!(events.len(), 5);

    assert_eq!(events[0].mask, AddWatchFlags::IN_CREATE);
    assert_eq!(events[0].name, Some(OsString::from("test")));

    assert_eq!(events[1].mask, AddWatchFlags::IN_OPEN);
    assert_eq!(events[1].name, Some(OsString::from("test")));

    assert_eq!(events[2].mask, AddWatchFlags::IN_CLOSE_WRITE);
    assert_eq!(events[2].name, Some(OsString::from("test")));

    assert_eq!(events[3].mask, AddWatchFlags::IN_MOVED_FROM);
    assert_eq!(events[3].name, Some(OsString::from("test")));

    assert_eq!(events[4].mask, AddWatchFlags::IN_MOVED_TO);
    assert_eq!(events[4].name, Some(OsString::from("test2")));

    assert_eq!(events[3].cookie, events[4].cookie);
}

Messung V0.5 in Prozent
C=86 H=96 G=90

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.0Angebot  (Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-06-19) ¤

*Eine klare Vorstellung vom Zielzustand






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.