Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
beffae7cd4 | |||
477ad7482a | |||
833c71bed5 | |||
182d9b3cb4 | |||
94218af170 | |||
9856c59da9 | |||
e41a4dfffb | |||
6f86266dee | |||
e39b78d5d7 | |||
be549808b5 |
@ -2,12 +2,15 @@ pipeline:
|
||||
test_build:
|
||||
image: rust:1.62
|
||||
commands:
|
||||
- cargo build
|
||||
- "cargo build"
|
||||
|
||||
build_release:
|
||||
image: rust:1.62
|
||||
commands:
|
||||
- cargo build --release
|
||||
- "cargo install cargo-deb cargo-generate-rpm"
|
||||
- "cargo build --release"
|
||||
- "cargo deb"
|
||||
- "cargo generate-rpm"
|
||||
- "mv target/release/bgbench target/release/bgbench-${CI_COMMIT_TAG}-linux-x86_64"
|
||||
when:
|
||||
event: tag
|
||||
@ -20,6 +23,8 @@ pipeline:
|
||||
base_url: https://git.metaunix.net
|
||||
files:
|
||||
- "target/release/*${CI_COMMIT_TAG}-linux-x86_64"
|
||||
- "target/debian/hardware-tests*.deb"
|
||||
- "target/generate-rpm/hardware-tests*.rpm"
|
||||
title: "${CI_COMMIT_TAG}"
|
||||
when:
|
||||
event: tag
|
||||
|
18
Cargo.toml
18
Cargo.toml
@ -1,14 +1,26 @@
|
||||
[package]
|
||||
name = "hardware-tests"
|
||||
version = "0.2.0"
|
||||
description = "Bit Goblin PC hardware test suite."
|
||||
version = "0.2.4"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license = "BSD 2-Clause"
|
||||
authors = ["Gregory Ballantine <gballantine@bitgoblin.tech>"]
|
||||
|
||||
[[bin]]
|
||||
name = "bgbench"
|
||||
path = "src/main.rs"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.20"
|
||||
clap = { version = "3.2.16", features = ["derive"] }
|
||||
|
||||
[package.metadata.deb]
|
||||
depends = "fio"
|
||||
|
||||
[package.metadata.generate-rpm]
|
||||
assets = [
|
||||
{ source = "target/release/bgbench", dest = "/usr/bin/bgbench", mode = "755" },
|
||||
]
|
||||
[package.metadata.generate-rpm.requires]
|
||||
fio = "*"
|
||||
|
11
README.md
11
README.md
@ -1,6 +1,6 @@
|
||||
# Bit Goblin Hardware Tests
|
||||
|
||||
Scripts used for testing hardware in Bit Goblin's videos.
|
||||
Benchmarking suite used for testing hardware in Bit Goblin's videos.
|
||||
|
||||
## Download & Installation
|
||||
|
||||
@ -8,9 +8,16 @@ Check out the [Releases page](https://git.metaunix.net/BitGoblin/hardware-tests/
|
||||
|
||||
Currently there is no installation method other than downloading the provided release binaries. In the future I want to build Linux package repositories for this, and have a Windows installer.
|
||||
|
||||
## Running
|
||||
|
||||
Simply run the tool with `./bgbench` and you'll be presented with the available subcommands.
|
||||
|
||||
### Runtime requirements:
|
||||
* disk - requires `fio`.
|
||||
|
||||
## Building
|
||||
|
||||
The easiest way to build the program is using the official Rust image from Docker Hub, for which there's a wrapper script at `bin/docker-build.sh` that can be used to build the test programs. These will be available under `target/debug/`.
|
||||
The easiest way to build the program is using the official Rust image from Docker Hub, for which there's a wrapper script at `bin/docker-build.sh` that can be used to build the test program. These will be available under `target/debug/`. Else you can just run a `cargo build` to compile the program.
|
||||
|
||||
## License
|
||||
|
||||
|
82
src/main.rs
82
src/main.rs
@ -1,6 +1,6 @@
|
||||
mod tests;
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "Bit Goblin Benchmark", author, version, about = "Bit Goblin's hardware benchmarking tool.", long_about = None)]
|
||||
@ -8,6 +8,9 @@ use clap::{Parser, Subcommand};
|
||||
struct Cli {
|
||||
#[clap(subcommand)]
|
||||
command: Commands,
|
||||
|
||||
#[clap(short = 'l', default_value_t = 1, help = "Number of times to run test. Default = 1", global = true)]
|
||||
loopcount: u8,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
@ -20,19 +23,47 @@ enum Commands {
|
||||
Net(Net),
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
#[derive(Args)]
|
||||
struct Disk {
|
||||
#[structopt(subcommand)]
|
||||
#[clap(subcommand)]
|
||||
disk_commands: DiskCommands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum DiskCommands {
|
||||
#[clap(name = "write-test", about = "Write a large file to determine sequential disk speeds.")]
|
||||
WriteTest {
|
||||
// sequential disk read subcommand
|
||||
#[clap(name = "read_seq", about = "Sequential disk read speed test.")]
|
||||
ReadSeqTest {
|
||||
#[clap(short = 'f', default_value_t = String::from("/tmp/disk-test.tmp"))]
|
||||
tempfile: String,
|
||||
#[clap(short = 's', default_value_t = 15)]
|
||||
size: u8,
|
||||
},
|
||||
|
||||
// random disk read subcommand
|
||||
#[clap(name = "read_rand", about = "Random 4K disk read speed test.")]
|
||||
ReadRandTest {
|
||||
#[clap(short = 'f', default_value_t = String::from("/tmp/disk-test.tmp"))]
|
||||
tempfile: String,
|
||||
#[clap(short = 's', default_value_t = 15)]
|
||||
size: u8,
|
||||
},
|
||||
|
||||
// sequential disk write subcommand
|
||||
#[clap(name = "write_seq", about = "Write a large file to determine sequential disk write speeds.")]
|
||||
WriteSeqTest {
|
||||
#[clap(short = 't', default_value_t = String::from("/tmp/disk-test.tmp"))]
|
||||
tempfile: String,
|
||||
#[clap(short = 's', default_value_t = 5)]
|
||||
#[clap(short = 's', default_value_t = 15)]
|
||||
size: u8,
|
||||
},
|
||||
|
||||
// random 4K disk write subcommand
|
||||
#[clap(name = "write_rand", about = "Write a bunch of smallfiles to determine random disk write speeds.")]
|
||||
WriteRandTest {
|
||||
#[clap(short = 't', default_value_t = String::from("/tmp/disk-test.tmp"))]
|
||||
tempfile: String,
|
||||
#[clap(short = 's', default_value_t = 15)]
|
||||
size: u8,
|
||||
},
|
||||
}
|
||||
@ -70,12 +101,45 @@ fn main() {
|
||||
// map subcommands back to the main command
|
||||
match &cli.command {
|
||||
Commands::Disk(args) => match &args.disk_commands {
|
||||
DiskCommands::WriteTest { tempfile, size } => tests::disk::disk_write_test(tempfile, size),
|
||||
DiskCommands::ReadSeqTest { tempfile, size } => {
|
||||
for i in 0..cli.loopcount {
|
||||
println!("Test run number {}.", i + 1);
|
||||
tests::disk::disk_read_seq_test(tempfile, size);
|
||||
}
|
||||
},
|
||||
DiskCommands::ReadRandTest { tempfile, size } => {
|
||||
for i in 0..cli.loopcount {
|
||||
println!("Test run number {}.", i + 1);
|
||||
tests::disk::disk_read_rand_test(tempfile, size);
|
||||
}
|
||||
},
|
||||
DiskCommands::WriteSeqTest { tempfile, size } => {
|
||||
for i in 0..cli.loopcount {
|
||||
println!("Test run number {}.", i + 1);
|
||||
tests::disk::disk_write_seq_test(tempfile, size);
|
||||
}
|
||||
},
|
||||
DiskCommands::WriteRandTest { tempfile, size } => {
|
||||
for i in 0..cli.loopcount {
|
||||
println!("Test run number {}.", i + 1);
|
||||
tests::disk::disk_write_rand_test(tempfile, size);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Commands::Net(args) => match &args.net_commands {
|
||||
NetCommands::Ping { host, count } => tests::network::ping_host(host, count),
|
||||
NetCommands::Bandwidth { download, output } => tests::network::bandwidth_test(download, output),
|
||||
NetCommands::Ping { host, count } => {
|
||||
for i in 0..cli.loopcount {
|
||||
println!("Test run number {}.", i + 1);
|
||||
tests::network::ping_host(host, count);
|
||||
}
|
||||
},
|
||||
NetCommands::Bandwidth { download, output } => {
|
||||
for i in 0..cli.loopcount {
|
||||
println!("Test run number {}.", i + 1);
|
||||
tests::network::bandwidth_test(download, output);
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,109 @@
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
|
||||
// test disk write speeds by continually writing zeroes to it
|
||||
pub fn disk_write_test(tempfile: &str, size: &u8) {
|
||||
// convert size in Gigabytes down to Megabytes
|
||||
let size_gigs: u32 = (*size as u32 * 1024).into();
|
||||
|
||||
// run the dd command with a block size of 1 MB
|
||||
let output = Command::new("dd")
|
||||
.arg("bs=1M")
|
||||
.arg(format!("count={}", size_gigs))
|
||||
.arg("if=/dev/zero")
|
||||
.arg(format!("of={}", tempfile))
|
||||
// test disk sequential read speeds w/ fio
|
||||
pub fn disk_read_seq_test(tempfile: &str, size: &u8) {
|
||||
// run the fio command
|
||||
let output = Command::new("fio")
|
||||
.arg("--name=TEST")
|
||||
.arg(format!("--filename={}", tempfile))
|
||||
.arg("--rw=read")
|
||||
.arg("--size=2g")
|
||||
.arg(format!("--io_size={}g", size))
|
||||
.arg("--blocksize=1024k")
|
||||
.arg("--ioengine=libaio")
|
||||
.arg("--fsync=10000")
|
||||
.arg("--iodepth=32")
|
||||
.arg("--direct=1")
|
||||
.arg("--numjobs=1")
|
||||
.arg("--runtime=60")
|
||||
.arg("--group_reporting")
|
||||
.output()
|
||||
.expect("Failed to execute command");
|
||||
|
||||
// check that the command succeeded
|
||||
assert!(output.status.success());
|
||||
|
||||
// for whatever reason, `dd` output ends up in stderr
|
||||
println!("{}", String::from_utf8_lossy(&output.stderr));
|
||||
// print the test's output
|
||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||
}
|
||||
|
||||
// remove the test file
|
||||
match fs::remove_file(tempfile) {
|
||||
Ok(()) => println!("Cleaning up..."),
|
||||
Err(e) => println!("There was a problem during cleanup - {}", e),
|
||||
// test disk 4K random read speeds w/ fio
|
||||
pub fn disk_read_rand_test(tempfile: &str, size: &u8) {
|
||||
// run the fio command
|
||||
let output = Command::new("fio")
|
||||
.arg("--name=TEST")
|
||||
.arg(format!("--filename={}", tempfile))
|
||||
.arg("--rw=randread")
|
||||
.arg("--size=2g")
|
||||
.arg(format!("--io_size={}g", size))
|
||||
.arg("--blocksize=4k")
|
||||
.arg("--ioengine=libaio")
|
||||
.arg("--fsync=1")
|
||||
.arg("--iodepth=1")
|
||||
.arg("--direct=1")
|
||||
.arg("--numjobs=32")
|
||||
.arg("--runtime=60")
|
||||
.arg("--group_reporting")
|
||||
.output()
|
||||
.expect("Failed to execute command");
|
||||
|
||||
// check that the command succeeded
|
||||
assert!(output.status.success());
|
||||
|
||||
// print the test's output
|
||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||
}
|
||||
|
||||
// test sequential disk write speeds w/ fio
|
||||
pub fn disk_write_seq_test(tempfile: &str, size: &u8) {
|
||||
// run the fio command
|
||||
let output = Command::new("fio")
|
||||
.arg("--name=TEST")
|
||||
.arg(format!("--filename={}", tempfile))
|
||||
.arg("--rw=write")
|
||||
.arg("--size=2g")
|
||||
.arg(format!("--io_size={}g", size))
|
||||
.arg("--blocksize=1024k")
|
||||
.arg("--ioengine=libaio")
|
||||
.arg("--fsync=10000")
|
||||
.arg("--iodepth=32")
|
||||
.arg("--direct=1")
|
||||
.arg("--numjobs=1")
|
||||
.arg("--runtime=60")
|
||||
.arg("--group_reporting")
|
||||
.output()
|
||||
.expect("Failed to execute command");
|
||||
|
||||
// check that the command succeeded
|
||||
assert!(output.status.success());
|
||||
|
||||
// print the test's output
|
||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||
}
|
||||
|
||||
// test random 4K disk write speeds w/ fio
|
||||
pub fn disk_write_rand_test(tempfile: &str, size: &u8) {
|
||||
// run the fio command
|
||||
let output = Command::new("fio")
|
||||
.arg("--name=TEST")
|
||||
.arg(format!("--filename={}", tempfile))
|
||||
.arg("--rw=randrw")
|
||||
.arg("--size=2g")
|
||||
.arg(format!("--io_size={}g", size))
|
||||
.arg("--blocksize=4k")
|
||||
.arg("--ioengine=libaio")
|
||||
.arg("--fsync=1")
|
||||
.arg("--iodepth=1")
|
||||
.arg("--direct=1")
|
||||
.arg("--numjobs=32")
|
||||
.arg("--runtime=60")
|
||||
.arg("--group_reporting")
|
||||
.output()
|
||||
.expect("Failed to execute command");
|
||||
|
||||
// check that the command succeeded
|
||||
assert!(output.status.success());
|
||||
|
||||
// print the test's output
|
||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||
}
|
||||
|
Reference in New Issue
Block a user