更新libclamav库1.0.0版本

This commit is contained in:
2023-01-14 18:28:39 +08:00
parent b879ee0b2e
commit 45fe15f472
8531 changed files with 1222046 additions and 177272 deletions

View File

@@ -0,0 +1,40 @@
extern crate env_logger;
extern crate log;
use std::env;
use std::process;
use std::str;
fn main() {
if env::var("YOU_ARE_TESTING_NOW").is_ok() {
// Init from the env (which should set the max level to `Debug`)
env_logger::init();
assert_eq!(log::LevelFilter::Debug, log::max_level());
// Init again using a different max level
// This shouldn't clobber the level that was previously set
env_logger::Builder::new()
.parse_filters("info")
.try_init()
.unwrap_err();
assert_eq!(log::LevelFilter::Debug, log::max_level());
return;
}
let exe = env::current_exe().unwrap();
let out = process::Command::new(exe)
.env("YOU_ARE_TESTING_NOW", "1")
.env("RUST_LOG", "debug")
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
if out.status.success() {
return;
}
println!("test failed: {}", out.status);
println!("--- stdout\n{}", str::from_utf8(&out.stdout).unwrap());
println!("--- stderr\n{}", str::from_utf8(&out.stderr).unwrap());
process::exit(1);
}

View File

@@ -0,0 +1,39 @@
#[macro_use]
extern crate log;
extern crate env_logger;
use std::env;
use std::fmt;
use std::process;
use std::str;
struct Foo;
impl fmt::Display for Foo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
info!("test");
f.write_str("bar")
}
}
fn main() {
env_logger::init();
if env::var("YOU_ARE_TESTING_NOW").is_ok() {
return info!("{}", Foo);
}
let exe = env::current_exe().unwrap();
let out = process::Command::new(exe)
.env("YOU_ARE_TESTING_NOW", "1")
.env("RUST_LOG", "debug")
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
if out.status.success() {
return;
}
println!("test failed: {}", out.status);
println!("--- stdout\n{}", str::from_utf8(&out.stdout).unwrap());
println!("--- stderr\n{}", str::from_utf8(&out.stderr).unwrap());
process::exit(1);
}

View File

@@ -0,0 +1,66 @@
#[macro_use]
extern crate log;
extern crate env_logger;
use std::env;
use std::process;
use std::str;
use std::thread;
struct DropMe;
impl Drop for DropMe {
fn drop(&mut self) {
debug!("Dropping now");
}
}
fn run() {
// Use multiple thread local values to increase the chance that our TLS
// value will get destroyed after the FORMATTER key in the library
thread_local! {
static DROP_ME_0: DropMe = DropMe;
static DROP_ME_1: DropMe = DropMe;
static DROP_ME_2: DropMe = DropMe;
static DROP_ME_3: DropMe = DropMe;
static DROP_ME_4: DropMe = DropMe;
static DROP_ME_5: DropMe = DropMe;
static DROP_ME_6: DropMe = DropMe;
static DROP_ME_7: DropMe = DropMe;
static DROP_ME_8: DropMe = DropMe;
static DROP_ME_9: DropMe = DropMe;
}
DROP_ME_0.with(|_| {});
DROP_ME_1.with(|_| {});
DROP_ME_2.with(|_| {});
DROP_ME_3.with(|_| {});
DROP_ME_4.with(|_| {});
DROP_ME_5.with(|_| {});
DROP_ME_6.with(|_| {});
DROP_ME_7.with(|_| {});
DROP_ME_8.with(|_| {});
DROP_ME_9.with(|_| {});
}
fn main() {
env_logger::init();
if env::var("YOU_ARE_TESTING_NOW").is_ok() {
// Run on a separate thread because TLS values on the main thread
// won't have their destructors run if pthread is used.
// https://doc.rust-lang.org/std/thread/struct.LocalKey.html#platform-specific-behavior
thread::spawn(run).join().unwrap();
} else {
let exe = env::current_exe().unwrap();
let out = process::Command::new(exe)
.env("YOU_ARE_TESTING_NOW", "1")
.env("RUST_LOG", "debug")
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
if !out.status.success() {
println!("test failed: {}", out.status);
println!("--- stdout\n{}", str::from_utf8(&out.stdout).unwrap());
println!("--- stderr\n{}", str::from_utf8(&out.stderr).unwrap());
process::exit(1);
}
}
}

View File

@@ -0,0 +1,57 @@
#[macro_use]
extern crate log;
extern crate env_logger;
use std::env;
use std::process;
use std::str;
fn main() {
if env::var("LOG_REGEXP_TEST").ok() == Some(String::from("1")) {
child_main();
} else {
parent_main()
}
}
fn child_main() {
env_logger::init();
info!("XYZ Message");
}
fn run_child(rust_log: String) -> bool {
let exe = env::current_exe().unwrap();
let out = process::Command::new(exe)
.env("LOG_REGEXP_TEST", "1")
.env("RUST_LOG", rust_log)
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
str::from_utf8(out.stderr.as_ref())
.unwrap()
.contains("XYZ Message")
}
fn assert_message_printed(rust_log: &str) {
if !run_child(rust_log.to_string()) {
panic!("RUST_LOG={} should allow the test log message", rust_log)
}
}
fn assert_message_not_printed(rust_log: &str) {
if run_child(rust_log.to_string()) {
panic!(
"RUST_LOG={} should not allow the test log message",
rust_log
)
}
}
fn parent_main() {
// test normal log severity levels
assert_message_printed("info");
assert_message_not_printed("warn");
// test of regular expression filters
assert_message_printed("info/XYZ");
assert_message_not_printed("info/XXX");
}