Merge pull request #2474 from backwaterred/master

This commit is contained in:
Sylvestre Ledru
2021-08-04 22:48:54 +02:00
committed by GitHub
92 changed files with 5332 additions and 28 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
{ "name": "workspace", "path": "./cspell.dictionaries/workspace.wordlist.txt" }
],
// ignorePaths - a list of globs to specify which files are to be ignored
"ignorePaths": ["Cargo.lock", "target/**", "tests/**/fixtures/**"],
"ignorePaths": ["Cargo.lock", "target/**", "tests/**/fixtures/**", "src/uu/dd/test-resources/**"],
// ignoreWords - a list of words to be ignored (even if they are in the flagWords)
"ignoreWords": [],
// words - list of words to be always considered correct
+27
View File
@@ -12,6 +12,7 @@ colorizable
colorize
coprime
consts
conv
cyclomatic
dedup
deduplication
@@ -23,6 +24,7 @@ dev
devs
discoverability
duplicative
dsync
enqueue
errored
executable
@@ -30,7 +32,10 @@ executables
exponentiate
eval
falsey
fileio
flamegraph
fullblock
gibi
gibibytes
glob
globbing
@@ -39,8 +44,12 @@ hardlink
hardlinks
hasher
hashsums
infile
iflag
iflags
kibi
kibibytes
lcase
mebi
mebibytes
mergeable
@@ -49,8 +58,21 @@ microbenchmarks
microbenchmarking
multibyte
multicall
noatime
nocache
nocreat
noctty
noerror
nofollow
nolinks
nonblock
nonportable
nonprinting
notrunc
noxfer
ofile
oflag
oflags
peekable
performant
precompiled
@@ -70,9 +92,12 @@ semiprime
semiprimes
shortcode
shortcodes
siginfo
sigusr
subcommand
subexpression
submodule
sync
symlink
symlinks
syscall
@@ -80,12 +105,14 @@ syscalls
tokenize
toolchain
truthy
ucase
unbuffered
unescape
unintuitive
unprefixed
unportable
unsync
urand
whitespace
wordlist
wordlists
Generated
+46 -10
View File
@@ -167,6 +167,15 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
[[package]]
name = "byte-unit"
version = "4.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "063197e6eb4b775b64160dedde7a0986bb2836cce140e9492e9e96f28e18bcd8"
dependencies = [
"utf8-width",
]
[[package]]
name = "byteorder"
version = "1.4.3"
@@ -175,9 +184,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "cc"
version = "1.0.68"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2"
[[package]]
name = "cexpr"
@@ -310,6 +319,7 @@ dependencies = [
"uu_csplit",
"uu_cut",
"uu_date",
"uu_dd",
"uu_df",
"uu_dircolors",
"uu_dirname",
@@ -510,9 +520,9 @@ dependencies = [
[[package]]
name = "crossbeam-deque"
version = "0.8.0"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9"
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-epoch",
@@ -699,6 +709,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
[[package]]
name = "gcd"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c7cd301bf2ab11ae4e5bdfd79c221d97a25e46c089144a62ee9d09cb32d2b92"
[[package]]
name = "generic-array"
version = "0.8.4"
@@ -1269,9 +1285,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]]
name = "proc-macro2"
version = "1.0.27"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612"
dependencies = [
"unicode-xid 0.2.2",
]
@@ -1491,9 +1507,9 @@ dependencies = [
[[package]]
name = "reference-counted-singleton"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e03aec30be874d0786379a6ee483c653c58dd6863ad4ed873e697ed968f9358"
checksum = "ef445213a92fdddc4bc69d9111156d20ffd50704a86ad82b372aab701a0d3a9a"
[[package]]
name = "regex"
@@ -1721,9 +1737,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.73"
version = "1.0.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c"
dependencies = [
"proc-macro2",
"quote 1.0.9",
@@ -1899,6 +1915,12 @@ dependencies = [
"log",
]
[[package]]
name = "utf8-width"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cf7d77f457ef8dfa11e4cd5933c5ddb5dc52a94664071951219a97710f0a32b"
[[package]]
name = "uu_arch"
version = "0.0.7"
@@ -2063,6 +2085,20 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "uu_dd"
version = "0.0.7"
dependencies = [
"byte-unit",
"clap",
"gcd",
"libc",
"signal-hook",
"tempfile",
"uucore",
"uucore_procs",
]
[[package]]
name = "uu_df"
version = "0.0.7"
+2
View File
@@ -45,6 +45,7 @@ feat_common_core = [
"df",
"dircolors",
"dirname",
"dd",
"du",
"echo",
"env",
@@ -255,6 +256,7 @@ cp = { optional=true, version="0.0.7", package="uu_cp", path="src/uu/cp" }
csplit = { optional=true, version="0.0.7", package="uu_csplit", path="src/uu/csplit" }
cut = { optional=true, version="0.0.7", package="uu_cut", path="src/uu/cut" }
date = { optional=true, version="0.0.7", package="uu_date", path="src/uu/date" }
dd = { optional=true, version="0.0.7", package="uu_dd", path="src/uu/dd" }
df = { optional=true, version="0.0.7", package="uu_df", path="src/uu/df" }
dircolors= { optional=true, version="0.0.7", package="uu_dircolors", path="src/uu/dircolors" }
dirname = { optional=true, version="0.0.7", package="uu_dirname", path="src/uu/dirname" }
+17 -17
View File
@@ -366,23 +366,23 @@ To contribute to uutils, please see [CONTRIBUTING](CONTRIBUTING.md).
| Done | Semi-Done | To Do |
|-----------|-----------|--------|
| arch | cp | chcon |
| base32 | date | dd |
| base64 | df | runcon |
| basename | expr | stty |
| cat | install | |
| chgrp | join | |
| chmod | ls | |
| chown | more | |
| chroot | numfmt | |
| cksum | od (`--strings` and 128-bit data types missing) | |
| comm | pr | |
| csplit | printf | |
| cut | sort | |
| dircolors | split | |
| dirname | tac | |
| du | tail | |
| echo | test | |
| env | | |
| base32 | date | runcon |
| base64 | dd | stty |
| basename | df | |
| cat | expr | |
| chgrp | install | |
| chmod | join | |
| chown | ls | |
| chroot | more | |
| cksum | numfmt | |
| comm | od (`--strings` and 128-bit data types missing) |
| csplit | pr | |
| cut | printf | |
| dircolors | sort | |
| dirname | split | |
| du | tac | |
| echo | tail | |
| env | test | |
| expand | | |
| factor | | |
| false | | |
+31
View File
@@ -0,0 +1,31 @@
[package]
name = "uu_dd"
version = "0.0.7"
authors = ["uutils developers"]
license = "MIT"
description = "dd ~ (uutils) copy and convert files"
homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/master/src/uu/dd"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2018"
[lib]
path = "src/dd.rs"
[dependencies]
byte-unit = "4.0"
clap = { version = "2.33", features = [ "wrap_help" ] }
gcd = "2.0"
libc = "0.2"
signal-hook = "0.3.9"
uucore = { version=">=0.0.8", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
[dev-dependencies]
tempfile = "^3"
[[bin]]
name = "dd"
path = "src/main.rs"
+221
View File
@@ -0,0 +1,221 @@
// This file is part of the uutils coreutils package.
//
// (c) Tyler Steele <tyler.steele@protonmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// Note: Conversion tables are just lookup tables.
// eg. The ASCII->EBCDIC table stores the EBCDIC code at the index
// obtained by treating the ASCII representation as a number.
pub type ConversionTable = [u8; 256];
pub const ASCII_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, 0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, 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,
];
pub const ASCII_TO_EBCDIC_UCASE_TO_LCASE: 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, 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, 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,
];
pub const ASCII_TO_EBCDIC_LCASE_TO_UCASE: ConversionTable = [
0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0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 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,
];
pub const ASCII_TO_IBM_UCASE_TO_LCASE: 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, 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, 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,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 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,
];
pub 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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const EBCDIC_TO_ASCII_UCASE_TO_LCASE: 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, 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, 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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xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 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,
];
+172
View File
@@ -0,0 +1,172 @@
// This file is part of the uutils coreutils package.
//
// (c) Tyler Steele <tyler.steele@protonmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore ctable, outfile
use crate::conversion_tables::*;
use std::error::Error;
use std::time;
pub struct ProgUpdate {
pub read_stat: ReadStat,
pub write_stat: WriteStat,
pub duration: time::Duration,
}
#[derive(Clone, Copy, Default)]
pub struct ReadStat {
pub reads_complete: u64,
pub reads_partial: u64,
pub records_truncated: u32,
}
impl std::ops::AddAssign for ReadStat {
fn add_assign(&mut self, other: Self) {
*self = Self {
reads_complete: self.reads_complete + other.reads_complete,
reads_partial: self.reads_partial + other.reads_partial,
records_truncated: self.records_truncated + other.records_truncated,
}
}
}
#[derive(Clone, Copy)]
pub struct WriteStat {
pub writes_complete: u64,
pub writes_partial: u64,
pub bytes_total: u128,
}
impl std::ops::AddAssign for WriteStat {
fn add_assign(&mut self, other: Self) {
*self = Self {
writes_complete: self.writes_complete + other.writes_complete,
writes_partial: self.writes_partial + other.writes_partial,
bytes_total: self.bytes_total + other.bytes_total,
}
}
}
type Cbs = usize;
/// Stores all Conv Flags that apply to the input
#[derive(Debug, Default, PartialEq)]
pub struct IConvFlags {
pub ctable: Option<&'static ConversionTable>,
pub block: Option<Cbs>,
pub unblock: Option<Cbs>,
pub swab: bool,
pub sync: Option<u8>,
pub noerror: bool,
}
/// Stores all Conv Flags that apply to the output
#[derive(Debug, Default, PartialEq)]
pub struct OConvFlags {
pub sparse: bool,
pub excl: bool,
pub nocreat: bool,
pub notrunc: bool,
pub fdatasync: bool,
pub fsync: bool,
}
/// Stores all Flags that apply to the input
#[derive(Debug, Default, PartialEq)]
pub struct IFlags {
pub cio: bool,
pub direct: bool,
pub directory: bool,
pub dsync: bool,
pub sync: bool,
pub nocache: bool,
pub nonblock: bool,
pub noatime: bool,
pub noctty: bool,
pub nofollow: bool,
pub nolinks: bool,
pub binary: bool,
pub text: bool,
pub fullblock: bool,
pub count_bytes: bool,
pub skip_bytes: bool,
}
/// Stores all Flags that apply to the output
#[derive(Debug, Default, PartialEq)]
pub struct OFlags {
pub append: bool,
pub cio: bool,
pub direct: bool,
pub directory: bool,
pub dsync: bool,
pub sync: bool,
pub nocache: bool,
pub nonblock: bool,
pub noatime: bool,
pub noctty: bool,
pub nofollow: bool,
pub nolinks: bool,
pub binary: bool,
pub text: bool,
pub seek_bytes: bool,
}
/// The value of the status cl-option.
/// Controls printing of transfer stats
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum StatusLevel {
Progress,
Noxfer,
None,
}
/// The value of count=N
/// Defaults to Reads(N)
/// if iflag=count_bytes
/// then becomes Bytes(N)
#[derive(Debug, PartialEq)]
pub enum CountType {
Reads(usize),
Bytes(usize),
}
#[derive(Debug)]
pub enum InternalError {
WrongInputType,
WrongOutputType,
InvalidConvBlockUnblockCase,
}
impl std::fmt::Display for InternalError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::WrongInputType | Self::WrongOutputType => {
write!(f, "Internal dd error: Wrong Input/Output data type")
}
Self::InvalidConvBlockUnblockCase => {
write!(f, "Invalid Conversion, Block, or Unblock data")
}
}
}
}
impl Error for InternalError {}
pub mod options {
pub const INFILE: &str = "if";
pub const OUTFILE: &str = "of";
pub const IBS: &str = "ibs";
pub const OBS: &str = "obs";
pub const BS: &str = "bs";
pub const CBS: &str = "cbs";
pub const COUNT: &str = "count";
pub const SKIP: &str = "skip";
pub const SEEK: &str = "seek";
pub const STATUS: &str = "status";
pub const CONV: &str = "conv";
pub const IFLAG: &str = "iflag";
pub const OFLAG: &str = "oflag";
}
+1236
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,351 @@
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat
use super::*;
#[cfg(unix)]
macro_rules! make_block_test (
( $test_id:ident, $test_name:expr, $src:expr, $block:expr, $spec:expr ) =>
{
make_spec_test!($test_id,
$test_name,
Input {
src: $src,
non_ascii: false,
ibs: 512,
print_level: None,
count: None,
cflags: IConvFlags {
block: $block,
..IConvFlags::default()
},
iflags: IFlags::default(),
},
Output {
dst: File::create(format!("./test-resources/FAILED-{}.test", $test_name)).unwrap(),
obs: 512,
cflags: OConvFlags::default(),
},
$spec,
format!("./test-resources/FAILED-{}.test", $test_name)
);
};
);
#[cfg(unix)]
macro_rules! make_unblock_test (
( $test_id:ident, $test_name:expr, $src:expr, $unblock:expr, $spec:expr ) =>
{
make_spec_test!($test_id,
$test_name,
Input {
src: $src,
non_ascii: false,
ibs: 512,
print_level: None,
count: None,
cflags: IConvFlags {
unblock: $unblock,
..IConvFlags::default()
},
iflags: IFlags::default(),
},
Output {
dst: File::create(format!("./test-resources/FAILED-{}.test", $test_name)).unwrap(),
obs: 512,
cflags: OConvFlags::default(),
},
$spec,
format!("./test-resources/FAILED-{}.test", $test_name)
);
};
);
#[test]
fn block_test_no_nl() {
let mut rs = ReadStat::default();
let buf = vec![0u8, 1u8, 2u8, 3u8];
let res = block(buf, 4, &mut rs);
assert_eq!(res, vec![vec![0u8, 1u8, 2u8, 3u8],]);
}
#[test]
fn block_test_no_nl_short_record() {
let mut rs = ReadStat::default();
let buf = vec![0u8, 1u8, 2u8, 3u8];
let res = block(buf, 8, &mut rs);
assert_eq!(
res,
vec![vec![0u8, 1u8, 2u8, 3u8, SPACE, SPACE, SPACE, SPACE],]
);
}
#[test]
fn block_test_no_nl_trunc() {
let mut rs = ReadStat::default();
let buf = vec![0u8, 1u8, 2u8, 3u8, 4u8];
let res = block(buf, 4, &mut rs);
// Commented section(s) should be truncated and appear for reference only.
assert_eq!(res, vec![vec![0u8, 1u8, 2u8, 3u8 /*, 4u8*/],]);
assert_eq!(rs.records_truncated, 1);
}
#[test]
fn block_test_nl_gt_cbs_trunc() {
let mut rs = ReadStat::default();
let buf = vec![
0u8, 1u8, 2u8, 3u8, 4u8, NEWLINE, 0u8, 1u8, 2u8, 3u8, 4u8, NEWLINE, 5u8, 6u8, 7u8, 8u8,
];
let res = block(buf, 4, &mut rs);
assert_eq!(
res,
vec![
// Commented section(s) should be truncated and appear for reference only.
vec![0u8, 1u8, 2u8, 3u8],
// vec![4u8, SPACE, SPACE, SPACE],
vec![0u8, 1u8, 2u8, 3u8],
// vec![4u8, SPACE, SPACE, SPACE],
vec![5u8, 6u8, 7u8, 8u8],
]
);
assert_eq!(rs.records_truncated, 2);
}
#[test]
fn block_test_surrounded_nl() {
let mut rs = ReadStat::default();
let buf = vec![0u8, 1u8, 2u8, 3u8, NEWLINE, 4u8, 5u8, 6u8, 7u8, 8u8];
let res = block(buf, 8, &mut rs);
assert_eq!(
res,
vec![
vec![0u8, 1u8, 2u8, 3u8, SPACE, SPACE, SPACE, SPACE],
vec![4u8, 5u8, 6u8, 7u8, 8u8, SPACE, SPACE, SPACE],
]
);
}
#[test]
fn block_test_multiple_nl_same_cbs_block() {
let mut rs = ReadStat::default();
let buf = vec![
0u8, 1u8, 2u8, 3u8, NEWLINE, 4u8, NEWLINE, 5u8, 6u8, 7u8, 8u8, 9u8,
];
let res = block(buf, 8, &mut rs);
assert_eq!(
res,
vec![
vec![0u8, 1u8, 2u8, 3u8, SPACE, SPACE, SPACE, SPACE],
vec![4u8, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE],
vec![5u8, 6u8, 7u8, 8u8, 9u8, SPACE, SPACE, SPACE],
]
);
}
#[test]
fn block_test_multiple_nl_diff_cbs_block() {
let mut rs = ReadStat::default();
let buf = vec![
0u8, 1u8, 2u8, 3u8, NEWLINE, 4u8, 5u8, 6u8, 7u8, NEWLINE, 8u8, 9u8,
];
let res = block(buf, 8, &mut rs);
assert_eq!(
res,
vec![
vec![0u8, 1u8, 2u8, 3u8, SPACE, SPACE, SPACE, SPACE],
vec![4u8, 5u8, 6u8, 7u8, SPACE, SPACE, SPACE, SPACE],
vec![8u8, 9u8, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE],
]
);
}
#[test]
fn block_test_end_nl_diff_cbs_block() {
let mut rs = ReadStat::default();
let buf = vec![0u8, 1u8, 2u8, 3u8, NEWLINE];
let res = block(buf, 4, &mut rs);
assert_eq!(res, vec![vec![0u8, 1u8, 2u8, 3u8],]);
}
#[test]
fn block_test_end_nl_same_cbs_block() {
let mut rs = ReadStat::default();
let buf = vec![0u8, 1u8, 2u8, NEWLINE];
let res = block(buf, 4, &mut rs);
assert_eq!(res, vec![vec![0u8, 1u8, 2u8, SPACE]]);
}
#[test]
fn block_test_double_end_nl() {
let mut rs = ReadStat::default();
let buf = vec![0u8, 1u8, 2u8, NEWLINE, NEWLINE];
let res = block(buf, 4, &mut rs);
assert_eq!(
res,
vec![vec![0u8, 1u8, 2u8, SPACE], vec![SPACE, SPACE, SPACE, SPACE],]
);
}
#[test]
fn block_test_start_nl() {
let mut rs = ReadStat::default();
let buf = vec![NEWLINE, 0u8, 1u8, 2u8, 3u8];
let res = block(buf, 4, &mut rs);
assert_eq!(
res,
vec![vec![SPACE, SPACE, SPACE, SPACE], vec![0u8, 1u8, 2u8, 3u8],]
);
}
#[test]
fn block_test_double_surrounded_nl_no_trunc() {
let mut rs = ReadStat::default();
let buf = vec![0u8, 1u8, 2u8, 3u8, NEWLINE, NEWLINE, 4u8, 5u8, 6u8, 7u8];
let res = block(buf, 8, &mut rs);
assert_eq!(
res,
vec![
vec![0u8, 1u8, 2u8, 3u8, SPACE, SPACE, SPACE, SPACE],
vec![SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE],
vec![4u8, 5u8, 6u8, 7u8, SPACE, SPACE, SPACE, SPACE],
]
);
}
#[test]
fn block_test_double_surrounded_nl_double_trunc() {
let mut rs = ReadStat::default();
let buf = vec![
0u8, 1u8, 2u8, 3u8, NEWLINE, NEWLINE, 4u8, 5u8, 6u8, 7u8, 8u8,
];
let res = block(buf, 4, &mut rs);
assert_eq!(
res,
vec![
// Commented section(s) should be truncated and appear for reference only.
vec![0u8, 1u8, 2u8, 3u8],
vec![SPACE, SPACE, SPACE, SPACE],
vec![4u8, 5u8, 6u8, 7u8 /*, 8u8*/],
]
);
assert_eq!(rs.records_truncated, 1);
}
#[cfg(unix)]
make_block_test!(
block_cbs16,
"block-cbs-16",
File::open("./test-resources/dd-block-cbs16.test").unwrap(),
Some(16),
File::open("./test-resources/dd-block-cbs16.spec").unwrap()
);
#[cfg(unix)]
make_block_test!(
block_cbs16_as_cbs8,
"block-cbs-16-as-cbs8",
File::open("./test-resources/dd-block-cbs16.test").unwrap(),
Some(8),
File::open("./test-resources/dd-block-cbs8.spec").unwrap()
);
#[cfg(unix)]
make_block_test!(
block_consecutive_nl,
"block-consecutive-nl",
File::open("./test-resources/dd-block-consecutive-nl.test").unwrap(),
Some(16),
File::open("./test-resources/dd-block-consecutive-nl-cbs16.spec").unwrap()
);
#[test]
fn unblock_test_full_cbs() {
let buf = vec![0u8, 1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8];
let res = unblock(buf, 8);
assert_eq!(res, vec![0u8, 1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, NEWLINE],);
}
#[test]
fn unblock_test_all_space() {
let buf = vec![SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE];
let res = unblock(buf, 8);
assert_eq!(res, vec![NEWLINE],);
}
#[test]
fn unblock_test_decoy_spaces() {
let buf = vec![0u8, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, 7u8];
let res = unblock(buf, 8);
assert_eq!(
res,
vec![0u8, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, 7u8, NEWLINE],
);
}
#[test]
fn unblock_test_strip_single_cbs() {
let buf = vec![0u8, 1u8, 2u8, 3u8, SPACE, SPACE, SPACE, SPACE];
let res = unblock(buf, 8);
assert_eq!(res, vec![0u8, 1u8, 2u8, 3u8, NEWLINE],);
}
#[test]
fn unblock_test_strip_multi_cbs() {
let buf = vec![
vec![0u8, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE],
vec![0u8, 1u8, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE],
vec![0u8, 1u8, 2u8, SPACE, SPACE, SPACE, SPACE, SPACE],
vec![0u8, 1u8, 2u8, 3u8, SPACE, SPACE, SPACE, SPACE],
]
.into_iter()
.flatten()
.collect::<Vec<_>>();
let res = unblock(buf, 8);
let exp = vec![
vec![0u8, NEWLINE],
vec![0u8, 1u8, NEWLINE],
vec![0u8, 1u8, 2u8, NEWLINE],
vec![0u8, 1u8, 2u8, 3u8, NEWLINE],
]
.into_iter()
.flatten()
.collect::<Vec<_>>();
assert_eq!(res, exp);
}
#[cfg(unix)]
make_unblock_test!(
unblock_multi_16,
"unblock-multi-16",
File::open("./test-resources/dd-unblock-cbs16.test").unwrap(),
Some(16),
File::open("./test-resources/dd-unblock-cbs16.spec").unwrap()
);
#[cfg(unix)]
make_unblock_test!(
unblock_multi_16_as_8,
"unblock-multi-16-as-8",
File::open("./test-resources/dd-unblock-cbs16.test").unwrap(),
Some(8),
File::open("./test-resources/dd-unblock-cbs8.spec").unwrap()
);
@@ -0,0 +1,106 @@
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat
use super::*;
macro_rules! make_sync_test (
( $test_id:ident, $test_name:expr, $src:expr, $sync:expr, $ibs:expr, $obs:expr, $spec:expr ) =>
{
make_spec_test!($test_id,
$test_name,
Input {
src: $src,
non_ascii: false,
ibs: $ibs,
print_level: None,
count: None,
cflags: IConvFlags {
sync: $sync,
..IConvFlags::default()
},
iflags: IFlags::default(),
},
Output {
dst: File::create(format!("./test-resources/FAILED-{}.test", $test_name)).unwrap(),
obs: $obs,
cflags: OConvFlags::default(),
},
$spec,
format!("./test-resources/FAILED-{}.test", $test_name)
);
};
);
// Zeros
make_sync_test!(
zeros_4k_conv_sync_obs_gt_ibs,
"zeros_4k_conv_sync_obs_gt_ibs",
File::open("./test-resources/zeros-620f0b67a91f7f74151bc5be745b7110.test").unwrap(),
Some(0u8),
521,
1031,
File::open("./test-resources/gnudd-conv-sync-ibs-521-obs-1031-zeros.spec").unwrap()
);
make_sync_test!(
zeros_4k_conv_sync_ibs_gt_obs,
"zeros_4k_conv_sync_ibs_gt_obs",
File::open("./test-resources/zeros-620f0b67a91f7f74151bc5be745b7110.test").unwrap(),
Some(0u8),
1031,
521,
File::open("./test-resources/gnudd-conv-sync-ibs-1031-obs-521-zeros.spec").unwrap()
);
// Deadbeef
make_sync_test!(
deadbeef_32k_conv_sync_obs_gt_ibs,
"deadbeef_32k_conv_sync_obs_gt_ibs",
File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap(),
Some(0u8),
521,
1031,
File::open("./test-resources/gnudd-conv-sync-ibs-521-obs-1031-deadbeef.spec").unwrap()
);
make_sync_test!(
deadbeef_32k_conv_sync_ibs_gt_obs,
"deadbeef_32k_conv_sync_ibs_gt_obs",
File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap(),
Some(0u8),
1031,
521,
File::open("./test-resources/gnudd-conv-sync-ibs-1031-obs-521-deadbeef.spec").unwrap()
);
// Random
make_sync_test!(
random_73k_test_bs_prime_obs_gt_ibs_sync,
"random-73k-test-bs-prime-obs-gt-ibs-sync",
File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap(),
Some(0u8),
521,
1031,
File::open("./test-resources/gnudd-conv-sync-ibs-521-obs-1031-random.spec").unwrap()
);
make_sync_test!(
random_73k_test_bs_prime_ibs_gt_obs_sync,
"random-73k-test-bs-prime-ibs-gt-obs-sync",
File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap(),
Some(0u8),
1031,
521,
File::open("./test-resources/gnudd-conv-sync-ibs-1031-obs-521-random.spec").unwrap()
);
make_sync_test!(
deadbeef_16_delayed,
"deadbeef-16-delayed",
LazyReader {
src: File::open("./test-resources/deadbeef-16.test").unwrap()
},
Some(0u8),
16,
32,
File::open("./test-resources/deadbeef-16.spec").unwrap()
);
@@ -0,0 +1,233 @@
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat
use super::*;
macro_rules! make_conv_test (
( $test_id:ident, $test_name:expr, $src:expr, $ctable:expr, $spec:expr ) =>
{
make_spec_test!($test_id,
$test_name,
Input {
src: $src,
non_ascii: false,
ibs: 512,
print_level: None,
count: None,
cflags: icf!($ctable),
iflags: IFlags::default(),
},
Output {
dst: File::create(format!("./test-resources/FAILED-{}.test", $test_name)).unwrap(),
obs: 512,
cflags: OConvFlags::default(),
},
$spec,
format!("./test-resources/FAILED-{}.test", $test_name)
);
};
);
macro_rules! make_icf_test (
( $test_id:ident, $test_name:expr, $src:expr, $icf:expr, $spec:expr ) =>
{
make_spec_test!($test_id,
$test_name,
Input {
src: $src,
non_ascii: false,
ibs: 512,
print_level: None,
count: None,
cflags: $icf,
iflags: IFlags::default(),
},
Output {
dst: File::create(format!("./test-resources/FAILED-{}.test", $test_name)).unwrap(),
obs: 512,
cflags: OConvFlags::default(),
},
$spec,
format!("./test-resources/FAILED-{}.test", $test_name)
);
};
);
make_conv_test!(
atoe_conv_spec_test,
"atoe-conv-spec-test",
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
Some(&ASCII_TO_EBCDIC),
File::open("./test-resources/gnudd-conv-atoe-seq-byte-values.spec").unwrap()
);
make_conv_test!(
etoa_conv_spec_test,
"etoa-conv-spec-test",
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
Some(&EBCDIC_TO_ASCII),
File::open("./test-resources/gnudd-conv-etoa-seq-byte-values.spec").unwrap()
);
make_conv_test!(
atoibm_conv_spec_test,
"atoibm-conv-spec-test",
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
Some(&ASCII_TO_IBM),
File::open("./test-resources/gnudd-conv-atoibm-seq-byte-values.spec").unwrap()
);
make_conv_test!(
lcase_ascii_to_ucase_ascii,
"lcase_ascii_to_ucase_ascii",
File::open("./test-resources/lcase-ascii.test").unwrap(),
Some(&ASCII_LCASE_TO_UCASE),
File::open("./test-resources/ucase-ascii.test").unwrap()
);
make_conv_test!(
ucase_ascii_to_lcase_ascii,
"ucase_ascii_to_lcase_ascii",
File::open("./test-resources/ucase-ascii.test").unwrap(),
Some(&ASCII_UCASE_TO_LCASE),
File::open("./test-resources/lcase-ascii.test").unwrap()
);
make_conv_test!(
// conv=ebcdic,ucase
atoe_and_ucase_conv_spec_test,
"atoe-and-ucase-conv-spec-test",
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
Some(&ASCII_TO_EBCDIC_LCASE_TO_UCASE),
File::open("./test-resources/ucase-ebcdic.test").unwrap()
);
make_conv_test!(
// conv=ebcdic,lcase
atoe_and_lcase_conv_spec_test,
"atoe-and-lcase-conv-spec-test",
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
Some(&ASCII_TO_EBCDIC_UCASE_TO_LCASE),
File::open("./test-resources/lcase-ebcdic.test").unwrap()
);
make_conv_test!(
// conv=ibm,ucase
atoibm_and_ucase_conv_spec_test,
"atoibm-and-ucase-conv-spec-test",
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
Some(&ASCII_TO_IBM_UCASE_TO_LCASE),
File::open("./test-resources/lcase-ibm.test").unwrap()
);
make_conv_test!(
// conv=ibm,lcase
atoibm_and_lcase_conv_spec_test,
"atoibm-and-lcase-conv-spec-test",
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
Some(&ASCII_TO_IBM_LCASE_TO_UCASE),
File::open("./test-resources/ucase-ibm.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(),
non_ascii: false,
ibs: 128,
print_level: None,
count: None,
cflags: icf!(Some(&ASCII_TO_EBCDIC)),
iflags: IFlags::default(),
};
let o = Output {
dst: File::create(&tmp_fname_ae).unwrap(),
obs: 1024,
cflags: OConvFlags::default(),
};
dd_fileout(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(),
non_ascii: false,
ibs: 256,
print_level: None,
count: None,
cflags: icf!(Some(&EBCDIC_TO_ASCII)),
iflags: IFlags::default(),
};
let o = Output {
dst: File::create(&tmp_fname_ea).unwrap(),
obs: 1024,
cflags: OConvFlags::default(),
};
dd_fileout(i, o).unwrap();
// Final Comparison
let res = File::open(&tmp_fname_ea).unwrap();
let spec =
File::open("./test-resources/all-valid-ascii-chars-37eff01866ba3f538421b30b7cbefcac.test")
.unwrap();
assert_eq!(
res.metadata().unwrap().len(),
spec.metadata().unwrap().len()
);
let res = BufReader::new(res);
let spec = BufReader::new(spec);
let res = BufReader::new(res);
// Check all bytes match
for (b_res, b_spec) in res.bytes().zip(spec.bytes()) {
assert_eq!(b_res.unwrap(), b_spec.unwrap());
}
fs::remove_file(&tmp_fname_ae).unwrap();
fs::remove_file(&tmp_fname_ea).unwrap();
}
make_icf_test!(
swab_256_test,
"swab-256",
File::open("./test-resources/seq-byte-values.test").unwrap(),
IConvFlags {
ctable: None,
block: None,
unblock: None,
swab: true,
sync: None,
noerror: false,
},
File::open("./test-resources/seq-byte-values-swapped.test").unwrap()
);
make_icf_test!(
swab_257_test,
"swab-257",
File::open("./test-resources/seq-byte-values-odd.test").unwrap(),
IConvFlags {
ctable: None,
block: None,
unblock: None,
swab: true,
sync: None,
noerror: false,
},
File::open("./test-resources/seq-byte-values-odd.spec").unwrap()
);
+89
View File
@@ -0,0 +1,89 @@
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat
use super::*;
mod block_unblock_tests;
mod conv_sync_tests;
mod conversion_tests;
mod sanity_tests;
use std::fs;
use std::io::prelude::*;
use std::io::BufReader;
struct LazyReader<R: Read> {
src: R,
}
impl<R: Read> Read for LazyReader<R> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let reduced = cmp::max(buf.len() / 2, 1);
self.src.read(&mut buf[..reduced])
}
}
#[macro_export]
macro_rules! icf (
( $ctable:expr ) =>
{
IConvFlags {
ctable: $ctable,
..IConvFlags::default()
}
};
);
#[macro_export]
macro_rules! make_spec_test (
( $test_id:ident, $test_name:expr, $src:expr ) =>
{
// When spec not given, output should match input
make_spec_test!($test_id, $test_name, $src, $src);
};
( $test_id:ident, $test_name:expr, $src:expr, $spec:expr ) =>
{
make_spec_test!($test_id,
$test_name,
Input {
src: $src,
non_ascii: false,
ibs: 512,
print_level: None,
count: None,
cflags: IConvFlags::default(),
iflags: IFlags::default(),
},
Output {
dst: File::create(format!("./test-resources/FAILED-{}.test", $test_name)).unwrap(),
obs: 512,
cflags: OConvFlags::default(),
},
$spec,
format!("./test-resources/FAILED-{}.test", $test_name)
);
};
( $test_id:ident, $test_name:expr, $i:expr, $o:expr, $spec:expr, $tmp_fname:expr ) =>
{
#[test]
fn $test_id()
{
dd_fileout($i,$o).unwrap();
let res = File::open($tmp_fname).unwrap();
// Check test file isn't empty (unless spec file is too)
assert_eq!(res.metadata().unwrap().len(), $spec.metadata().unwrap().len());
let spec = BufReader::new($spec);
let res = BufReader::new(res);
// Check all bytes match
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();
}
};
);
+316
View File
@@ -0,0 +1,316 @@
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat
use super::*;
const DST_PLACEHOLDER: Vec<u8> = Vec::new();
macro_rules! make_io_test (
( $test_id:ident, $test_name:expr, $i:expr, $o:expr, $spec:expr ) =>
{
make_spec_test!($test_id,
$test_name,
$i,
Output {
dst: File::create(format!("./test-resources/FAILED-{}.test", $test_name)).unwrap(),
obs: $o.obs,
cflags: $o.cflags,
},
$spec,
format!("./test-resources/FAILED-{}.test", $test_name)
);
};
);
make_spec_test!(
zeros_4k_test,
"zeros-4k",
File::open("./test-resources/zeros-620f0b67a91f7f74151bc5be745b7110.test").unwrap()
);
make_spec_test!(
ones_4k_test,
"ones-4k",
File::open("./test-resources/ones-6ae59e64850377ee5470c854761551ea.test").unwrap()
);
make_spec_test!(
deadbeef_32k_test,
"deadbeef-32k",
File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap()
);
make_spec_test!(
random_73k_test,
"random-73k",
File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap()
);
make_io_test!(
random_73k_test_not_a_multiple_obs_gt_ibs,
"random-73k-not-a-multiple-obs-gt-ibs",
Input {
src: File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap(),
non_ascii: false,
ibs: 521,
print_level: None,
count: None,
cflags: IConvFlags::default(),
iflags: IFlags::default(),
},
Output {
dst: DST_PLACEHOLDER,
obs: 1031,
cflags: OConvFlags::default(),
},
File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap()
);
make_io_test!(
random_73k_test_obs_lt_not_a_multiple_ibs,
"random-73k-obs-lt-not-a-multiple-ibs",
Input {
src: File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap(),
non_ascii: false,
ibs: 1031,
print_level: None,
count: None,
cflags: IConvFlags::default(),
iflags: IFlags::default(),
},
Output {
dst: DST_PLACEHOLDER,
obs: 521,
cflags: OConvFlags::default(),
},
File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap()
);
make_io_test!(
deadbeef_all_32k_test_count_reads,
"deadbeef_all_32k_test_count_reads",
Input {
src: File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap(),
non_ascii: false,
ibs: 1024,
print_level: None,
count: Some(CountType::Reads(32)),
cflags: IConvFlags::default(),
iflags: IFlags::default(),
},
Output {
dst: DST_PLACEHOLDER,
obs: 1024,
cflags: OConvFlags::default(),
},
File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap()
);
make_io_test!(
deadbeef_all_32k_test_count_bytes,
"deadbeef_all_32k_test_count_bytes",
Input {
src: File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap(),
non_ascii: false,
ibs: 531,
print_level: None,
count: Some(CountType::Bytes(32 * 1024)),
cflags: IConvFlags::default(),
iflags: IFlags::default(),
},
Output {
dst: DST_PLACEHOLDER,
obs: 1031,
cflags: OConvFlags::default(),
},
File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap()
);
make_io_test!(
deadbeef_32k_to_16k_test_count_reads,
"deadbeef_32k_test_count_reads",
Input {
src: File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap(),
non_ascii: false,
ibs: 1024,
print_level: None,
count: Some(CountType::Reads(16)),
cflags: IConvFlags::default(),
iflags: IFlags::default(),
},
Output {
dst: DST_PLACEHOLDER,
obs: 1031,
cflags: OConvFlags::default(),
},
File::open("./test-resources/gnudd-deadbeef-first-16k.spec").unwrap()
);
make_io_test!(
deadbeef_32k_to_12345_test_count_bytes,
"deadbeef_32k_to_12345_test_count_bytes",
Input {
src: File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap(),
non_ascii: false,
ibs: 531,
print_level: None,
count: Some(CountType::Bytes(12345)),
cflags: IConvFlags::default(),
iflags: IFlags::default(),
},
Output {
dst: DST_PLACEHOLDER,
obs: 1031,
cflags: OConvFlags::default(),
},
File::open("./test-resources/gnudd-deadbeef-first-12345.spec").unwrap()
);
make_io_test!(
random_73k_test_count_reads,
"random-73k-test-count-reads",
Input {
src: File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap(),
non_ascii: false,
ibs: 1024,
print_level: None,
count: Some(CountType::Reads(32)),
cflags: IConvFlags::default(),
iflags: IFlags::default(),
},
Output {
dst: DST_PLACEHOLDER,
obs: 1024,
cflags: OConvFlags::default(),
},
File::open("./test-resources/gnudd-random-first-32k.spec").unwrap()
);
make_io_test!(
random_73k_test_count_bytes,
"random-73k-test-count-bytes",
Input {
src: File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap(),
non_ascii: false,
ibs: 521,
print_level: None,
count: Some(CountType::Bytes(32 * 1024)),
cflags: IConvFlags::default(),
iflags: IFlags::default(),
},
Output {
dst: DST_PLACEHOLDER,
obs: 1031,
cflags: OConvFlags::default(),
},
File::open("./test-resources/gnudd-random-first-32k.spec").unwrap()
);
make_io_test!(
random_73k_test_lazy_fullblock,
"random-73k-test-lazy-fullblock",
Input {
src: LazyReader {
src: File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test")
.unwrap()
},
non_ascii: false,
ibs: 521,
print_level: None,
count: None,
cflags: IConvFlags::default(),
iflags: IFlags {
fullblock: true,
..IFlags::default()
},
},
Output {
dst: DST_PLACEHOLDER,
obs: 1031,
cflags: OConvFlags::default(),
},
File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap()
);
// Test internal buffer size fn
#[test]
fn bsize_test_primes() {
let (n, m) = (7901, 7919);
let res = calc_bsize(n, m);
assert!(res % n == 0);
assert!(res % m == 0);
assert_eq!(res, n * m);
}
#[test]
fn bsize_test_rel_prime_obs_greater() {
let (n, m) = (7 * 5119, 13 * 5119);
let res = calc_bsize(n, m);
assert!(res % n == 0);
assert!(res % m == 0);
assert_eq!(res, 7 * 13 * 5119);
}
#[test]
fn bsize_test_rel_prime_ibs_greater() {
let (n, m) = (13 * 5119, 7 * 5119);
let res = calc_bsize(n, m);
assert!(res % n == 0);
assert!(res % m == 0);
assert_eq!(res, 7 * 13 * 5119);
}
#[test]
fn bsize_test_3fac_rel_prime() {
let (n, m) = (11 * 13 * 5119, 7 * 11 * 5119);
let res = calc_bsize(n, m);
assert!(res % n == 0);
assert!(res % m == 0);
assert_eq!(res, 7 * 11 * 13 * 5119);
}
#[test]
fn bsize_test_ibs_greater() {
let (n, m) = (512 * 1024, 256 * 1024);
let res = calc_bsize(n, m);
assert!(res % n == 0);
assert!(res % m == 0);
assert_eq!(res, n);
}
#[test]
fn bsize_test_obs_greater() {
let (n, m) = (256 * 1024, 512 * 1024);
let res = calc_bsize(n, m);
assert!(res % n == 0);
assert!(res % m == 0);
assert_eq!(res, m);
}
#[test]
fn bsize_test_bs_eq() {
let (n, m) = (1024, 1024);
let res = calc_bsize(n, m);
assert!(res % n == 0);
assert!(res % m == 0);
assert_eq!(res, m);
}
#[test]
#[should_panic]
fn test_nocreat_causes_failure_when_ofile_doesnt_exist() {
let args = vec![
String::from("dd"),
String::from("--conv=nocreat"),
String::from("--of=not-a-real.file"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let _ = Output::<File>::new(&matches).unwrap();
}
+1
View File
@@ -0,0 +1 @@
uucore_procs::main!(uu_dd); // spell-checker:ignore procs uucore
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,16 @@
0
01
012
0123
01234
012345
0123456
01234567
012345678
0123456789
0123456789a
0123456789ab
0123456789abc
0123456789abcd
0123456789abcde
0123456789abcdef
@@ -0,0 +1 @@
0 01 012 0123 01234 012345 0123456 01234567 012345678 0123456789 0123456789a 0123456789ab 0123456789abc 0123456789abcd 0123456789abcde 0123456789abcdef

Some files were not shown because too many files have changed in this diff Show More