Testing a small http-client on Linux using no_std & embedded reqwless.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add xtask validation commands and streamline README validation guidance

rektide 1d6100b8 ce4a3500

+318
+133
Cargo.lock
··· 38 38 ] 39 39 40 40 [[package]] 41 + name = "anstream" 42 + version = "1.0.0" 43 + source = "registry+https://github.com/rust-lang/crates.io-index" 44 + checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" 45 + dependencies = [ 46 + "anstyle", 47 + "anstyle-parse", 48 + "anstyle-query", 49 + "anstyle-wincon", 50 + "colorchoice", 51 + "is_terminal_polyfill", 52 + "utf8parse", 53 + ] 54 + 55 + [[package]] 56 + name = "anstyle" 57 + version = "1.0.14" 58 + source = "registry+https://github.com/rust-lang/crates.io-index" 59 + checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" 60 + 61 + [[package]] 62 + name = "anstyle-parse" 63 + version = "1.0.0" 64 + source = "registry+https://github.com/rust-lang/crates.io-index" 65 + checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" 66 + dependencies = [ 67 + "utf8parse", 68 + ] 69 + 70 + [[package]] 71 + name = "anstyle-query" 72 + version = "1.1.5" 73 + source = "registry+https://github.com/rust-lang/crates.io-index" 74 + checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" 75 + dependencies = [ 76 + "windows-sys", 77 + ] 78 + 79 + [[package]] 80 + name = "anstyle-wincon" 81 + version = "3.0.11" 82 + source = "registry+https://github.com/rust-lang/crates.io-index" 83 + checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" 84 + dependencies = [ 85 + "anstyle", 86 + "once_cell_polyfill", 87 + "windows-sys", 88 + ] 89 + 90 + [[package]] 41 91 name = "as-slice" 42 92 version = "0.1.5" 43 93 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 109 159 ] 110 160 111 161 [[package]] 162 + name = "clap" 163 + version = "4.6.0" 164 + source = "registry+https://github.com/rust-lang/crates.io-index" 165 + checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" 166 + dependencies = [ 167 + "clap_builder", 168 + "clap_derive", 169 + ] 170 + 171 + [[package]] 172 + name = "clap_builder" 173 + version = "4.6.0" 174 + source = "registry+https://github.com/rust-lang/crates.io-index" 175 + checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" 176 + dependencies = [ 177 + "anstream", 178 + "anstyle", 179 + "clap_lex", 180 + "strsim", 181 + ] 182 + 183 + [[package]] 184 + name = "clap_derive" 185 + version = "4.6.0" 186 + source = "registry+https://github.com/rust-lang/crates.io-index" 187 + checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a" 188 + dependencies = [ 189 + "heck", 190 + "proc-macro2", 191 + "quote", 192 + "syn", 193 + ] 194 + 195 + [[package]] 196 + name = "clap_lex" 197 + version = "1.1.0" 198 + source = "registry+https://github.com/rust-lang/crates.io-index" 199 + checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" 200 + 201 + [[package]] 202 + name = "colorchoice" 203 + version = "1.0.5" 204 + source = "registry+https://github.com/rust-lang/crates.io-index" 205 + checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" 206 + 207 + [[package]] 112 208 name = "const-oid" 113 209 version = "0.9.6" 114 210 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 472 568 ] 473 569 474 570 [[package]] 571 + name = "heck" 572 + version = "0.5.0" 573 + source = "registry+https://github.com/rust-lang/crates.io-index" 574 + checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 575 + 576 + [[package]] 475 577 name = "hex" 476 578 version = "0.4.3" 477 579 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 511 613 ] 512 614 513 615 [[package]] 616 + name = "is_terminal_polyfill" 617 + version = "1.70.2" 618 + source = "registry+https://github.com/rust-lang/crates.io-index" 619 + checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" 620 + 621 + [[package]] 514 622 name = "libc" 515 623 version = "0.2.183" 516 624 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 539 647 version = "0.2.0" 540 648 source = "registry+https://github.com/rust-lang/crates.io-index" 541 649 checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" 650 + 651 + [[package]] 652 + name = "once_cell_polyfill" 653 + version = "1.70.2" 654 + source = "registry+https://github.com/rust-lang/crates.io-index" 655 + checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" 542 656 543 657 [[package]] 544 658 name = "opaque-debug" ··· 779 893 checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" 780 894 781 895 [[package]] 896 + name = "strsim" 897 + version = "0.11.1" 898 + source = "registry+https://github.com/rust-lang/crates.io-index" 899 + checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" 900 + 901 + [[package]] 782 902 name = "subtle" 783 903 version = "2.6.1" 784 904 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 836 956 ] 837 957 838 958 [[package]] 959 + name = "utf8parse" 960 + version = "0.2.2" 961 + source = "registry+https://github.com/rust-lang/crates.io-index" 962 + checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" 963 + 964 + [[package]] 839 965 name = "version_check" 840 966 version = "0.9.5" 841 967 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 854 980 checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" 855 981 dependencies = [ 856 982 "windows-link", 983 + ] 984 + 985 + [[package]] 986 + name = "xtask" 987 + version = "0.1.0" 988 + dependencies = [ 989 + "clap", 857 990 ] 858 991 859 992 [[package]]
+4
Cargo.toml
··· 3 3 version = "0.1.0" 4 4 edition = "2024" 5 5 6 + [workspace] 7 + members = ["xtask"] 8 + resolver = "3" 9 + 6 10 [features] 7 11 default = ["backend-posix-libc", "dns-getaddrinfo"] 8 12 backend-posix-libc = []
+10
README.md
··· 39 39 # Minimal DNS mode (literal IP hosts only) 40 40 cargo run --no-default-features --features backend-posix-libc,dns-ip-only -- http://93.184.216.34 41 41 ``` 42 + 43 + ## Validation 44 + 45 + Use the composite `xtask` validation flow for reproducible checks. 46 + 47 + ```bash 48 + cargo run -p xtask -- validate 49 + ``` 50 + 51 + The `xtask` subcommands are self-documented in CLI help and can be explored as needed.
+7
xtask/Cargo.toml
··· 1 + [package] 2 + name = "xtask" 3 + version = "0.1.0" 4 + edition = "2024" 5 + 6 + [dependencies] 7 + clap = { version = "4.5", features = ["derive"] }
+164
xtask/src/main.rs
··· 1 + // pattern: Imperative Shell 2 + 3 + use clap::{Parser, Subcommand}; 4 + use std::path::Path; 5 + use std::process::Command; 6 + 7 + const RUSTIX_GUARD_NEEDLE: &str = "backend-rustix is not implemented yet; use backend-posix-libc"; 8 + const DNS_IP_ONLY_REJECT_NEEDLE: &str = "dns-ip-only mode accepts literal IP hosts only"; 9 + 10 + #[derive(Parser)] 11 + #[command(name = "xtask", about = "validation tasks for reqwless-linux")] 12 + struct Cli { 13 + #[command(subcommand)] 14 + command: Task, 15 + } 16 + 17 + #[derive(Clone, Copy, Subcommand)] 18 + enum Task { 19 + /// Check default feature set builds. 20 + Check, 21 + /// Check default feature set with HTTPS enabled. 22 + CheckHttps, 23 + /// Check no-default build with posix backend and IP-only DNS mode. 24 + CheckIpOnly, 25 + /// Run downloader against example.com in default mode. 26 + RunHttpExample, 27 + /// Run IP-only mode against hostname and confirm rejection message. 28 + RunIpOnlyReject, 29 + /// Check rustix backend guard emits expected compile-time error. 30 + CheckRustixGuard, 31 + /// Run all build-time validations. 32 + ValidateBuild, 33 + /// Run runtime behavior validations. 34 + ValidateRuntime, 35 + /// Run complete validation suite (build + runtime + guarded failure checks). 36 + Validate, 37 + } 38 + 39 + fn main() { 40 + if let Err(error) = run() { 41 + eprintln!("{error}"); 42 + std::process::exit(1); 43 + } 44 + } 45 + 46 + fn run() -> Result<(), String> { 47 + let cli = Cli::parse(); 48 + run_task(cli.command) 49 + } 50 + 51 + fn run_task(task: Task) -> Result<(), String> { 52 + match task { 53 + Task::Check => run_success("cargo check", &["check"]), 54 + Task::CheckHttps => run_success("cargo check --features https", &["check", "--features", "https"]), 55 + Task::CheckIpOnly => run_success( 56 + "cargo check --no-default-features --features backend-posix-libc,dns-ip-only", 57 + &[ 58 + "check", 59 + "--no-default-features", 60 + "--features", 61 + "backend-posix-libc,dns-ip-only", 62 + ], 63 + ), 64 + Task::RunHttpExample => run_success("cargo run -- http://example.com", &["run", "--", "http://example.com"]), 65 + Task::RunIpOnlyReject => run_expected_failure( 66 + "cargo run --no-default-features --features backend-posix-libc,dns-ip-only -- http://example.com", 67 + &[ 68 + "run", 69 + "--no-default-features", 70 + "--features", 71 + "backend-posix-libc,dns-ip-only", 72 + "--", 73 + "http://example.com", 74 + ], 75 + DNS_IP_ONLY_REJECT_NEEDLE, 76 + ), 77 + Task::CheckRustixGuard => run_expected_failure( 78 + "cargo check --no-default-features --features backend-rustix,dns-getaddrinfo", 79 + &[ 80 + "check", 81 + "--no-default-features", 82 + "--features", 83 + "backend-rustix,dns-getaddrinfo", 84 + ], 85 + RUSTIX_GUARD_NEEDLE, 86 + ), 87 + Task::ValidateBuild => run_sequence(&[ 88 + Task::Check, 89 + Task::CheckHttps, 90 + Task::CheckIpOnly, 91 + Task::CheckRustixGuard, 92 + ]), 93 + Task::ValidateRuntime => run_sequence(&[Task::RunHttpExample, Task::RunIpOnlyReject]), 94 + Task::Validate => run_sequence(&[ 95 + Task::Check, 96 + Task::CheckHttps, 97 + Task::CheckIpOnly, 98 + Task::RunHttpExample, 99 + Task::RunIpOnlyReject, 100 + Task::CheckRustixGuard, 101 + ]), 102 + } 103 + } 104 + 105 + fn run_sequence(tasks: &[Task]) -> Result<(), String> { 106 + for task in tasks { 107 + run_task(*task)?; 108 + } 109 + Ok(()) 110 + } 111 + 112 + fn run_success(display: &str, cargo_args: &[&str]) -> Result<(), String> { 113 + eprintln!("==> {display}"); 114 + let output = run_cargo(cargo_args)?; 115 + if output.status.success() { 116 + return Ok(()); 117 + } 118 + Err(format_command_failure( 119 + display, 120 + &output.stdout, 121 + &output.stderr, 122 + )) 123 + } 124 + 125 + fn run_expected_failure(display: &str, cargo_args: &[&str], needle: &str) -> Result<(), String> { 126 + eprintln!("==> {display}"); 127 + let output = run_cargo(cargo_args)?; 128 + if output.status.success() { 129 + return Err(format!("expected failure but command succeeded: {display}")); 130 + } 131 + 132 + let stdout = String::from_utf8_lossy(&output.stdout); 133 + let stderr = String::from_utf8_lossy(&output.stderr); 134 + if stdout.contains(needle) || stderr.contains(needle) { 135 + return Ok(()); 136 + } 137 + 138 + Err(format!( 139 + "command failed as expected but missing required message: {needle}\n{}", 140 + format_command_failure(display, &output.stdout, &output.stderr) 141 + )) 142 + } 143 + 144 + fn run_cargo(cargo_args: &[&str]) -> Result<std::process::Output, String> { 145 + Command::new("cargo") 146 + .current_dir(workspace_root()) 147 + .args(cargo_args) 148 + .output() 149 + .map_err(|error| format!("failed to execute cargo: {error}")) 150 + } 151 + 152 + fn workspace_root() -> &'static Path { 153 + Path::new(env!("CARGO_MANIFEST_DIR")) 154 + .parent() 155 + .expect("xtask crate must live directly under workspace root") 156 + } 157 + 158 + fn format_command_failure(display: &str, stdout: &[u8], stderr: &[u8]) -> String { 159 + format!( 160 + "command failed: {display}\nstdout:\n{}\nstderr:\n{}", 161 + String::from_utf8_lossy(stdout), 162 + String::from_utf8_lossy(stderr) 163 + ) 164 + }