fsfreeze: Add tool

Add fsfreeze, a Linux-specific tool used to freeze/thaw writes to a
filesystem. It's an extremely simple tool so this should have full
feature-parity.
This commit is contained in:
Tuomas Tynkkynen
2025-01-04 14:27:06 +02:00
parent 257d142a5b
commit ca574b49d3
9 changed files with 192 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
// This file is part of the uutils util-linux package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use crate::common::util::TestScenario;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_operations_mutually_exclusive() {
new_ucmd!()
.arg("--freeze")
.arg("--unfreeze")
.arg("/foo")
.fails()
.code_is(1)
.stderr_contains("the argument '--freeze' cannot be used with '--unfreeze'");
}
#[cfg(target_os = "linux")]
mod linux {
use crate::common::util::TestScenario;
#[test]
fn test_fails_on_non_existing_path() {
new_ucmd!()
.arg("--unfreeze")
.arg("/non/existing")
.fails()
.code_is(1)
.stderr_contains("No such file or directory");
}
#[test]
fn test_fails_on_non_directory() {
new_ucmd!()
.arg("--unfreeze")
.arg("/dev/null")
.fails()
.code_is(1)
.stderr_contains("not a directory");
}
}
#[cfg(not(target_os = "linux"))]
mod non_linux {
use crate::common::util::TestScenario;
#[test]
fn test_fails_on_unsupported_platforms() {
new_ucmd!()
.arg("--unfreeze")
.arg("/non/existing")
.fails()
.code_is(1)
.stderr_is("fsfreeze: `fsfreeze` is available only on Linux.\n");
}
}

View File

@@ -36,3 +36,7 @@ mod test_last;
#[cfg(feature = "dmesg")]
#[path = "by-util/test_dmesg.rs"]
mod test_dmesg;
#[cfg(feature = "fsfreeze")]
#[path = "by-util/test_fsfreeze.rs"]
mod test_fsfreeze;