You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
507 lines
13 KiB
507 lines
13 KiB
5 years ago
|
From c80c5ec34923b6df2487ef2d7de82800ee6feedf Mon Sep 17 00:00:00 2001
|
||
|
From: dalance <dalance@gmail.com>
|
||
|
Date: Tue, 18 Feb 2020 21:47:32 +0900
|
||
|
Subject: [PATCH] Fix test failure without docker #41
|
||
|
|
||
|
---
|
||
|
src/columns/empty.rs | 38 +++++++++++
|
||
|
src/columns/os_linux.rs | 133 +++-----------------------------------
|
||
|
src/columns/os_macos.rs | 127 +++---------------------------------
|
||
|
src/columns/os_windows.rs | 8 +++
|
||
|
4 files changed, 66 insertions(+), 240 deletions(-)
|
||
|
create mode 100644 src/columns/empty.rs
|
||
|
|
||
|
diff --git a/src/columns/empty.rs b/src/columns/empty.rs
|
||
|
new file mode 100644
|
||
|
index 0000000..d50a0b2
|
||
|
--- /dev/null
|
||
|
+++ b/src/columns/empty.rs
|
||
|
@@ -0,0 +1,38 @@
|
||
|
+use crate::process::ProcessInfo;
|
||
|
+use crate::{column_default, Column};
|
||
|
+use std::cmp;
|
||
|
+use std::collections::HashMap;
|
||
|
+
|
||
|
+pub struct Empty {
|
||
|
+ header: String,
|
||
|
+ unit: String,
|
||
|
+ fmt_contents: HashMap<i32, String>,
|
||
|
+ raw_contents: HashMap<i32, String>,
|
||
|
+ width: usize,
|
||
|
+}
|
||
|
+
|
||
|
+impl Empty {
|
||
|
+ pub fn new() -> Self {
|
||
|
+ let header = String::from("");
|
||
|
+ let unit = String::from("");
|
||
|
+ Empty {
|
||
|
+ fmt_contents: HashMap::new(),
|
||
|
+ raw_contents: HashMap::new(),
|
||
|
+ width: 0,
|
||
|
+ header,
|
||
|
+ unit,
|
||
|
+ }
|
||
|
+ }
|
||
|
+}
|
||
|
+
|
||
|
+impl Column for Empty {
|
||
|
+ fn add(&mut self, proc: &ProcessInfo) {
|
||
|
+ let raw_content = String::from("");
|
||
|
+ let fmt_content = String::from("");
|
||
|
+
|
||
|
+ self.fmt_contents.insert(proc.pid, fmt_content);
|
||
|
+ self.raw_contents.insert(proc.pid, raw_content);
|
||
|
+ }
|
||
|
+
|
||
|
+ column_default!(String);
|
||
|
+}
|
||
|
diff --git a/src/columns/os_linux.rs b/src/columns/os_linux.rs
|
||
|
index 3986a63..6804dee 100644
|
||
|
--- a/src/columns/os_linux.rs
|
||
|
+++ b/src/columns/os_linux.rs
|
||
|
@@ -4,6 +4,7 @@ pub mod cpu_time;
|
||
|
#[cfg(feature = "docker")]
|
||
|
pub mod docker;
|
||
|
pub mod eip;
|
||
|
+pub mod empty;
|
||
|
pub mod esp;
|
||
|
pub mod gid;
|
||
|
pub mod gid_fs;
|
||
|
@@ -71,6 +72,7 @@ pub use self::cpu_time::CpuTime;
|
||
|
#[cfg(feature = "docker")]
|
||
|
pub use self::docker::Docker;
|
||
|
pub use self::eip::Eip;
|
||
|
+pub use self::empty::Empty;
|
||
|
pub use self::esp::Esp;
|
||
|
pub use self::gid::Gid;
|
||
|
pub use self::gid_fs::GidFs;
|
||
|
@@ -146,9 +148,9 @@ pub enum ConfigColumnKind {
|
||
|
Command,
|
||
|
ContextSw,
|
||
|
CpuTime,
|
||
|
- #[cfg(feature = "docker")]
|
||
|
Docker,
|
||
|
Eip,
|
||
|
+ Empty,
|
||
|
Esp,
|
||
|
Gid,
|
||
|
GidFs,
|
||
|
@@ -229,7 +231,10 @@ pub fn gen_column(
|
||
|
ConfigColumnKind::CpuTime => Box::new(CpuTime::new()),
|
||
|
#[cfg(feature = "docker")]
|
||
|
ConfigColumnKind::Docker => Box::new(Docker::new(_docker_path)),
|
||
|
+ #[cfg(not(feature = "docker"))]
|
||
|
+ ConfigColumnKind::Docker => Box::new(Empty::new()),
|
||
|
ConfigColumnKind::Eip => Box::new(Eip::new()),
|
||
|
+ ConfigColumnKind::Empty => Box::new(Empty::new()),
|
||
|
ConfigColumnKind::Esp => Box::new(Esp::new()),
|
||
|
ConfigColumnKind::Gid => Box::new(Gid::new(abbr_sid)),
|
||
|
ConfigColumnKind::GidFs => Box::new(GidFs::new()),
|
||
|
@@ -312,12 +317,12 @@ lazy_static! {
|
||
|
ConfigColumnKind::CpuTime,
|
||
|
("CpuTime", "Cumulative CPU time")
|
||
|
),
|
||
|
- #[cfg(feature = "docker")]
|
||
|
(
|
||
|
ConfigColumnKind::Docker,
|
||
|
("Docker", "Docker container name")
|
||
|
),
|
||
|
(ConfigColumnKind::Eip, ("Eip", "Instruction pointer")),
|
||
|
+ (ConfigColumnKind::Empty, ("Empty", "Empty")),
|
||
|
(ConfigColumnKind::Esp, ("Esp", "Stack pointer")),
|
||
|
(ConfigColumnKind::Gid, ("Gid", "Group ID")),
|
||
|
(ConfigColumnKind::GidFs, ("GidFs", "File system group ID")),
|
||
|
@@ -453,7 +458,6 @@ lazy_static! {
|
||
|
// CONFIG_DEFAULT
|
||
|
// ---------------------------------------------------------------------------------------------------------------------
|
||
|
|
||
|
-#[cfg(feature = "docker")]
|
||
|
pub static CONFIG_DEFAULT: &str = r#"
|
||
|
[[columns]]
|
||
|
kind = "Pid"
|
||
|
@@ -578,126 +582,6 @@ numeric_search = false
|
||
|
nonnumeric_search = true
|
||
|
"#;
|
||
|
|
||
|
-#[cfg(not(feature = "docker"))]
|
||
|
-pub static CONFIG_DEFAULT: &str = r#"
|
||
|
-[[columns]]
|
||
|
-kind = "Pid"
|
||
|
-style = "BrightYellow"
|
||
|
-numeric_search = true
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "User"
|
||
|
-style = "BrightGreen"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = true
|
||
|
-[[columns]]
|
||
|
-kind = "Separator"
|
||
|
-style = "White"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "State"
|
||
|
-style = "ByState"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "Nice"
|
||
|
-style = "BrightMagenta"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "Tty"
|
||
|
-style = "BrightWhite"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "UsageCpu"
|
||
|
-style = "ByPercentage"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "UsageMem"
|
||
|
-style = "ByPercentage"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "VmPeak"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "VmSize"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "VmRss"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "TcpPort"
|
||
|
-style = "BrightCyan"
|
||
|
-numeric_search = true
|
||
|
-nonnumeric_search = false
|
||
|
-max_width = 20
|
||
|
-[[columns]]
|
||
|
-kind = "UdpPort"
|
||
|
-style = "BrightCyan"
|
||
|
-numeric_search = true
|
||
|
-nonnumeric_search = false
|
||
|
-max_width = 20
|
||
|
-[[columns]]
|
||
|
-kind = "ReadBytes"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "WriteBytes"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "Slot"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "Separator"
|
||
|
-style = "White"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "CpuTime"
|
||
|
-style = "BrightCyan"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "StartTime"
|
||
|
-style = "BrightMagenta"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "Separator"
|
||
|
-style = "White"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "Command"
|
||
|
-style = "BrightWhite"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = true
|
||
|
-"#;
|
||
|
-
|
||
|
// ---------------------------------------------------------------------------------------------------------------------
|
||
|
// CONFIG_ALL
|
||
|
// ---------------------------------------------------------------------------------------------------------------------
|
||
|
@@ -723,6 +607,9 @@ style = "BrightMagenta"
|
||
|
kind = "Eip"
|
||
|
style = "BrightYellow"
|
||
|
[[columns]]
|
||
|
+kind = "Empty"
|
||
|
+style = "BrightYellow"
|
||
|
+[[columns]]
|
||
|
kind = "Esp"
|
||
|
style = "BrightBlue"
|
||
|
[[columns]]
|
||
|
diff --git a/src/columns/os_macos.rs b/src/columns/os_macos.rs
|
||
|
index 1302786..3906950 100644
|
||
|
--- a/src/columns/os_macos.rs
|
||
|
+++ b/src/columns/os_macos.rs
|
||
|
@@ -3,6 +3,7 @@ pub mod context_sw;
|
||
|
pub mod cpu_time;
|
||
|
#[cfg(feature = "docker")]
|
||
|
pub mod docker;
|
||
|
+pub mod empty;
|
||
|
pub mod gid;
|
||
|
pub mod gid_real;
|
||
|
pub mod gid_saved;
|
||
|
@@ -43,6 +44,7 @@ pub use self::context_sw::ContextSw;
|
||
|
pub use self::cpu_time::CpuTime;
|
||
|
#[cfg(feature = "docker")]
|
||
|
pub use self::docker::Docker;
|
||
|
+pub use self::empty::Empty;
|
||
|
pub use self::gid::Gid;
|
||
|
pub use self::gid_real::GidReal;
|
||
|
pub use self::gid_saved::GidSaved;
|
||
|
@@ -92,8 +94,8 @@ pub enum ConfigColumnKind {
|
||
|
Command,
|
||
|
ContextSw,
|
||
|
CpuTime,
|
||
|
- #[cfg(feature = "docker")]
|
||
|
Docker,
|
||
|
+ Empty,
|
||
|
Gid,
|
||
|
GidReal,
|
||
|
GidSaved,
|
||
|
@@ -148,6 +150,9 @@ pub fn gen_column(
|
||
|
ConfigColumnKind::CpuTime => Box::new(CpuTime::new()),
|
||
|
#[cfg(feature = "docker")]
|
||
|
ConfigColumnKind::Docker => Box::new(Docker::new(_docker_path)),
|
||
|
+ #[cfg(not(feature = "docker"))]
|
||
|
+ ConfigColumnKind::Docker => Box::new(Empty::new()),
|
||
|
+ ConfigColumnKind::Empty => Box::new(Empty::new()),
|
||
|
ConfigColumnKind::Gid => Box::new(Gid::new(abbr_sid)),
|
||
|
ConfigColumnKind::GidReal => Box::new(GidReal::new()),
|
||
|
ConfigColumnKind::GidSaved => Box::new(GidSaved::new()),
|
||
|
@@ -204,11 +209,11 @@ lazy_static! {
|
||
|
ConfigColumnKind::CpuTime,
|
||
|
("CpuTime", "Cumulative CPU time")
|
||
|
),
|
||
|
- #[cfg(feature = "docker")]
|
||
|
(
|
||
|
ConfigColumnKind::Docker,
|
||
|
("Docker", "Docker container name")
|
||
|
),
|
||
|
+ (ConfigColumnKind::Empty, ("Empty", "Empty")),
|
||
|
(ConfigColumnKind::Gid, ("Gid", "Group ID")),
|
||
|
(ConfigColumnKind::GidReal, ("GidReal", "Real group ID")),
|
||
|
(ConfigColumnKind::GidSaved, ("GidSaved", "Saved group ID")),
|
||
|
@@ -282,7 +287,6 @@ lazy_static! {
|
||
|
// CONFIG_DEFAULT
|
||
|
// ---------------------------------------------------------------------------------------------------------------------
|
||
|
|
||
|
-#[cfg(feature = "docker")]
|
||
|
pub static CONFIG_DEFAULT: &str = r#"
|
||
|
[[columns]]
|
||
|
kind = "Pid"
|
||
|
@@ -401,120 +405,6 @@ numeric_search = false
|
||
|
nonnumeric_search = true
|
||
|
"#;
|
||
|
|
||
|
-#[cfg(not(feature = "docker"))]
|
||
|
-pub static CONFIG_DEFAULT: &str = r#"
|
||
|
-[[columns]]
|
||
|
-kind = "Pid"
|
||
|
-style = "BrightYellow"
|
||
|
-numeric_search = true
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "User"
|
||
|
-style = "BrightGreen"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = true
|
||
|
-[[columns]]
|
||
|
-kind = "Separator"
|
||
|
-style = "White"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "State"
|
||
|
-style = "ByState"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "Nice"
|
||
|
-style = "BrightMagenta"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "Tty"
|
||
|
-style = "BrightWhite"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "UsageCpu"
|
||
|
-style = "ByPercentage"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "UsageMem"
|
||
|
-style = "ByPercentage"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "VmSize"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "VmRss"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "TcpPort"
|
||
|
-style = "BrightCyan"
|
||
|
-numeric_search = true
|
||
|
-nonnumeric_search = false
|
||
|
-max_width = 20
|
||
|
-[[columns]]
|
||
|
-kind = "UdpPort"
|
||
|
-style = "BrightCyan"
|
||
|
-numeric_search = true
|
||
|
-nonnumeric_search = false
|
||
|
-max_width = 20
|
||
|
-[[columns]]
|
||
|
-kind = "ReadBytes"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "WriteBytes"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "Slot"
|
||
|
-style = "ByUnit"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-align = "Right"
|
||
|
-[[columns]]
|
||
|
-kind = "Separator"
|
||
|
-style = "White"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "CpuTime"
|
||
|
-style = "BrightCyan"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "StartTime"
|
||
|
-style = "BrightMagenta"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "Separator"
|
||
|
-style = "White"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = false
|
||
|
-[[columns]]
|
||
|
-kind = "Command"
|
||
|
-style = "BrightWhite"
|
||
|
-numeric_search = false
|
||
|
-nonnumeric_search = true
|
||
|
-"#;
|
||
|
-
|
||
|
// ---------------------------------------------------------------------------------------------------------------------
|
||
|
// CONFIG_ALL
|
||
|
// ---------------------------------------------------------------------------------------------------------------------
|
||
|
@@ -537,6 +427,9 @@ align = "Center"
|
||
|
kind = "Docker"
|
||
|
style = "BrightMagenta"
|
||
|
[[columns]]
|
||
|
+kind = "Empty"
|
||
|
+style = "BrightYellow"
|
||
|
+[[columns]]
|
||
|
kind = "Gid"
|
||
|
style = "White"
|
||
|
[[columns]]
|
||
|
diff --git a/src/columns/os_windows.rs b/src/columns/os_windows.rs
|
||
|
index 401d33e..357feaa 100644
|
||
|
--- a/src/columns/os_windows.rs
|
||
|
+++ b/src/columns/os_windows.rs
|
||
|
@@ -1,5 +1,6 @@
|
||
|
pub mod command;
|
||
|
pub mod cpu_time;
|
||
|
+pub mod empty;
|
||
|
pub mod gid;
|
||
|
pub mod group;
|
||
|
pub mod maj_flt;
|
||
|
@@ -26,6 +27,7 @@ pub mod write_bytes;
|
||
|
|
||
|
pub use self::command::Command;
|
||
|
pub use self::cpu_time::CpuTime;
|
||
|
+pub use self::empty::Empty;
|
||
|
pub use self::gid::Gid;
|
||
|
pub use self::group::Group;
|
||
|
pub use self::maj_flt::MajFlt;
|
||
|
@@ -63,6 +65,7 @@ use std::collections::HashMap;
|
||
|
pub enum ConfigColumnKind {
|
||
|
Command,
|
||
|
CpuTime,
|
||
|
+ Empty,
|
||
|
Gid,
|
||
|
Group,
|
||
|
MajFlt,
|
||
|
@@ -102,6 +105,7 @@ pub fn gen_column(
|
||
|
match kind {
|
||
|
ConfigColumnKind::Command => Box::new(Command::new()),
|
||
|
ConfigColumnKind::CpuTime => Box::new(CpuTime::new()),
|
||
|
+ ConfigColumnKind::Empty => Box::new(Empty::new()),
|
||
|
ConfigColumnKind::Gid => Box::new(Gid::new(abbr_sid)),
|
||
|
ConfigColumnKind::Group => Box::new(Group::new(abbr_sid)),
|
||
|
ConfigColumnKind::MajFlt => Box::new(MajFlt::new()),
|
||
|
@@ -142,6 +146,7 @@ lazy_static! {
|
||
|
ConfigColumnKind::CpuTime,
|
||
|
("CpuTime", "Cumulative CPU time")
|
||
|
),
|
||
|
+ (ConfigColumnKind::Empty, ("Empty", "Empty")),
|
||
|
(ConfigColumnKind::Gid, ("Gid", "Group ID")),
|
||
|
(ConfigColumnKind::Group, ("Group", "Group name")),
|
||
|
(
|
||
|
@@ -303,6 +308,9 @@ kind = "CpuTime"
|
||
|
style = "BrightGreen"
|
||
|
align = "Center"
|
||
|
[[columns]]
|
||
|
+kind = "Empty"
|
||
|
+style = "BrightYellow"
|
||
|
+[[columns]]
|
||
|
kind = "Gid"
|
||
|
style = "White"
|
||
|
[[columns]]
|
||
|
--
|
||
|
2.25.0
|
||
|
|