mirror of
https://github.com/uutils/coreutils.git
synced 2025-08-18 17:51:12 +00:00
Fuzz the expr command
This commit is contained in:
parent
bd0fb817a7
commit
ec7ced2518
4 changed files with 228 additions and 0 deletions
30
fuzz/fuzz_targets/fuzz_common.rs
Normal file
30
fuzz/fuzz_targets/fuzz_common.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
// This file is part of the uutils coreutils package.
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
use std::process::Command;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::{atomic::AtomicBool, Once};
|
||||
|
||||
static CHECK_GNU: Once = Once::new();
|
||||
static IS_GNU: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub fn is_gnu_cmd(cmd_path: &str) -> Result<(), std::io::Error> {
|
||||
CHECK_GNU.call_once(|| {
|
||||
let version_output = Command::new(cmd_path).arg("--version").output().unwrap();
|
||||
|
||||
println!("version_output {:#?}", version_output);
|
||||
|
||||
let version_str = String::from_utf8_lossy(&version_output.stdout).to_string();
|
||||
if version_str.contains("GNU coreutils") {
|
||||
IS_GNU.store(true, Ordering::Relaxed);
|
||||
}
|
||||
});
|
||||
|
||||
if IS_GNU.load(Ordering::Relaxed) {
|
||||
Ok(())
|
||||
} else {
|
||||
panic!("Not the GNU implementation");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue