1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 05:27:45 +00:00

Merge pull request #5419 from cakebaker/fuzzing_expr_lc_collate

fuzz: set LC_COLLATE=C for expr
This commit is contained in:
Sylvestre Ledru 2023-10-18 12:03:23 +02:00 committed by GitHub
commit 1cfd1192e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,7 +10,7 @@ use uu_expr::uumain;
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
use rand::Rng; use rand::Rng;
use std::ffi::OsString; use std::{env, ffi::OsString};
mod fuzz_common; mod fuzz_common;
use crate::fuzz_common::{generate_and_run_uumain, run_gnu_cmd}; use crate::fuzz_common::{generate_and_run_uumain, run_gnu_cmd};
@ -86,6 +86,11 @@ fuzz_target!(|_data: &[u8]| {
let (rust_output, uumain_exit_code) = generate_and_run_uumain(&args, uumain); let (rust_output, uumain_exit_code) = generate_and_run_uumain(&args, uumain);
// Use C locale to avoid false positives, like in https://github.com/uutils/coreutils/issues/5378,
// because uutils expr doesn't support localization yet
// TODO remove once uutils expr supports localization
env::set_var("LC_COLLATE", "C");
// Run GNU expr with the provided arguments and compare the output // Run GNU expr with the provided arguments and compare the output
match run_gnu_cmd(CMD_PATH, &args[1..], true) { match run_gnu_cmd(CMD_PATH, &args[1..], true) {
Ok((gnu_output, gnu_exit_code)) => { Ok((gnu_output, gnu_exit_code)) => {