Compare commits
6 Commits
b1255c451e
...
v0.1.0
Author | SHA1 | Date | |
---|---|---|---|
784f64ca16 | |||
1ff6b671eb | |||
33e540add4 | |||
a315e2662c | |||
9000924590 | |||
a9b1ffa614 |
26
.woodpecker.yml
Normal file
26
.woodpecker.yml
Normal file
@ -0,0 +1,26 @@
|
||||
pipeline:
|
||||
test_build:
|
||||
image: rust:1.62
|
||||
commands:
|
||||
- cargo build
|
||||
|
||||
build_release:
|
||||
image: rust:1.62
|
||||
commands:
|
||||
- cargo build --release
|
||||
- "mv target/release/nettest target/release/nettest-${CI_COMMIT_TAG}-linux-x86_64"
|
||||
- "mv target/release/hdtest target/release/hdtest-${CI_COMMIT_TAG}-linux-x86_64"
|
||||
when:
|
||||
event: tag
|
||||
|
||||
gitea_release:
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_api_key
|
||||
base_url: https://git.metaunix.net
|
||||
files:
|
||||
- "target/release/*${CI_COMMIT_TAG}-linux-x86_64"
|
||||
title: "${CI_COMMIT_TAG}"
|
||||
when:
|
||||
event: tag
|
@ -14,4 +14,5 @@ path = "src/nettest.rs"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.19"
|
||||
clap = { version = "3.1.2", features = ["derive"] }
|
||||
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
||||
Copyright (c) <year> <owner>
|
||||
Copyright (c) 2022 Bit Goblin
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
|
18
README.md
18
README.md
@ -1,3 +1,17 @@
|
||||
# test-scripts
|
||||
# Bit Goblin Hardware Tests
|
||||
|
||||
Scripts used for testing hardware in Bit Goblin's videos
|
||||
Scripts used for testing hardware in Bit Goblin's videos.
|
||||
|
||||
## Download & Installation
|
||||
|
||||
Check out the [Releases page](https://git.metaunix.net/BitGoblin/hardware-tests/releases) to find the latest compiled binaries.
|
||||
|
||||
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.
|
||||
|
||||
## 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/`.
|
||||
|
||||
## License
|
||||
|
||||
The Bit Goblin hardware test suite is available via the BSD 2-Clause license, so feel free to hack away at it!
|
||||
|
3
bin/docker-build.sh
Executable file
3
bin/docker-build.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
docker run --rm --user "$(id -u)":"$(id -g)" -v "$PWD":/usr/src/hardware-tests -w /usr/src/hardware-tests rust:1.62 cargo build
|
@ -1,5 +1,6 @@
|
||||
use chrono::prelude::*;
|
||||
use clap::{Parser, Subcommand};
|
||||
use std::process;
|
||||
use std::{fs,process};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "Bit Goblin Network Tester", author, version, about = "Network testing app.", long_about = None)]
|
||||
@ -16,6 +17,14 @@ enum Commands {
|
||||
#[clap(default_value_t = String::from("8.8.8.8"))]
|
||||
host: String
|
||||
},
|
||||
|
||||
// bandwidth test subcommand
|
||||
Bandwidth {
|
||||
#[clap(default_value_t = String::from("https://www.bitgoblin.tech/hardware-tests/export-01.mp4"))]
|
||||
download: String,
|
||||
#[clap(default_value_t = String::from("./tempfile"))]
|
||||
output: String,
|
||||
},
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -23,7 +32,8 @@ fn main() {
|
||||
|
||||
// map subcommands back to the main command
|
||||
match &cli.command {
|
||||
Commands::Ping { host } => ping_host(host)
|
||||
Commands::Ping { host } => ping_host(host),
|
||||
Commands::Bandwidth { download, output } => bandwidth_test(download, output)
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,3 +54,25 @@ fn ping_host(host: &str) {
|
||||
// print out the ping results from stdout
|
||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||
}
|
||||
|
||||
// timed file copy test to guage bandwidth speeds
|
||||
fn bandwidth_test(download: &str, output: &str) {
|
||||
println!("Testing network bandwidth by downloading {}.", download);
|
||||
|
||||
// get start time so we can track how long it takes to complete
|
||||
let start_time = Utc::now();
|
||||
|
||||
// do the download
|
||||
|
||||
// get finish time
|
||||
let finish_time = Utc::now();
|
||||
// compute time to complete
|
||||
let comp_time = finish_time - start_time;
|
||||
println!("{}", comp_time.num_milliseconds());
|
||||
|
||||
// clean up the test file
|
||||
match fs::remove_file(output) {
|
||||
Ok(()) => println!("Cleaning up..."),
|
||||
Err(e) => println!("There was a problem during cleanup - {}", e),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user