diff --git a/Cargo.lock b/Cargo.lock index fe0440d73..3da5e17fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,6 +89,14 @@ dependencies = [ "generic-array 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bstr" version = "0.2.15" @@ -504,6 +512,14 @@ dependencies = [ "generic-array 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dunce" version = "1.0.1" @@ -563,6 +579,15 @@ dependencies = [ "typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "getopts" version = "0.2.21" @@ -581,6 +606,16 @@ dependencies = [ "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.10.2+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "glob" version = "0.2.11" @@ -609,6 +644,11 @@ name = "hex" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "hex-literal" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "hostname" version = "0.3.1" @@ -703,6 +743,16 @@ name = "maybe-uninit" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "md-5" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "md5" version = "0.3.8" @@ -818,6 +868,11 @@ name = "oorandom" version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "paste" version = "0.1.18" @@ -946,6 +1001,17 @@ dependencies = [ "rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -955,6 +1021,15 @@ dependencies = [ "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ppv-lite86 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -976,6 +1051,14 @@ dependencies = [ "getrandom 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -984,6 +1067,14 @@ dependencies = [ "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_pcg" version = "0.2.1" @@ -1502,6 +1593,9 @@ dependencies = [ name = "uu_dd" version = "0.0.4" dependencies = [ + "hex-literal 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "md-5 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "uucore 0.0.7", "uucore_procs 0.0.5", ] @@ -2359,6 +2453,11 @@ name = "vec_map" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "void" version = "1.0.2" @@ -2379,6 +2478,11 @@ name = "wasi" version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "wasm-bindgen" version = "0.2.71" @@ -2503,6 +2607,7 @@ dependencies = [ "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum block-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1339a1042f5d9f295737ad4d9a6ab6bf81c84a933dba110b9200cd6d1448b814" +"checksum block-buffer 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" "checksum bstr 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" "checksum bumpalo 3.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" @@ -2535,6 +2640,7 @@ dependencies = [ "checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" "checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a" +"checksum digest 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" "checksum dunce 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b2641c4a7c0c4101df53ea572bffdc561c146f6c2eb09e4df02bc4811e3feeb4" "checksum either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" @@ -2543,14 +2649,17 @@ dependencies = [ "checksum fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" "checksum fs_extra 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" "checksum generic-array 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2297fb0e3ea512e380da24b52dca3924028f59df5e3a17a18f81d8349ca7ebe" "checksum getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" "checksum getrandom 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +"checksum getrandom 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum half 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" "checksum hermit-abi 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" "checksum hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" +"checksum hex-literal 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5af1f635ef1bc545d78392b136bfe1c9809e029023c84a3638a864a10b8819c8" "checksum hostname 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" "checksum if_rust_version 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46dbcb333e86939721589d25a3557e180b52778cb33c7fdfe9e0158ff790d5ec" "checksum ioctl-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e2c4b26352496eaaa8ca7cfa9bd99e93419d3f7983dc6e99c2a35fe9e33504a" @@ -2565,6 +2674,7 @@ dependencies = [ "checksum log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" "checksum match_cfg 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" +"checksum md-5 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15" "checksum md5 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "79c56d6a0b07f9e19282511c83fc5b086364cbae4ba8c7d5f190c3d9b0425a48" "checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" "checksum memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" @@ -2580,6 +2690,7 @@ dependencies = [ "checksum onig 4.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8518fcb2b1b8c2f45f0ad499df4fda6087fc3475ca69a185c173b8315d2fb383" "checksum onig_sys 69.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388410bf5fa341f10e58e6db3975f4bea1ac30247dd79d37a9e5ced3cb4cc3b0" "checksum oorandom 11.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +"checksum opaque-debug 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" "checksum paste 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" "checksum paste-impl 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" "checksum pkg-config 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" @@ -2596,11 +2707,15 @@ dependencies = [ "checksum quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" "checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +"checksum rand 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" "checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +"checksum rand_chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +"checksum rand_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +"checksum rand_hc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" "checksum rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" "checksum rayon 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" "checksum rayon-core 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" @@ -2648,8 +2763,10 @@ dependencies = [ "checksum unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aa2700417c405c38f5e6902d699345241c28c0b7ade4abaad71e35a87eb1564" "checksum users 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa4227e95324a443c9fcb06e03d4d85e91aabe9a5a02aa818688b6918b6af486" "checksum vec_map 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +"checksum version_check 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +"checksum wasi 0.10.2+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" "checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" "checksum wasm-bindgen 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1280240b7c461d6a0071313e08f34a60b0365f14260362e5a2b17d1d31aa7" "checksum wasm-bindgen-backend 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "5b7d8b6942b8bb3a9b0e73fc79b98095a27de6fa247615e59d096754a3bc2aa8" diff --git a/src/uu/dd/Cargo.toml b/src/uu/dd/Cargo.toml index dac27d833..f91f0c045 100644 --- a/src/uu/dd/Cargo.toml +++ b/src/uu/dd/Cargo.toml @@ -21,6 +21,7 @@ uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_p [dev-dependencies] md-5 = "0.9" hex-literal = "0.3" +rand = "0.8" [[bin]] name = "dd" diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index ed9e0508f..faed1a9d8 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -21,20 +21,113 @@ use std::thread; const NAME: &str = "dd"; const SUMMARY: &str = "Copies, and optionally converts, file system resources."; -const LONG_HELP: &str = " -TODO: This is where the long help string for dd goes! -"; +const LONG_HELP: &str = "TODO: This is where the long help string for dd goes!"; const RTN_SUCCESS: i32 = 0; const RTN_FAILURE: i32 = 1; // Conversion tables are just lookup tables. -// eg. -// The ASCII->EBDIC table stores the EBDIC code at the index +// eg. The ASCII->EBCDIC table stores the EBCDIC code at the index // obtained by treating the ASCII representation as a number. -// This idea is from the original GNU implementation. -type ConversionTable = [u8; u8::MAX as usize]; +type ConversionTable = [u8; 256]; +const ascii_to_ebcdic: ConversionTable = [ + 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, + 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, + 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, + 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x9a, 0x6d, + 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0x5f, 0x07, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b, + 0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xe1, + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, + 0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x6a, 0x9b, 0x9c, 0x9d, 0x9e, + 0x9f, 0xa0, 0xaa, 0xab, 0xac, 0x4a, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xa1, 0xbe, 0xbf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb, + 0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, +]; + +const ascii_to_ibm: ConversionTable = [ + 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, + 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, + 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, + 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, + 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b, + 0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xe1, + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, + 0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, + 0x9f, 0xa0, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb, + 0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, +]; + +const ebcdic_to_ascii: ConversionTable = [ + 0x00, 0x01, 0x02, 0x03, 0x9c, 0x09, 0x86, 0x7f, 0x97, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x9d, 0x85, 0x08, 0x87, 0x18, 0x19, 0x92, 0x8f, 0x1c, 0x1d, 0x1e, 0x1f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x0a, 0x17, 0x1b, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, + 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, + 0x20, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xd5, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, + 0x26, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x7e, + 0x2d, 0x2f, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xcb, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, + 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, + 0xc3, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, + 0xca, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x5e, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, + 0xd1, 0xe5, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0xd2, 0xd3, 0xd4, 0x5b, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0x5d, 0xe6, 0xe7, + 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, + 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, + 0x5c, 0x9f, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, +]; + +const lcase_to_ucase: ConversionTable = [ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, + +]; + +const ucase_to_lcase: ConversionTable = [ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, +]; + +// ----- Datatypes ----- enum SrcStat { Read(usize), @@ -45,6 +138,7 @@ struct Input { src: R, ibs: usize, + output_progress: bool, } impl Read for Input @@ -115,6 +209,7 @@ impl Write for Output } } +// ----- Implementation ----- fn gen_prog_updater(rx: mpsc::Receiver) -> impl Fn() -> () { move || { // LAAAAMBDA! @@ -140,8 +235,17 @@ fn gen_prog_updater(rx: mpsc::Receiver) -> impl Fn() -> () fn dd(mut i: Input, mut o: Output) -> Result<(usize, usize), Box> { - let (prog_tx, prog_rx) = mpsc::channel(); - thread::spawn(gen_prog_updater(prog_rx)); + let prog_tx = if i.output_progress { + let (prog_tx, prog_rx) = mpsc::channel(); + thread::spawn(gen_prog_updater(prog_rx)); + + Some(prog_tx) + } + else + { + None + }; + let mut bytes_in = 0; let mut bytes_out = 0; @@ -165,7 +269,10 @@ fn dd(mut i: Input, mut o: Output) -> Result<(usize, us bytes_out += w_len; - prog_tx.send(bytes_out)?; + if let Some(prog_tx) = &prog_tx + { + prog_tx.send(bytes_out)?; + } } Ok((bytes_in, bytes_out)) @@ -190,6 +297,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 let i = Input { src: in_f, ibs, + output_progress: false, }; let o = Output { dst: out_f, @@ -221,18 +329,18 @@ mod test_dd_internal use md5::{ Md5, Digest, }; use hex_literal::hex; - macro_rules! make_test ( + macro_rules! make_hash_test ( ( $test_id:ident, $test_name:expr, $src:expr, $exp:expr ) => { #[test] fn $test_id() { - // let test_name = "6ae59e64850377ee5470c854761551ea-ones"; let tmp_fname = format!("./test-resources/FAILED-{}.test", $test_name); let i = Input { src: $src, ibs: 256, + output_progress: false, }; let o = Output { @@ -258,44 +366,260 @@ mod test_dd_internal assert_eq!(hex!($exp), res[..]); + fs::remove_file(&tmp_fname).unwrap(); + } + }; + ( $test_id:ident, $test_name:expr, $i:expr, $o:expr, $exp:expr ) => + { + #[test] + fn $test_id() + { + let tmp_fname = format!("./test-resources/FAILED-{}.test", $test_name); + + let o = Output { + dst: File::create(&tmp_fname).unwrap(), + obs: $o.obs, + conv_table: $o.conv_table, + }; + + dd($i,o).unwrap(); + + let res = { + let res = File::open(&tmp_fname).unwrap(); + let res = BufReader::new(res); + + let mut h = Md5::new(); + for b in res.bytes() + { + h.update([b.unwrap()]); + } + + h.finalize() + }; + + assert_eq!(hex!($exp), res[..]); + fs::remove_file(&tmp_fname).unwrap(); } }; ); - make_test!( + macro_rules! make_spec_test ( + ( $test_id:ident, $test_name:expr, $i:expr, $o:expr, $spec:expr ) => + { + #[test] + fn $test_id() + { + let tmp_fname = format!("./test-resources/FAILED-{}.test", $test_name); + + let o = Output { + dst: File::create(&tmp_fname).unwrap(), + obs: $o.obs, + conv_table: $o.conv_table, + }; + + dd($i,o).unwrap(); + + let res = File::open(&tmp_fname).unwrap(); + let res = BufReader::new(res); + + let spec = BufReader::new($spec); + + for (b_res, b_spec) in res.bytes().zip(spec.bytes()) + { + assert_eq!(b_res.unwrap(), + b_spec.unwrap()); + } + + fs::remove_file(&tmp_fname).unwrap(); + } + }; + ); + + make_hash_test!( empty_file_test, "stdio-empty-file", io::empty(), "d41d8cd98f00b204e9800998ecf8427e" ); - make_test!( + make_hash_test!( zeros_4k_test, "zeros-4k", - File::open("./test-resources/620f0b67a91f7f74151bc5be745b7110-zeros.test").unwrap(), + File::open("./test-resources/zeros-620f0b67a91f7f74151bc5be745b7110.test").unwrap(), "620f0b67a91f7f74151bc5be745b7110" ); - make_test!( + make_hash_test!( ones_4k_test, "ones-4k", - File::open("./test-resources/6ae59e64850377ee5470c854761551ea-ones.test").unwrap(), + File::open("./test-resources/ones-6ae59e64850377ee5470c854761551ea.test").unwrap(), "6ae59e64850377ee5470c854761551ea" ); - make_test!( + make_hash_test!( deadbeef_32k_test, - "deadbeef_32k", - File::open("./test-resources/18d99661a1de1fc9af21b0ec2cd67ba3-deadbeef.test").unwrap(), + "deadbeef-32k", + File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap(), "18d99661a1de1fc9af21b0ec2cd67ba3" ); - make_test!( + make_hash_test!( random_73k_test, - "random_73k", - File::open("./test-resources/5828891cb1230748e146f34223bbd3b5-random.test").unwrap(), + "random-73k", + File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap(), "5828891cb1230748e146f34223bbd3b5" ); + make_spec_test!( + atoe_conv_spec_test, + "atoe-conv-spec-test", + Input { + src: File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(), + ibs: 512, + output_progress: false, + }, + Output { + dst: Vec::new(), // unused! + obs: 512, + conv_table: Some(ascii_to_ebcdic), + }, + File::open("./test-resources/gnudd-conv-atoe-seq-byte-values.spec").unwrap() + ); + + make_spec_test!( + etoa_conv_spec_test, + "etoa-conv-spec-test", + Input { + src: File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(), + ibs: 512, + output_progress: false, + }, + Output { + dst: Vec::new(), // unused! + obs: 512, + conv_table: Some(ebcdic_to_ascii), + }, + File::open("./test-resources/gnudd-conv-etoa-seq-byte-values.spec").unwrap() + ); + + make_spec_test!( + atoibm_conv_spec_test, + "atoibm-conv-spec-test", + Input { + src: File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(), + ibs: 512, + output_progress: false, + }, + Output { + dst: Vec::new(), // unused! + obs: 512, + conv_table: Some(ascii_to_ibm), + }, + File::open("./test-resources/gnudd-conv-atoibm-seq-byte-values.spec").unwrap() + ); + + make_spec_test!( + lcase_ascii_to_ucase_ascii, + "lcase_ascii_to_ucase_ascii", + Input { + src: File::open("./test-resources/lcase-ascii.test").unwrap(), + ibs: 512, + output_progress: false, + }, + Output { + dst: Vec::new(), // unused! + obs: 512, + conv_table: Some(lcase_to_ucase), + }, + File::open("./test-resources/ucase-ascii.test").unwrap() + ); + + make_spec_test!( + ucase_ascii_to_lcase_ascii, + "ucase_ascii_to_lcase_ascii", + Input { + src: File::open("./test-resources/ucase-ascii.test").unwrap(), + ibs: 512, + output_progress: false, + }, + Output { + dst: Vec::new(), // unused! + obs: 512, + conv_table: Some(ucase_to_lcase), + }, + File::open("./test-resources/lcase-ascii.test").unwrap() + ); + + #[test] + fn all_valid_ascii_ebcdic_ascii_roundtrip_conv_test() + { + // ASCII->EBCDIC + let test_name = "all-valid-ascii-to-ebcdic"; + let tmp_fname_ae = format!("./test-resources/FAILED-{}.test", test_name); + + let i = Input { + src: File::open("./test-resources/all-valid-ascii-chars-37eff01866ba3f538421b30b7cbefcac.test").unwrap(), + ibs: 256, + output_progress: false, + }; + + let o = Output { + dst: File::create(&tmp_fname_ae).unwrap(), + obs: 1024, + conv_table: Some(ascii_to_ebcdic), + }; + + dd(i,o).unwrap(); + + // EBCDIC->ASCII + let test_name = "all-valid-ebcdic-to-ascii"; + let tmp_fname_ea = format!("./test-resources/FAILED-{}.test", test_name); + + let i = Input { + src: File::open(&tmp_fname_ae).unwrap(), + ibs: 256, + output_progress: false, + }; + + let o = Output { + dst: File::create(&tmp_fname_ea).unwrap(), + obs: 1024, + conv_table: Some(ebcdic_to_ascii), + }; + + dd(i,o).unwrap(); + + let res = { + let res = File::open(&tmp_fname_ea).unwrap(); + let res = BufReader::new(res); + + let mut h = Md5::new(); + for b in res.bytes() + { + h.update([b.unwrap()]); + } + + h.finalize() + }; + + assert_eq!(hex!("37eff01866ba3f538421b30b7cbefcac"), res[..]); + + fs::remove_file(&tmp_fname_ae).unwrap(); + fs::remove_file(&tmp_fname_ea).unwrap(); + } + + //use rand::prelude::*; + //#[test] + //fn make_test_data() + //{ + // let mut f = File::create("./test-resources/random-walk-through-the-ascii-ranged-forest.test").unwrap(); + // // let mut rng = rand::thread_rng(); + + // for _ in 0..65536 { + // f.write(&[c]).unwrap(); + // } + //} + + } diff --git a/src/uu/dd/test-resources/all-valid-ascii-chars-37eff01866ba3f538421b30b7cbefcac.test b/src/uu/dd/test-resources/all-valid-ascii-chars-37eff01866ba3f538421b30b7cbefcac.test new file mode 100644 index 000000000..7e1cc9de8 Binary files /dev/null and b/src/uu/dd/test-resources/all-valid-ascii-chars-37eff01866ba3f538421b30b7cbefcac.test differ diff --git a/src/uu/dd/test-resources/18d99661a1de1fc9af21b0ec2cd67ba3-deadbeef.test b/src/uu/dd/test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test similarity index 100% rename from src/uu/dd/test-resources/18d99661a1de1fc9af21b0ec2cd67ba3-deadbeef.test rename to src/uu/dd/test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test diff --git a/src/uu/dd/test-resources/gnudd-conv-atoe-seq-byte-values.spec b/src/uu/dd/test-resources/gnudd-conv-atoe-seq-byte-values.spec new file mode 100644 index 000000000..8701c67fd Binary files /dev/null and b/src/uu/dd/test-resources/gnudd-conv-atoe-seq-byte-values.spec differ diff --git a/src/uu/dd/test-resources/gnudd-conv-atoibm-seq-byte-values.spec b/src/uu/dd/test-resources/gnudd-conv-atoibm-seq-byte-values.spec new file mode 100644 index 000000000..3835d57cf Binary files /dev/null and b/src/uu/dd/test-resources/gnudd-conv-atoibm-seq-byte-values.spec differ diff --git a/src/uu/dd/test-resources/gnudd-conv-etoa-seq-byte-values.spec b/src/uu/dd/test-resources/gnudd-conv-etoa-seq-byte-values.spec new file mode 100644 index 000000000..433b1f600 Binary files /dev/null and b/src/uu/dd/test-resources/gnudd-conv-etoa-seq-byte-values.spec differ diff --git a/src/uu/dd/test-resources/gnudd-conv-ltou-seq-byte-values.spec b/src/uu/dd/test-resources/gnudd-conv-ltou-seq-byte-values.spec new file mode 100644 index 000000000..5aacec0cd Binary files /dev/null and b/src/uu/dd/test-resources/gnudd-conv-ltou-seq-byte-values.spec differ diff --git a/src/uu/dd/test-resources/gnudd-conv-utol-seq-byte-values.spec b/src/uu/dd/test-resources/gnudd-conv-utol-seq-byte-values.spec new file mode 100644 index 000000000..d205368d5 Binary files /dev/null and b/src/uu/dd/test-resources/gnudd-conv-utol-seq-byte-values.spec differ diff --git a/src/uu/dd/test-resources/lcase-ascii.test b/src/uu/dd/test-resources/lcase-ascii.test new file mode 100644 index 000000000..61231db2b Binary files /dev/null and b/src/uu/dd/test-resources/lcase-ascii.test differ diff --git a/src/uu/dd/test-resources/6ae59e64850377ee5470c854761551ea-ones.test b/src/uu/dd/test-resources/ones-6ae59e64850377ee5470c854761551ea.test similarity index 100% rename from src/uu/dd/test-resources/6ae59e64850377ee5470c854761551ea-ones.test rename to src/uu/dd/test-resources/ones-6ae59e64850377ee5470c854761551ea.test diff --git a/src/uu/dd/test-resources/5828891cb1230748e146f34223bbd3b5-random.test b/src/uu/dd/test-resources/random-5828891cb1230748e146f34223bbd3b5.test similarity index 100% rename from src/uu/dd/test-resources/5828891cb1230748e146f34223bbd3b5-random.test rename to src/uu/dd/test-resources/random-5828891cb1230748e146f34223bbd3b5.test diff --git a/src/uu/dd/test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test b/src/uu/dd/test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test new file mode 100644 index 000000000..be75933c8 Binary files /dev/null and b/src/uu/dd/test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test differ diff --git a/src/uu/dd/test-resources/seq-byte-values-swapped.test b/src/uu/dd/test-resources/seq-byte-values-swapped.test new file mode 100644 index 000000000..c86626638 Binary files /dev/null and b/src/uu/dd/test-resources/seq-byte-values-swapped.test differ diff --git a/src/uu/dd/test-resources/ucase-ascii.test b/src/uu/dd/test-resources/ucase-ascii.test new file mode 100644 index 000000000..526f596cc Binary files /dev/null and b/src/uu/dd/test-resources/ucase-ascii.test differ diff --git a/src/uu/dd/test-resources/620f0b67a91f7f74151bc5be745b7110-zeros.test b/src/uu/dd/test-resources/zeros-620f0b67a91f7f74151bc5be745b7110.test similarity index 100% rename from src/uu/dd/test-resources/620f0b67a91f7f74151bc5be745b7110-zeros.test rename to src/uu/dd/test-resources/zeros-620f0b67a91f7f74151bc5be745b7110.test