1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

Merge branch 'uutils:main' into more_implement_print_over_and_clean_print

This commit is contained in:
Ideflop 2023-05-17 22:47:07 +02:00 committed by GitHub
commit 1ce52903b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
92 changed files with 1026 additions and 274 deletions

View file

@ -3,7 +3,7 @@ name: CICD
# spell-checker:ignore (abbrev/names) CICD CodeCOV MacOS MinGW MSVC musl taiki # spell-checker:ignore (abbrev/names) CICD CodeCOV MacOS MinGW MSVC musl taiki
# spell-checker:ignore (env/flags) Awarnings Ccodegen Coverflow Cpanic Dwarnings RUSTDOCFLAGS RUSTFLAGS Zpanic CARGOFLAGS # spell-checker:ignore (env/flags) Awarnings Ccodegen Coverflow Cpanic Dwarnings RUSTDOCFLAGS RUSTFLAGS Zpanic CARGOFLAGS
# spell-checker:ignore (jargon) SHAs deps dequote softprops subshell toolchain fuzzers # spell-checker:ignore (jargon) SHAs deps dequote softprops subshell toolchain fuzzers
# spell-checker:ignore (people) Peltoche rivy # spell-checker:ignore (people) Peltoche rivy dtolnay
# spell-checker:ignore (shell/tools) choco clippy dmake dpkg esac fakeroot fdesc fdescfs gmake grcov halium lcov libssl mkdir popd printf pushd rsync rustc rustfmt rustup shopt utmpdump xargs # spell-checker:ignore (shell/tools) choco clippy dmake dpkg esac fakeroot fdesc fdescfs gmake grcov halium lcov libssl mkdir popd printf pushd rsync rustc rustfmt rustup shopt utmpdump xargs
# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos gnueabihf issuecomment maint multisize nullglob onexitbegin onexitend pell runtest Swatinem tempfile testsuite toybox uutils # spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos gnueabihf issuecomment maint multisize nullglob onexitbegin onexitend pell runtest Swatinem tempfile testsuite toybox uutils
@ -48,10 +48,10 @@ jobs:
- { os: windows-latest , features: feat_os_windows } - { os: windows-latest , features: feat_os_windows }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@nightly
run: | ## note: requires 'nightly' toolchain b/c `cargo-udeps` uses the `rustc` '-Z save-analysis' option
rustup toolchain install nightly --no-self-update --profile minimal ## * ... ref: <https://github.com/est31/cargo-udeps/issues/73>
rustup default nightly - uses: taiki-e/install-action@cargo-udeps
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Initialize workflow variables - name: Initialize workflow variables
id: vars id: vars
@ -70,12 +70,6 @@ jobs:
CARGO_FEATURES_OPTION='' ; CARGO_FEATURES_OPTION='' ;
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
outputs CARGO_FEATURES_OPTION outputs CARGO_FEATURES_OPTION
## note: requires 'nightly' toolchain b/c `cargo-udeps` uses the `rustc` '-Z save-analysis' option
## * ... ref: <https://github.com/est31/cargo-udeps/issues/73>
- name: Install `cargo-udeps`
run: cargo install cargo-udeps
env:
RUSTUP_TOOLCHAIN: stable
- name: Detect unused dependencies - name: Detect unused dependencies
shell: bash shell: bash
run: | run: |
@ -98,11 +92,10 @@ jobs:
- { os: ubuntu-latest , features: feat_os_unix } - { os: ubuntu-latest , features: feat_os_unix }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@master
run: | with:
## Install `rust` toolchain toolchain: stable
rustup toolchain install stable --no-self-update -c rustfmt --profile minimal components: rustfmt
rustup default stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Initialize workflow variables - name: Initialize workflow variables
id: vars id: vars
@ -139,10 +132,7 @@ jobs:
RUN_FOR: 60 RUN_FOR: 60
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@nightly
run: |
rustup toolchain install nightly --no-self-update --profile minimal
rustup default nightly
- name: Install `cargo-fuzz` - name: Install `cargo-fuzz`
run: cargo install cargo-fuzz run: cargo install cargo-fuzz
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
@ -186,11 +176,10 @@ jobs:
- { os: windows-latest , features: feat_os_windows } - { os: windows-latest , features: feat_os_windows }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@master
run: | with:
## Install `rust` toolchain toolchain: stable
rustup toolchain install stable --no-self-update -c clippy --profile minimal components: clippy
rustup default stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Run sccache-cache - name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3 uses: mozilla-actions/sccache-action@v0.0.3
@ -297,11 +286,10 @@ jobs:
# - { os: windows-latest , features: feat_os_windows } # - { os: windows-latest , features: feat_os_windows }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@master
run: | with:
## Install `rust` toolchain toolchain: stable
rustup toolchain install stable --no-self-update -c clippy --profile minimal components: clippy
rustup default stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Run sccache-cache - name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3 uses: mozilla-actions/sccache-action@v0.0.3
@ -351,13 +339,12 @@ jobs:
- { os: ubuntu-latest , features: feat_os_unix } - { os: ubuntu-latest , features: feat_os_unix }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain (v${{ env.RUST_MIN_SRV }}) - uses: dtolnay/rust-toolchain@master
run: | with:
## Install `rust` toolchain (v${{ env.RUST_MIN_SRV }}) toolchain: ${{ env.RUST_MIN_SRV }}
rustup toolchain install --no-self-update ${{ env.RUST_MIN_SRV }} --profile minimal components: rustfmt
rustup default ${{ env.RUST_MIN_SRV }}
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest - uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache - name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3 uses: mozilla-actions/sccache-action@v0.0.3
- name: Initialize workflow variables - name: Initialize workflow variables
@ -409,7 +396,6 @@ jobs:
env: env:
RUSTFLAGS: "-Awarnings" RUSTFLAGS: "-Awarnings"
RUST_BACKTRACE: "1" RUST_BACKTRACE: "1"
CARGO_TERM_COLOR: always
deps: deps:
name: Dependencies name: Dependencies
@ -421,11 +407,7 @@ jobs:
- { os: ubuntu-latest , features: feat_os_unix } - { os: ubuntu-latest , features: feat_os_unix }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@stable
run: |
## Install `rust` toolchain
rustup toolchain install stable --no-self-update --profile minimal
rustup default stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: "`cargo update` testing" - name: "`cargo update` testing"
shell: bash shell: bash
@ -448,11 +430,7 @@ jobs:
- { os: ubuntu-latest , features: feat_os_unix } - { os: ubuntu-latest , features: feat_os_unix }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@stable
run: |
## Install `rust` toolchain
rustup toolchain install stable --no-self-update --profile minimal
rustup default stable
- uses: taiki-e/install-action@nextest - uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Run sccache-cache - name: Run sccache-cache
@ -466,7 +444,6 @@ jobs:
run: make nextest CARGOFLAGS="--profile ci --hide-progress-bar" run: make nextest CARGOFLAGS="--profile ci --hide-progress-bar"
env: env:
RUST_BACKTRACE: "1" RUST_BACKTRACE: "1"
CARGO_TERM_COLOR: "always"
- name: "`make install`" - name: "`make install`"
shell: bash shell: bash
run: | run: |
@ -495,11 +472,7 @@ jobs:
- { os: windows-latest , features: feat_os_windows } - { os: windows-latest , features: feat_os_windows }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@stable
run: |
## Install `rust` toolchain
rustup toolchain install stable --no-self-update --profile minimal
rustup default stable
- uses: taiki-e/install-action@nextest - uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Run sccache-cache - name: Run sccache-cache
@ -508,7 +481,6 @@ jobs:
run: cargo nextest run --hide-progress-bar --profile ci ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} run: cargo nextest run --hide-progress-bar --profile ci ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
env: env:
RUST_BACKTRACE: "1" RUST_BACKTRACE: "1"
CARGO_TERM_COLOR: "always"
build_rust_nightly: build_rust_nightly:
name: Build/nightly name: Build/nightly
@ -527,11 +499,7 @@ jobs:
- { os: windows-latest , features: feat_os_windows } - { os: windows-latest , features: feat_os_windows }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@nightly
run: |
## Install `rust` toolchain
rustup toolchain install nightly --no-self-update --profile minimal
rustup default nightly
- uses: taiki-e/install-action@nextest - uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Run sccache-cache - name: Run sccache-cache
@ -540,7 +508,6 @@ jobs:
run: cargo nextest run --hide-progress-bar --profile ci ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} run: cargo nextest run --hide-progress-bar --profile ci ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
env: env:
RUST_BACKTRACE: "1" RUST_BACKTRACE: "1"
CARGO_TERM_COLOR: "always"
compute_size: compute_size:
name: Binary sizes name: Binary sizes
@ -556,11 +523,7 @@ jobs:
- { os: ubuntu-latest , features: feat_os_unix } - { os: ubuntu-latest , features: feat_os_unix }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@stable
run: |
## Install `rust` toolchain
rustup toolchain install stable --no-self-update --profile minimal
rustup default stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Run sccache-cache - name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3 uses: mozilla-actions/sccache-action@v0.0.3
@ -680,11 +643,10 @@ jobs:
- { os: windows-latest , target: x86_64-pc-windows-msvc , features: feat_os_windows } - { os: windows-latest , target: x86_64-pc-windows-msvc , features: feat_os_windows }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: rust toolchain ~ install - uses: dtolnay/rust-toolchain@master
run: | with:
## rust toolchain ~ install toolchain: ${{ env.RUST_MIN_SRV }}
rustup toolchain install --no-self-update ${{ env.RUST_MIN_SRV }} -t ${{ matrix.job.target }} --profile minimal targets: ${{ matrix.job.target }}
rustup default ${{ env.RUST_MIN_SRV }}
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
key: "${{ matrix.job.os }}_${{ matrix.job.target }}" key: "${{ matrix.job.os }}_${{ matrix.job.target }}"
@ -765,8 +727,7 @@ jobs:
outputs CARGO_CMD outputs CARGO_CMD
# ** pass needed environment into `cross` container (iff `cross` not already configured via "Cross.toml") # ** pass needed environment into `cross` container (iff `cross` not already configured via "Cross.toml")
if [ "${CARGO_CMD}" = 'cross' ] && [ ! -e "Cross.toml" ] ; then if [ "${CARGO_CMD}" = 'cross' ] && [ ! -e "Cross.toml" ] ; then
cargo install --version 0.2.1 cross printf "[build.env]\npassthrough = [\"CI\", \"RUST_BACKTRACE\", \"CARGO_TERM_COLOR\"]\n" > Cross.toml
printf "[build.env]\npassthrough = [\"CI\", \"RUST_BACKTRACE\"]\n" > Cross.toml
fi fi
# * test only library and/or binaries for arm-type targets # * test only library and/or binaries for arm-type targets
unset CARGO_TEST_OPTIONS ; case '${{ matrix.job.target }}' in aarch64-* | arm-*) CARGO_TEST_OPTIONS="--bins" ;; esac; unset CARGO_TEST_OPTIONS ; case '${{ matrix.job.target }}' in aarch64-* | arm-*) CARGO_TEST_OPTIONS="--bins" ;; esac;
@ -779,6 +740,10 @@ jobs:
*-pc-windows-msvc) STRIP="" ;; *-pc-windows-msvc) STRIP="" ;;
esac; esac;
outputs STRIP outputs STRIP
- uses: taiki-e/install-action@v2
if: steps.vars.outputs.CARGO_CMD == 'cross'
with:
tool: cross@0.2.1
- name: Create all needed build/work directories - name: Create all needed build/work directories
shell: bash shell: bash
run: | run: |
@ -1017,11 +982,10 @@ jobs:
TEST_SUMMARY_FILE="toybox-result.json" TEST_SUMMARY_FILE="toybox-result.json"
outputs TEST_SUMMARY_FILE outputs TEST_SUMMARY_FILE
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: rust toolchain ~ install - uses: dtolnay/rust-toolchain@master
run: | with:
## rust toolchain ~ install toolchain: ${{ env.RUST_MIN_SRV }}
rustup toolchain install --no-self-update ${{ env.RUST_MIN_SRV }} --profile minimal components: rustfmt
rustup default ${{ env.RUST_MIN_SRV }}
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Run sccache-cache - name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3 uses: mozilla-actions/sccache-action@v0.0.3
@ -1100,12 +1064,12 @@ jobs:
- { os: windows-latest , features: windows, toolchain: nightly-x86_64-pc-windows-gnu } - { os: windows-latest , features: windows, toolchain: nightly-x86_64-pc-windows-gnu }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: rust toolchain ~ install - uses: dtolnay/rust-toolchain@master
run: | with:
## rust toolchain ~ install toolchain: ${{ matrix.job.toolchain }}
rustup toolchain install ${{ matrix.job.toolchain }} --no-self-update --profile minimal components: rustfmt
rustup default ${{ matrix.job.toolchain }}
- uses: taiki-e/install-action@nextest - uses: taiki-e/install-action@nextest
- uses: taiki-e/install-action@grcov
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Run sccache-cache - name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3 uses: mozilla-actions/sccache-action@v0.0.3
@ -1170,7 +1134,6 @@ jobs:
- name: Test uucore - name: Test uucore
run: cargo nextest run --profile ci --hide-progress-bar -p uucore run: cargo nextest run --profile ci --hide-progress-bar -p uucore
env: env:
CARGO_INCREMENTAL: "0"
RUSTC_WRAPPER: "" RUSTC_WRAPPER: ""
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort" RUSTDOCFLAGS: "-Cpanic=abort"
@ -1179,7 +1142,6 @@ jobs:
- name: Test - name: Test
run: cargo nextest run --profile ci --hide-progress-bar ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} run: cargo nextest run --profile ci --hide-progress-bar ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
env: env:
CARGO_INCREMENTAL: "0"
RUSTC_WRAPPER: "" RUSTC_WRAPPER: ""
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort" RUSTDOCFLAGS: "-Cpanic=abort"
@ -1188,15 +1150,11 @@ jobs:
- name: Test individual utilities - name: Test individual utilities
run: cargo nextest run --profile ci --hide-progress-bar ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} run: cargo nextest run --profile ci --hide-progress-bar ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }}
env: env:
CARGO_INCREMENTAL: "0"
RUSTC_WRAPPER: "" RUSTC_WRAPPER: ""
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort" RUSTDOCFLAGS: "-Cpanic=abort"
RUST_BACKTRACE: "1" RUST_BACKTRACE: "1"
# RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }} # RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }}
- name: "`grcov` ~ install"
id: build_grcov
run: cargo install grcov
- name: Generate coverage data (via `grcov`) - name: Generate coverage data (via `grcov`)
id: coverage id: coverage
shell: bash shell: bash

View file

@ -1,6 +1,6 @@
name: FixPR name: FixPR
# spell-checker:ignore Swatinem # spell-checker:ignore Swatinem dtolnay
# Trigger automated fixes for PRs being merged (with associated commits) # Trigger automated fixes for PRs being merged (with associated commits)
@ -36,11 +36,7 @@ jobs:
# surface MSRV from CICD workflow # surface MSRV from CICD workflow
RUST_MIN_SRV=$(grep -P "^\s+RUST_MIN_SRV:" .github/workflows/CICD.yml | grep -Po "(?<=\x22)\d+[.]\d+(?:[.]\d+)?(?=\x22)" ) RUST_MIN_SRV=$(grep -P "^\s+RUST_MIN_SRV:" .github/workflows/CICD.yml | grep -Po "(?<=\x22)\d+[.]\d+(?:[.]\d+)?(?=\x22)" )
outputs RUST_MIN_SRV outputs RUST_MIN_SRV
- name: Install `rust` toolchain (v${{ steps.vars.outputs.RUST_MIN_SRV }}) - uses: dtolnay/rust-toolchain@${{ steps.vars.outputs.RUST_MIN_SRV }}
run: |
## Install `rust` toolchain (v${{ steps.vars.outputs.RUST_MIN_SRV }})
rustup toolchain install ${{ steps.vars.outputs.RUST_MIN_SRV }} --profile minimal
rustup default ${{ steps.vars.outputs.RUST_MIN_SRV }}
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Ensure updated 'Cargo.lock' - name: Ensure updated 'Cargo.lock'
shell: bash shell: bash
@ -101,12 +97,10 @@ jobs:
CARGO_FEATURES_OPTION='' ; CARGO_FEATURES_OPTION='' ;
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
outputs CARGO_FEATURES_OPTION outputs CARGO_FEATURES_OPTION
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@master
run: | with:
## Install `rust` toolchain toolchain: stable
rm -f "${HOME}/.cargo/bin/"{rustfmt,cargo-fmt} components: rustfmt
rustup toolchain install stable -c rustfmt --profile minimal
rustup default stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: "`cargo fmt`" - name: "`cargo fmt`"
shell: bash shell: bash

View file

@ -2,9 +2,9 @@ name: GnuTests
# spell-checker:ignore (abbrev/names) CodeCov gnulib GnuTests Swatinem # spell-checker:ignore (abbrev/names) CodeCov gnulib GnuTests Swatinem
# spell-checker:ignore (jargon) submodules # spell-checker:ignore (jargon) submodules
# spell-checker:ignore (libs/utils) autopoint chksum gperf lcov libexpect pyinotify shopt texinfo valgrind libattr libcap # spell-checker:ignore (libs/utils) autopoint chksum gperf lcov libexpect pyinotify shopt texinfo valgrind libattr libcap taiki-e
# spell-checker:ignore (options) Ccodegen Coverflow Cpanic Zpanic # spell-checker:ignore (options) Ccodegen Coverflow Cpanic Zpanic
# spell-checker:ignore (people) Dawid Dziurla * dawidd # spell-checker:ignore (people) Dawid Dziurla * dawidd dtolnay
# spell-checker:ignore (vars) FILESET SUBDIRS XPASS # spell-checker:ignore (vars) FILESET SUBDIRS XPASS
# * note: to run a single test => `REPO/util/run-gnu-test.sh PATH/TO/TEST/SCRIPT` # * note: to run a single test => `REPO/util/run-gnu-test.sh PATH/TO/TEST/SCRIPT`
@ -58,13 +58,13 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
path: '${{ steps.vars.outputs.path_UUTILS }}' path: '${{ steps.vars.outputs.path_UUTILS }}'
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@master
run: | with:
## Install `rust` toolchain toolchain: stable
rm -f "${HOME}/.cargo/bin/"{rustfmt,cargo-fmt} components: rustfmt
rustup toolchain install stable -c rustfmt --profile minimal
rustup default stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
workspaces: "./${{ steps.vars.outputs.path_UUTILS }} -> target"
- name: Checkout code (GNU coreutils) - name: Checkout code (GNU coreutils)
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
@ -317,13 +317,14 @@ jobs:
path: 'gnu' path: 'gnu'
ref: 'v9.3' ref: 'v9.3'
submodules: recursive submodules: recursive
- name: Install `rust` toolchain - uses: dtolnay/rust-toolchain@master
run: | with:
## Install `rust` toolchain toolchain: nightly
rm -f "${HOME}/.cargo/bin/"{rustfmt,cargo-fmt} components: rustfmt
rustup toolchain install nightly -c rustfmt --profile minimal - uses: taiki-e/install-action@grcov
rustup default nightly
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
workspaces: "./uutils -> target"
- name: Install dependencies - name: Install dependencies
run: | run: |
## Install dependencies ## Install dependencies
@ -344,7 +345,6 @@ jobs:
locale -a locale -a
- name: Build binaries - name: Build binaries
env: env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort" RUSTDOCFLAGS: "-Cpanic=abort"
run: | run: |
@ -353,8 +353,6 @@ jobs:
UU_MAKE_PROFILE=debug bash util/build-gnu.sh UU_MAKE_PROFILE=debug bash util/build-gnu.sh
- name: Run GNU tests - name: Run GNU tests
run: bash uutils/util/run-gnu-test.sh run: bash uutils/util/run-gnu-test.sh
- name: "`grcov` ~ install"
run: cargo install grcov
- name: Generate coverage data (via `grcov`) - name: Generate coverage data (via `grcov`)
id: coverage id: coverage
run: | run: |

22
Cargo.lock generated
View file

@ -1156,9 +1156,9 @@ dependencies = [
[[package]] [[package]]
name = "humantime_to_duration" name = "humantime_to_duration"
version = "0.1.3" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46276b15cd421d8262968eb5c3a075ae4a40bd787762ca0ddfead00fd5f6fbce" checksum = "714764645f21cc70c4c151d7798dd158409641f37ad820bed65224aae403cbed"
dependencies = [ dependencies = [
"regex", "regex",
"time", "time",
@ -1318,9 +1318,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.143" version = "0.2.144"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edc207893e85c5d6be840e969b496b53d94cec8be2d501b214f50daa97fa8024" checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -1404,9 +1404,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]] [[package]]
name = "memmap2" name = "memmap2"
version = "0.5.8" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b182332558b18d807c4ce1ca8ca983b34c3ee32765e47b3f0f69b90355cc1dc" checksum = "7f9ff02d2efdc645fca1ee55f45545b996e7da776b5b60c4e170334457551693"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -2158,9 +2158,9 @@ dependencies = [
[[package]] [[package]]
name = "sm3" name = "sm3"
version = "0.4.1" version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f943a7c5e3089f2bd046221d1e9f4fa59396bf0fe966360983649683086215da" checksum = "ebb9a3b702d0a7e33bc4d85a14456633d2b165c2ad839c5fd9a8417c1ab15860"
dependencies = [ dependencies = [
"digest", "digest",
] ]
@ -2552,6 +2552,7 @@ dependencies = [
"clap", "clap",
"gcd", "gcd",
"libc", "libc",
"nix",
"signal-hook", "signal-hook",
"uucore", "uucore",
] ]
@ -3378,6 +3379,7 @@ name = "uu_yes"
version = "0.0.18" version = "0.0.18"
dependencies = [ dependencies = [
"clap", "clap",
"itertools",
"nix", "nix",
"uucore", "uucore",
] ]
@ -3665,9 +3667,9 @@ checksum = "2a599daf1b507819c1121f0bf87fa37eb19daac6aff3aefefd4e6e2e0f2020fc"
[[package]] [[package]]
name = "zip" name = "zip"
version = "0.6.5" version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e92305c174683d78035cbf1b70e18db6329cc0f1b9cae0a52ca90bf5bfe7125" checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"crc32fast", "crc32fast",

View file

@ -286,11 +286,11 @@ fundu = "0.5.1"
gcd = "2.3" gcd = "2.3"
glob = "0.3.1" glob = "0.3.1"
half = "2.2" half = "2.2"
humantime_to_duration = "0.1.3" humantime_to_duration = "0.2.1"
indicatif = "0.17" indicatif = "0.17"
is-terminal = "0.4.6" is-terminal = "0.4.6"
itertools = "0.10.5" itertools = "0.10.5"
libc = "0.2.143" libc = "0.2.144"
lscolors = { version = "0.14.0", default-features=false, features = ["nu-ansi-term"] } lscolors = { version = "0.14.0", default-features=false, features = ["nu-ansi-term"] }
memchr = "2" memchr = "2"
nix = { version="0.26", default-features=false } nix = { version="0.26", default-features=false }
@ -331,7 +331,7 @@ walkdir = "2.3"
winapi-util = "0.1.5" winapi-util = "0.1.5"
windows-sys = { version="0.45.0", default-features=false } windows-sys = { version="0.45.0", default-features=false }
xattr = "1.0.0" xattr = "1.0.0"
zip = { version = "0.6.5", default_features=false, features=["deflate"] } zip = { version = "0.6.6", default_features=false, features=["deflate"] }
hex = "0.4.3" hex = "0.4.3"
md-5 = "0.10.5" md-5 = "0.10.5"
@ -340,7 +340,7 @@ sha2 = "0.10.6"
sha3 = "0.10.8" sha3 = "0.10.8"
blake2b_simd = "1.0.1" blake2b_simd = "1.0.1"
blake3 = "1.3.3" blake3 = "1.3.3"
sm3 = "0.4.1" sm3 = "0.4.2"
digest = "0.10.6" digest = "0.10.6"
uucore = { version=">=0.0.18", package="uucore", path="src/uucore" } uucore = { version=">=0.0.18", package="uucore", path="src/uucore" }

View file

@ -5,6 +5,21 @@ features that are not supported by GNU coreutils. We take care not to introduce
features that are incompatible with the GNU coreutils. Below is a list of uutils features that are incompatible with the GNU coreutils. Below is a list of uutils
extensions. extensions.
## General
GNU coreutils provides two ways to define short options taking an argument:
```
$ ls -w 80
$ ls -w80
```
We support a third way:
```
$ ls -w=80
```
## `env` ## `env`
`env` has an additional `-f`/`--file` flag that can parse `.env` files and set `env` has an additional `-f`/`--file` flag that can parse `.env` files and set

View file

@ -216,6 +216,10 @@ impl<'a, 'b> MDWriter<'a, 'b> {
} else if let Some(f) = get_zip_content(zip, &format!("pages/linux/{}.md", self.name)) { } else if let Some(f) = get_zip_content(zip, &format!("pages/linux/{}.md", self.name)) {
f f
} else { } else {
println!(
"Warning: Could not find tldr examples for page '{}'",
self.name
);
return Ok(()); return Ok(());
}; };

View file

@ -24,15 +24,33 @@ use uucore::{help_about, help_usage};
const ABOUT: &str = help_about!("basenc.md"); const ABOUT: &str = help_about!("basenc.md");
const USAGE: &str = help_usage!("basenc.md"); const USAGE: &str = help_usage!("basenc.md");
const ENCODINGS: &[(&str, Format)] = &[ const ENCODINGS: &[(&str, Format, &str)] = &[
("base64", Format::Base64), ("base64", Format::Base64, "same as 'base64' program"),
("base64url", Format::Base64Url), ("base64url", Format::Base64Url, "file- and url-safe base64"),
("base32", Format::Base32), ("base32", Format::Base32, "same as 'base32' program"),
("base32hex", Format::Base32Hex), (
("base16", Format::Base16), "base32hex",
("base2lsbf", Format::Base2Lsbf), Format::Base32Hex,
("base2msbf", Format::Base2Msbf), "extended hex alphabet base32",
("z85", Format::Z85), ),
("base16", Format::Base16, "hex encoding"),
(
"base2lsbf",
Format::Base2Lsbf,
"bit string with least significant bit (lsb) first",
),
(
"base2msbf",
Format::Base2Msbf,
"bit string with most significant bit (msb) first",
),
(
"z85",
Format::Z85,
"ascii85-like encoding;\n\
when encoding, input length must be a multiple of 4;\n\
when decoding, input length must be a multiple of 5",
),
]; ];
pub fn uu_app() -> Command { pub fn uu_app() -> Command {
@ -41,6 +59,7 @@ pub fn uu_app() -> Command {
command = command.arg( command = command.arg(
Arg::new(encoding.0) Arg::new(encoding.0)
.long(encoding.0) .long(encoding.0)
.help(encoding.2)
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
); );
} }

View file

@ -6,7 +6,7 @@
// file that was distributed with this source code. // file that was distributed with this source code.
// spell-checker:ignore (ToDO) fname, algo // spell-checker:ignore (ToDO) fname, algo
use clap::{crate_version, Arg, Command}; use clap::{crate_version, Arg, ArgAction, Command};
use hex::encode; use hex::encode;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::fs::File; use std::fs::File;
@ -103,6 +103,7 @@ struct Options {
algo_name: &'static str, algo_name: &'static str,
digest: Box<dyn Digest + 'static>, digest: Box<dyn Digest + 'static>,
output_bits: usize, output_bits: usize,
untagged: bool,
} }
/// Calculate checksum /// Calculate checksum
@ -159,8 +160,22 @@ where
div_ceil(sz, options.output_bits), div_ceil(sz, options.output_bits),
filename.display() filename.display()
), ),
(_, true) => println!("{sum} {sz}"), (ALGORITHM_OPTIONS_CRC, true) => println!("{sum} {sz}"),
(_, false) => println!("{sum} {sz} {}", filename.display()), (ALGORITHM_OPTIONS_CRC, false) => println!("{sum} {sz} {}", filename.display()),
(ALGORITHM_OPTIONS_BLAKE2B, _) if !options.untagged => {
println!("BLAKE2b ({}) = {sum}", filename.display());
}
_ => {
if options.untagged {
println!("{sum} {}", filename.display());
} else {
println!(
"{} ({}) = {sum}",
options.algo_name.to_ascii_uppercase(),
filename.display()
);
}
}
} }
} }
@ -202,8 +217,9 @@ fn digest_read<T: Read>(
} }
mod options { mod options {
pub static FILE: &str = "file"; pub const ALGORITHM: &str = "algorithm";
pub static ALGORITHM: &str = "algorithm"; pub const FILE: &str = "file";
pub const UNTAGGED: &str = "untagged";
} }
#[uucore::main] #[uucore::main]
@ -222,6 +238,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
algo_name: name, algo_name: name,
digest: algo, digest: algo,
output_bits: bits, output_bits: bits,
untagged: matches.get_flag(options::UNTAGGED),
}; };
match matches.get_many::<String>(options::FILE) { match matches.get_many::<String>(options::FILE) {
@ -264,5 +281,11 @@ pub fn uu_app() -> Command {
ALGORITHM_OPTIONS_SM3, ALGORITHM_OPTIONS_SM3,
]), ]),
) )
.arg(
Arg::new(options::UNTAGGED)
.long(options::UNTAGGED)
.help("create a reversed style checksum, without digest type")
.action(ArgAction::SetTrue),
)
.after_help(AFTER_HELP) .after_help(AFTER_HELP)
} }

View file

@ -404,8 +404,18 @@ pub(crate) fn copy_directory(
Err(e) => show_error!("{}", e), Err(e) => show_error!("{}", e),
} }
} }
// Copy the attributes from the root directory to the target directory. // Copy the attributes from the root directory to the target directory.
copy_attributes(root, target, &options.attributes)?; if options.parents {
let dest = target.join(root.file_name().unwrap());
copy_attributes(root, dest.as_path(), &options.attributes)?;
for (x, y) in aligned_ancestors(root, dest.as_path()) {
copy_attributes(x, y, &options.attributes)?;
}
} else {
copy_attributes(root, target, &options.attributes)?;
}
Ok(()) Ok(())
} }

View file

@ -1151,14 +1151,20 @@ fn copy_source(
} else { } else {
// Copy as file // Copy as file
let dest = construct_dest_path(source_path, target, target_type, options)?; let dest = construct_dest_path(source_path, target, target_type, options)?;
copy_file( let res = copy_file(
progress_bar, progress_bar,
source_path, source_path,
dest.as_path(), dest.as_path(),
options, options,
symlinked_files, symlinked_files,
true, true,
) );
if options.parents {
for (x, y) in aligned_ancestors(source, dest.as_path()) {
copy_attributes(x, y, &options.attributes)?;
}
}
res
} }
} }

View file

@ -20,6 +20,9 @@ gcd = { workspace=true }
libc = { workspace=true } libc = { workspace=true }
uucore = { workspace=true, features=["memo"] } uucore = { workspace=true, features=["memo"] }
[target.'cfg(any(target_os = "linux"))'.dependencies]
nix = { workspace=true, features = ["fs"] }
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
signal-hook = { workspace=true } signal-hook = { workspace=true }

View file

@ -5,7 +5,7 @@
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rremain, rsofar, rstat, sigusr, wlen, wstat seekable oconv canonicalized // spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rremain, rsofar, rstat, sigusr, wlen, wstat seekable oconv canonicalized fadvise Fadvise FADV DONTNEED ESPIPE
mod datastructures; mod datastructures;
use datastructures::*; use datastructures::*;
@ -42,9 +42,16 @@ use std::time;
use clap::{crate_version, Arg, Command}; use clap::{crate_version, Arg, Command};
use gcd::Gcd; use gcd::Gcd;
#[cfg(target_os = "linux")]
use nix::{
errno::Errno,
fcntl::{posix_fadvise, PosixFadviseAdvice},
};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{FromIo, UResult}; use uucore::error::{FromIo, UResult};
use uucore::{format_usage, help_about, help_section, help_usage, show_error}; use uucore::{format_usage, help_about, help_section, help_usage, show_error};
#[cfg(target_os = "linux")]
use uucore::{show, show_if_err};
const ABOUT: &str = help_about!("dd.md"); const ABOUT: &str = help_about!("dd.md");
const AFTER_HELP: &str = help_section!("after help", "dd.md"); const AFTER_HELP: &str = help_section!("after help", "dd.md");
@ -131,6 +138,16 @@ impl Source {
Self::StdinFile(f) Self::StdinFile(f)
} }
/// The length of the data source in number of bytes.
///
/// If it cannot be determined, then this function returns 0.
fn len(&self) -> std::io::Result<i64> {
match self {
Self::File(f) => Ok(f.metadata()?.len().try_into().unwrap_or(i64::MAX)),
_ => Ok(0),
}
}
fn skip(&mut self, n: u64) -> io::Result<u64> { fn skip(&mut self, n: u64) -> io::Result<u64> {
match self { match self {
#[cfg(not(unix))] #[cfg(not(unix))]
@ -156,6 +173,23 @@ impl Source {
Self::Fifo(f) => io::copy(&mut f.take(n), &mut io::sink()), Self::Fifo(f) => io::copy(&mut f.take(n), &mut io::sink()),
} }
} }
/// Discard the system file cache for the given portion of the data source.
///
/// `offset` and `len` specify a contiguous portion of the data
/// source. This function informs the kernel that the specified
/// portion of the source is no longer needed. If not possible,
/// then this function returns an error.
#[cfg(target_os = "linux")]
fn discard_cache(&self, offset: libc::off_t, len: libc::off_t) -> nix::Result<()> {
match self {
Self::File(f) => {
let advice = PosixFadviseAdvice::POSIX_FADV_DONTNEED;
posix_fadvise(f.as_raw_fd(), offset, len, advice)
}
_ => Err(Errno::ESPIPE), // "Illegal seek"
}
}
} }
impl Read for Source { impl Read for Source {
@ -296,6 +330,29 @@ impl<'a> Read for Input<'a> {
} }
impl<'a> Input<'a> { impl<'a> Input<'a> {
/// Discard the system file cache for the given portion of the input.
///
/// `offset` and `len` specify a contiguous portion of the input.
/// This function informs the kernel that the specified portion of
/// the input file is no longer needed. If not possible, then this
/// function prints an error message to stderr and sets the exit
/// status code to 1.
#[allow(unused_variables)]
fn discard_cache(&self, offset: libc::off_t, len: libc::off_t) {
#[cfg(target_os = "linux")]
{
show_if_err!(self
.src
.discard_cache(offset, len)
.map_err_context(|| "failed to discard cache for: 'standard input'".to_string()));
}
#[cfg(not(target_os = "linux"))]
{
// TODO Is there a way to discard filesystem cache on
// these other operating systems?
}
}
/// Fills a given buffer. /// Fills a given buffer.
/// Reads in increments of 'self.ibs'. /// Reads in increments of 'self.ibs'.
/// The start of each ibs-sized read follows the previous one. /// The start of each ibs-sized read follows the previous one.
@ -317,13 +374,13 @@ impl<'a> Input<'a> {
_ => break, _ => break,
} }
} }
buf.truncate(bytes_total); buf.truncate(bytes_total);
Ok(ReadStat { Ok(ReadStat {
reads_complete, reads_complete,
reads_partial, reads_partial,
// Records are not truncated when filling. // Records are not truncated when filling.
records_truncated: 0, records_truncated: 0,
bytes_total: bytes_total.try_into().unwrap(),
}) })
} }
@ -334,6 +391,7 @@ impl<'a> Input<'a> {
let mut reads_complete = 0; let mut reads_complete = 0;
let mut reads_partial = 0; let mut reads_partial = 0;
let mut base_idx = 0; let mut base_idx = 0;
let mut bytes_total = 0;
while base_idx < buf.len() { while base_idx < buf.len() {
let next_blk = cmp::min(base_idx + self.settings.ibs, buf.len()); let next_blk = cmp::min(base_idx + self.settings.ibs, buf.len());
@ -342,11 +400,13 @@ impl<'a> Input<'a> {
match self.read(&mut buf[base_idx..next_blk])? { match self.read(&mut buf[base_idx..next_blk])? {
0 => break, 0 => break,
rlen if rlen < target_len => { rlen if rlen < target_len => {
bytes_total += rlen;
reads_partial += 1; reads_partial += 1;
let padding = vec![pad; target_len - rlen]; let padding = vec![pad; target_len - rlen];
buf.splice(base_idx + rlen..next_blk, padding.into_iter()); buf.splice(base_idx + rlen..next_blk, padding.into_iter());
} }
_ => { rlen => {
bytes_total += rlen;
reads_complete += 1; reads_complete += 1;
} }
} }
@ -359,6 +419,7 @@ impl<'a> Input<'a> {
reads_complete, reads_complete,
reads_partial, reads_partial,
records_truncated: 0, records_truncated: 0,
bytes_total: bytes_total.try_into().unwrap(),
}) })
} }
} }
@ -447,6 +508,33 @@ impl Dest {
_ => Ok(()), _ => Ok(()),
} }
} }
/// Discard the system file cache for the given portion of the destination.
///
/// `offset` and `len` specify a contiguous portion of the
/// destination. This function informs the kernel that the
/// specified portion of the destination is no longer needed. If
/// not possible, then this function returns an error.
#[cfg(target_os = "linux")]
fn discard_cache(&self, offset: libc::off_t, len: libc::off_t) -> nix::Result<()> {
match self {
Self::File(f, _) => {
let advice = PosixFadviseAdvice::POSIX_FADV_DONTNEED;
posix_fadvise(f.as_raw_fd(), offset, len, advice)
}
_ => Err(Errno::ESPIPE), // "Illegal seek"
}
}
/// The length of the data destination in number of bytes.
///
/// If it cannot be determined, then this function returns 0.
fn len(&self) -> std::io::Result<i64> {
match self {
Self::File(f, _) => Ok(f.metadata()?.len().try_into().unwrap_or(i64::MAX)),
_ => Ok(0),
}
}
} }
/// Decide whether the given buffer is all zeros. /// Decide whether the given buffer is all zeros.
@ -580,6 +668,29 @@ impl<'a> Output<'a> {
Ok(Self { dst, settings }) Ok(Self { dst, settings })
} }
/// Discard the system file cache for the given portion of the output.
///
/// `offset` and `len` specify a contiguous portion of the output.
/// This function informs the kernel that the specified portion of
/// the output file is no longer needed. If not possible, then
/// this function prints an error message to stderr and sets the
/// exit status code to 1.
#[allow(unused_variables)]
fn discard_cache(&self, offset: libc::off_t, len: libc::off_t) {
#[cfg(target_os = "linux")]
{
show_if_err!(self
.dst
.discard_cache(offset, len)
.map_err_context(|| "failed to discard cache for: 'standard output'".to_string()));
}
#[cfg(target_os = "linux")]
{
// TODO Is there a way to discard filesystem cache on
// these other operating systems?
}
}
/// Write the given bytes one block at a time. /// Write the given bytes one block at a time.
/// ///
/// This may write partial blocks (for example, if the underlying /// This may write partial blocks (for example, if the underlying
@ -674,6 +785,27 @@ fn dd_copy(mut i: Input, mut o: Output) -> std::io::Result<()> {
// Optimization: if no blocks are to be written, then don't // Optimization: if no blocks are to be written, then don't
// bother allocating any buffers. // bother allocating any buffers.
if let Some(Num::Blocks(0) | Num::Bytes(0)) = i.settings.count { if let Some(Num::Blocks(0) | Num::Bytes(0)) = i.settings.count {
// Even though we are not reading anything from the input
// file, we still need to honor the `nocache` flag, which
// requests that we inform the system that we no longer
// need the contents of the input file in a system cache.
//
// TODO Better error handling for overflowing `len`.
if i.settings.iflags.nocache {
let offset = 0;
#[allow(clippy::useless_conversion)]
let len = i.src.len()?.try_into().unwrap();
i.discard_cache(offset, len);
}
// Similarly, discard the system cache for the output file.
//
// TODO Better error handling for overflowing `len`.
if i.settings.oflags.nocache {
let offset = 0;
#[allow(clippy::useless_conversion)]
let len = o.dst.len()?.try_into().unwrap();
o.discard_cache(offset, len);
}
return finalize(&mut o, rstat, wstat, start, &prog_tx, output_thread); return finalize(&mut o, rstat, wstat, start, &prog_tx, output_thread);
}; };
@ -681,6 +813,13 @@ fn dd_copy(mut i: Input, mut o: Output) -> std::io::Result<()> {
// This is the max size needed. // This is the max size needed.
let mut buf = vec![BUF_INIT_BYTE; bsize]; let mut buf = vec![BUF_INIT_BYTE; bsize];
// Index in the input file where we are reading bytes and in
// the output file where we are writing bytes.
//
// These are updated on each iteration of the main loop.
let mut read_offset = 0;
let mut write_offset = 0;
// The main read/write loop. // The main read/write loop.
// //
// Each iteration reads blocks from the input and writes // Each iteration reads blocks from the input and writes
@ -700,6 +839,30 @@ fn dd_copy(mut i: Input, mut o: Output) -> std::io::Result<()> {
} }
let wstat_update = o.write_blocks(&buf)?; let wstat_update = o.write_blocks(&buf)?;
// Discard the system file cache for the read portion of
// the input file.
//
// TODO Better error handling for overflowing `offset` and `len`.
let read_len = rstat_update.bytes_total;
if i.settings.iflags.nocache {
let offset = read_offset.try_into().unwrap();
let len = read_len.try_into().unwrap();
i.discard_cache(offset, len);
}
read_offset += read_len;
// Discard the system file cache for the written portion
// of the output file.
//
// TODO Better error handling for overflowing `offset` and `len`.
let write_len = wstat_update.bytes_total;
if o.settings.oflags.nocache {
let offset = write_offset.try_into().unwrap();
let len = write_len.try_into().unwrap();
o.discard_cache(offset, len);
}
write_offset += write_len;
// Update the read/write stats and inform the progress thread once per second. // Update the read/write stats and inform the progress thread once per second.
// //
// If the receiver is disconnected, `send()` returns an // If the receiver is disconnected, `send()` returns an

View file

@ -304,7 +304,7 @@ impl Parser {
"directory" => linux_only!(f, i.directory = true), "directory" => linux_only!(f, i.directory = true),
"dsync" => linux_only!(f, i.dsync = true), "dsync" => linux_only!(f, i.dsync = true),
"sync" => linux_only!(f, i.sync = true), "sync" => linux_only!(f, i.sync = true),
"nocache" => return Err(ParseError::Unimplemented(f.to_string())), "nocache" => linux_only!(f, i.nocache = true),
"nonblock" => linux_only!(f, i.nonblock = true), "nonblock" => linux_only!(f, i.nonblock = true),
"noatime" => linux_only!(f, i.noatime = true), "noatime" => linux_only!(f, i.noatime = true),
"noctty" => linux_only!(f, i.noctty = true), "noctty" => linux_only!(f, i.noctty = true),
@ -336,7 +336,7 @@ impl Parser {
"directory" => linux_only!(f, o.directory = true), "directory" => linux_only!(f, o.directory = true),
"dsync" => linux_only!(f, o.dsync = true), "dsync" => linux_only!(f, o.dsync = true),
"sync" => linux_only!(f, o.sync = true), "sync" => linux_only!(f, o.sync = true),
"nocache" => return Err(ParseError::Unimplemented(f.to_string())), "nocache" => linux_only!(f, o.nocache = true),
"nonblock" => linux_only!(f, o.nonblock = true), "nonblock" => linux_only!(f, o.nonblock = true),
"noatime" => linux_only!(f, o.noatime = true), "noatime" => linux_only!(f, o.noatime = true),
"noctty" => linux_only!(f, o.noctty = true), "noctty" => linux_only!(f, o.noctty = true),

View file

@ -55,7 +55,7 @@ fn unimplemented_flags_should_error() {
let mut succeeded = Vec::new(); let mut succeeded = Vec::new();
// The following flags are not implemented // The following flags are not implemented
for flag in ["cio", "nocache", "nolinks", "text", "binary"] { for flag in ["cio", "nolinks", "text", "binary"] {
let args = vec![format!("iflag={flag}")]; let args = vec![format!("iflag={flag}")];
if Parser::new() if Parser::new()

View file

@ -79,9 +79,9 @@ impl ProgUpdate {
/// ```rust,ignore /// ```rust,ignore
/// use std::io::Cursor; /// use std::io::Cursor;
/// use std::time::Duration; /// use std::time::Duration;
/// use crate::progress::{ProgUpdate, ReadState, WriteStat}; /// use crate::progress::{ProgUpdate, ReadStat, WriteStat};
/// ///
/// let read_stat = ReadStat::new(1, 2, 3); /// let read_stat = ReadStat::new(1, 2, 3, 999);
/// let write_stat = WriteStat::new(4, 5, 6); /// let write_stat = WriteStat::new(4, 5, 6);
/// let duration = Duration::new(789, 0); /// let duration = Duration::new(789, 0);
/// let prog_update = ProgUpdate { /// let prog_update = ProgUpdate {
@ -121,7 +121,7 @@ impl ProgUpdate {
/// ```rust,ignore /// ```rust,ignore
/// use std::io::Cursor; /// use std::io::Cursor;
/// use std::time::Duration; /// use std::time::Duration;
/// use crate::progress::{ProgUpdate, ReadState, WriteStat}; /// use crate::progress::ProgUpdate;
/// ///
/// let prog_update = ProgUpdate { /// let prog_update = ProgUpdate {
/// read_stat: Default::default(), /// read_stat: Default::default(),
@ -191,7 +191,7 @@ impl ProgUpdate {
/// ```rust,ignore /// ```rust,ignore
/// use std::io::Cursor; /// use std::io::Cursor;
/// use std::time::Duration; /// use std::time::Duration;
/// use crate::progress::{ProgUpdate, ReadState, WriteStat}; /// use crate::progress::ProgUpdate;
/// ///
/// let prog_update = ProgUpdate { /// let prog_update = ProgUpdate {
/// read_stat: Default::default(), /// read_stat: Default::default(),
@ -276,16 +276,20 @@ pub(crate) struct ReadStat {
/// ///
/// A truncated record can only occur in `conv=block` mode. /// A truncated record can only occur in `conv=block` mode.
pub(crate) records_truncated: u32, pub(crate) records_truncated: u32,
/// The total number of bytes read.
pub(crate) bytes_total: u64,
} }
impl ReadStat { impl ReadStat {
/// Create a new instance. /// Create a new instance.
#[allow(dead_code)] #[allow(dead_code)]
fn new(complete: u64, partial: u64, truncated: u32) -> Self { fn new(complete: u64, partial: u64, truncated: u32, bytes_total: u64) -> Self {
Self { Self {
reads_complete: complete, reads_complete: complete,
reads_partial: partial, reads_partial: partial,
records_truncated: truncated, records_truncated: truncated,
bytes_total,
} }
} }
@ -315,6 +319,7 @@ impl std::ops::AddAssign for ReadStat {
reads_complete: self.reads_complete + other.reads_complete, reads_complete: self.reads_complete + other.reads_complete,
reads_partial: self.reads_partial + other.reads_partial, reads_partial: self.reads_partial + other.reads_partial,
records_truncated: self.records_truncated + other.records_truncated, records_truncated: self.records_truncated + other.records_truncated,
bytes_total: self.bytes_total + other.bytes_total,
} }
} }
} }
@ -514,7 +519,7 @@ mod tests {
#[test] #[test]
fn test_read_stat_report() { fn test_read_stat_report() {
let read_stat = ReadStat::new(1, 2, 3); let read_stat = ReadStat::new(1, 2, 3, 4);
let mut cursor = Cursor::new(vec![]); let mut cursor = Cursor::new(vec![]);
read_stat.report(&mut cursor).unwrap(); read_stat.report(&mut cursor).unwrap();
assert_eq!(cursor.get_ref(), b"1+2 records in\n"); assert_eq!(cursor.get_ref(), b"1+2 records in\n");
@ -530,7 +535,7 @@ mod tests {
#[test] #[test]
fn test_prog_update_write_io_lines() { fn test_prog_update_write_io_lines() {
let read_stat = ReadStat::new(1, 2, 3); let read_stat = ReadStat::new(1, 2, 3, 4);
let write_stat = WriteStat::new(4, 5, 6); let write_stat = WriteStat::new(4, 5, 6);
let duration = Duration::new(789, 0); let duration = Duration::new(789, 0);
let complete = false; let complete = false;

View file

@ -41,7 +41,13 @@ use unicode_width::UnicodeWidthStr;
target_os = "linux", target_os = "linux",
target_os = "macos", target_os = "macos",
target_os = "android", target_os = "android",
target_os = "ios" target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd",
target_os = "illumos",
target_os = "solaris"
))] ))]
use uucore::libc::{dev_t, major, minor}; use uucore::libc::{dev_t, major, minor};
#[cfg(unix)] #[cfg(unix)]
@ -1991,7 +1997,12 @@ fn should_display(entry: &DirEntry, config: &Config) -> bool {
require_literal_separator: false, require_literal_separator: false,
case_sensitive: true, case_sensitive: true,
}; };
let file_name = entry.file_name().into_string().unwrap(); let file_name = entry.file_name();
// If the decoding fails, still show an incorrect rendering
let file_name = match file_name.to_str() {
Some(s) => s.to_string(),
None => file_name.to_string_lossy().into_owned(),
};
!config !config
.ignore_patterns .ignore_patterns
.iter() .iter()
@ -2716,7 +2727,13 @@ fn display_len_or_rdev(metadata: &Metadata, config: &Config) -> SizeOrDeviceId {
target_os = "linux", target_os = "linux",
target_os = "macos", target_os = "macos",
target_os = "android", target_os = "android",
target_os = "ios" target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd",
target_os = "illumos",
target_os = "solaris"
))] ))]
{ {
let ft = metadata.file_type(); let ft = metadata.file_type();

View file

@ -18,7 +18,7 @@ path = "src/tac.rs"
[dependencies] [dependencies]
memchr = { workspace=true } memchr = { workspace=true }
memmap2 = "0.5" memmap2 = "0.6"
regex = { workspace=true } regex = { workspace=true }
clap = { workspace=true } clap = { workspace=true }
uucore = { workspace=true } uucore = { workspace=true }

View file

@ -16,6 +16,7 @@ path = "src/yes.rs"
[dependencies] [dependencies]
clap = { workspace=true } clap = { workspace=true }
itertools = { workspace=true }
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
uucore = { workspace=true, features=["pipes", "signals"] } uucore = { workspace=true, features=["pipes", "signals"] }

View file

@ -7,8 +7,11 @@
/* last synced with: yes (GNU coreutils) 8.13 */ /* last synced with: yes (GNU coreutils) 8.13 */
use clap::{Arg, ArgAction, Command}; // cSpell:ignore strs
use std::borrow::Cow;
use clap::{builder::ValueParser, Arg, ArgAction, Command};
use std::error::Error;
use std::ffi::OsString;
use std::io::{self, Write}; use std::io::{self, Write};
use uucore::error::{UResult, USimpleError}; use uucore::error::{UResult, USimpleError};
#[cfg(unix)] #[cfg(unix)]
@ -28,19 +31,11 @@ const BUF_SIZE: usize = 16 * 1024;
pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app().try_get_matches_from(args)?; let matches = uu_app().try_get_matches_from(args)?;
let string = if let Some(values) = matches.get_many::<String>("STRING") { let mut buffer = Vec::with_capacity(BUF_SIZE);
let mut result = values.fold(String::new(), |res, s| res + s + " "); args_into_buffer(&mut buffer, matches.get_many::<OsString>("STRING")).unwrap();
result.pop(); prepare_buffer(&mut buffer);
result.push('\n');
Cow::from(result)
} else {
Cow::from("y\n")
};
let mut buffer = [0; BUF_SIZE]; match exec(&buffer) {
let bytes = prepare_buffer(&string, &mut buffer);
match exec(bytes) {
Ok(()) => Ok(()), Ok(()) => Ok(()),
Err(err) if err.kind() == io::ErrorKind::BrokenPipe => Ok(()), Err(err) if err.kind() == io::ErrorKind::BrokenPipe => Ok(()),
Err(err) => Err(USimpleError::new(1, format!("standard output: {err}"))), Err(err) => Err(USimpleError::new(1, format!("standard output: {err}"))),
@ -51,21 +46,73 @@ pub fn uu_app() -> Command {
Command::new(uucore::util_name()) Command::new(uucore::util_name())
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.arg(Arg::new("STRING").action(ArgAction::Append)) .arg(
Arg::new("STRING")
.value_parser(ValueParser::os_string())
.action(ArgAction::Append),
)
.infer_long_args(true) .infer_long_args(true)
} }
fn prepare_buffer<'a>(input: &'a str, buffer: &'a mut [u8; BUF_SIZE]) -> &'a [u8] { // Copies words from `i` into `buf`, separated by spaces.
if input.len() < BUF_SIZE / 2 { fn args_into_buffer<'a>(
let mut size = 0; buf: &mut Vec<u8>,
while size < BUF_SIZE - input.len() { i: Option<impl Iterator<Item = &'a OsString>>,
let (_, right) = buffer.split_at_mut(size); ) -> Result<(), Box<dyn Error>> {
right[..input.len()].copy_from_slice(input.as_bytes()); // TODO: this should be replaced with let/else once available in the MSRV.
size += input.len(); let i = if let Some(i) = i {
} i
&buffer[..size]
} else { } else {
input.as_bytes() buf.extend_from_slice(b"y\n");
return Ok(());
};
// On Unix (and wasi), OsStrs are just &[u8]'s underneath...
#[cfg(any(unix, target_os = "wasi"))]
{
#[cfg(unix)]
use std::os::unix::ffi::OsStrExt;
#[cfg(target_os = "wasi")]
use std::os::wasi::ffi::OsStrExt;
for part in itertools::intersperse(i.map(|a| a.as_bytes()), b" ") {
buf.extend_from_slice(part);
}
}
// But, on Windows, we must hop through a String.
#[cfg(not(any(unix, target_os = "wasi")))]
{
for part in itertools::intersperse(i.map(|a| a.to_str()), Some(" ")) {
let bytes = match part {
Some(part) => part.as_bytes(),
None => return Err("arguments contain invalid UTF-8".into()),
};
buf.extend_from_slice(bytes);
}
}
buf.push(b'\n');
Ok(())
}
// Assumes buf holds a single output line forged from the command line arguments, copies it
// repeatedly until the buffer holds as many copies as it can under BUF_SIZE.
fn prepare_buffer(buf: &mut Vec<u8>) {
if buf.len() * 2 > BUF_SIZE {
return;
}
assert!(!buf.is_empty());
let line_len = buf.len();
let target_size = line_len * (BUF_SIZE / line_len);
while buf.len() < target_size {
let to_copy = std::cmp::min(target_size - buf.len(), buf.len());
debug_assert_eq!(to_copy % line_len, 0);
buf.extend_from_within(..to_copy);
} }
} }
@ -88,3 +135,67 @@ pub fn exec(bytes: &[u8]) -> io::Result<()> {
stdout.write_all(bytes)?; stdout.write_all(bytes)?;
} }
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_prepare_buffer() {
let tests = [
(150, 16350),
(1000, 16000),
(4093, 16372),
(4099, 12297),
(4111, 12333),
(2, 16384),
(3, 16383),
(4, 16384),
(5, 16380),
(8192, 16384),
(8191, 16382),
(8193, 8193),
(10000, 10000),
(15000, 15000),
(25000, 25000),
];
for (line, final_len) in tests {
let mut v = std::iter::repeat(b'a').take(line).collect::<Vec<_>>();
prepare_buffer(&mut v);
assert_eq!(v.len(), final_len);
}
}
#[test]
fn test_args_into_buf() {
{
let mut v = Vec::with_capacity(BUF_SIZE);
args_into_buffer(&mut v, None::<std::slice::Iter<OsString>>).unwrap();
assert_eq!(String::from_utf8(v).unwrap(), "y\n");
}
{
let mut v = Vec::with_capacity(BUF_SIZE);
args_into_buffer(&mut v, Some([OsString::from("foo")].iter())).unwrap();
assert_eq!(String::from_utf8(v).unwrap(), "foo\n");
}
{
let mut v = Vec::with_capacity(BUF_SIZE);
args_into_buffer(
&mut v,
Some(
[
OsString::from("foo"),
OsString::from("bar baz"),
OsString::from("qux"),
]
.iter(),
),
)
.unwrap();
assert_eq!(String::from_utf8(v).unwrap(), "foo bar baz qux\n");
}
}
}

View file

@ -32,7 +32,7 @@ time = { workspace=true, optional=true, features = ["formatting", "local-offset"
data-encoding = { version="2.3", optional=true } data-encoding = { version="2.3", optional=true }
data-encoding-macro = { version="0.1.12", optional=true } data-encoding-macro = { version="0.1.12", optional=true }
z85 = { version="3.0.5", optional=true } z85 = { version="3.0.5", optional=true }
libc = { version="0.2.143", optional=true } libc = { version="0.2.144", optional=true }
once_cell = { workspace=true } once_cell = { workspace=true }
os_display = "0.1.3" os_display = "0.1.3"

View file

@ -1,7 +1,11 @@
// spell-checker:ignore (words) asdf // spell-checker:ignore (words) asdf algo algos
use crate::common::util::TestScenario; use crate::common::util::TestScenario;
const ALGOS: [&str; 11] = [
"sysv", "bsd", "crc", "md5", "sha1", "sha224", "sha256", "sha384", "sha512", "blake2b", "sm3",
];
#[test] #[test]
fn test_invalid_arg() { fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1); new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
@ -12,7 +16,7 @@ fn test_single_file() {
new_ucmd!() new_ucmd!()
.arg("lorem_ipsum.txt") .arg("lorem_ipsum.txt")
.succeeds() .succeeds()
.stdout_is_fixture("single_file.expected"); .stdout_is_fixture("crc_single_file.expected");
} }
#[test] #[test]
@ -21,7 +25,7 @@ fn test_multiple_files() {
.arg("lorem_ipsum.txt") .arg("lorem_ipsum.txt")
.arg("alice_in_wonderland.txt") .arg("alice_in_wonderland.txt")
.succeeds() .succeeds()
.stdout_is_fixture("multiple_files.expected"); .stdout_is_fixture("crc_multiple_files.expected");
} }
#[test] #[test]
@ -29,11 +33,11 @@ fn test_stdin() {
new_ucmd!() new_ucmd!()
.pipe_in_fixture("lorem_ipsum.txt") .pipe_in_fixture("lorem_ipsum.txt")
.succeeds() .succeeds()
.stdout_is_fixture("stdin.expected"); .stdout_is_fixture("crc_stdin.expected");
} }
#[test] #[test]
fn test_empty() { fn test_empty_file() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
at.touch("a"); at.touch("a");
@ -62,25 +66,26 @@ fn test_arg_overrides_stdin() {
} }
#[test] #[test]
fn test_invalid_file() { fn test_nonexisting_file() {
let ts = TestScenario::new(util_name!()); let file_name = "asdf";
let at = ts.fixtures.clone();
let folder_name = "asdf"; new_ucmd!()
.arg(file_name)
// First check when file doesn't exist
ts.ucmd()
.arg(folder_name)
.fails() .fails()
.no_stdout() .no_stdout()
.stderr_contains("cksum: asdf: No such file or directory"); .stderr_contains(format!("cksum: {file_name}: No such file or directory"));
}
// Then check when the file is of an invalid type #[test]
fn test_folder() {
let (at, mut ucmd) = at_and_ucmd!();
let folder_name = "a_folder";
at.mkdir(folder_name); at.mkdir(folder_name);
ts.ucmd()
.arg(folder_name) ucmd.arg(folder_name)
.succeeds() .succeeds()
.stdout_only("4294967295 0 asdf\n"); .stdout_only(format!("4294967295 0 {folder_name}\n"));
} }
// Make sure crc is correct for files larger than 32 bytes // Make sure crc is correct for files larger than 32 bytes
@ -116,77 +121,106 @@ fn test_stdin_larger_than_128_bytes() {
} }
#[test] #[test]
fn test_sha1_single_file() { fn test_algorithm_single_file() {
new_ucmd!() for algo in ALGOS {
.arg("-a=sha1") for option in ["-a", "--algorithm"] {
.arg("lorem_ipsum.txt") new_ucmd!()
.succeeds() .arg(format!("{option}={algo}"))
.stdout_is("ab1dd0bae1d8883a3d18a66de6afbd28252cfbef 772 lorem_ipsum.txt\n"); .arg("lorem_ipsum.txt")
.succeeds()
.stdout_is_fixture(format!("{algo}_single_file.expected"));
}
}
} }
#[test] #[test]
fn test_sm3_single_file() { fn test_algorithm_multiple_files() {
new_ucmd!() for algo in ALGOS {
.arg("-a=sm3") for option in ["-a", "--algorithm"] {
.arg("lorem_ipsum.txt") new_ucmd!()
.succeeds() .arg(format!("{option}={algo}"))
.stdout_is( .arg("lorem_ipsum.txt")
"6d296b805d060bfed22808df308dbb9b4317794dd4ed6740a10770a782699bc2 772 lorem_ipsum.txt\n", .arg("alice_in_wonderland.txt")
); .succeeds()
.stdout_is_fixture(format!("{algo}_multiple_files.expected"));
}
}
} }
#[test] #[test]
fn test_bsd_single_file() { fn test_algorithm_stdin() {
new_ucmd!() for algo in ALGOS {
.arg("-a=bsd") for option in ["-a", "--algorithm"] {
.arg("lorem_ipsum.txt") new_ucmd!()
.succeeds() .arg(format!("{option}={algo}"))
.stdout_only_fixture("bsd_single_file.expected"); .pipe_in_fixture("lorem_ipsum.txt")
.succeeds()
.stdout_is_fixture(format!("{algo}_stdin.expected"));
}
}
} }
#[test] #[test]
fn test_bsd_multiple_files() { fn test_untagged_single_file() {
new_ucmd!() new_ucmd!()
.arg("-a=bsd") .arg("--untagged")
.arg("lorem_ipsum.txt")
.succeeds()
.stdout_is_fixture("untagged/crc_single_file.expected");
}
#[test]
fn test_untagged_multiple_files() {
new_ucmd!()
.arg("--untagged")
.arg("lorem_ipsum.txt") .arg("lorem_ipsum.txt")
.arg("alice_in_wonderland.txt") .arg("alice_in_wonderland.txt")
.succeeds() .succeeds()
.stdout_only_fixture("bsd_multiple_files.expected"); .stdout_is_fixture("untagged/crc_multiple_files.expected");
} }
#[test] #[test]
fn test_bsd_stdin() { fn test_untagged_stdin() {
new_ucmd!() new_ucmd!()
.arg("-a=bsd") .arg("--untagged")
.pipe_in_fixture("lorem_ipsum.txt") .pipe_in_fixture("lorem_ipsum.txt")
.succeeds() .succeeds()
.stdout_only_fixture("bsd_stdin.expected"); .stdout_is_fixture("untagged/crc_stdin.expected");
} }
#[test] #[test]
fn test_sysv_single_file() { fn test_untagged_algorithm_single_file() {
new_ucmd!() for algo in ALGOS {
.arg("-a=sysv") new_ucmd!()
.arg("lorem_ipsum.txt") .arg("--untagged")
.succeeds() .arg(format!("--algorithm={algo}"))
.stdout_only_fixture("sysv_single_file.expected"); .arg("lorem_ipsum.txt")
.succeeds()
.stdout_is_fixture(format!("untagged/{algo}_single_file.expected"));
}
} }
#[test] #[test]
fn test_sysv_multiple_files() { fn test_untagged_algorithm_multiple_files() {
new_ucmd!() for algo in ALGOS {
.arg("-a=sysv") new_ucmd!()
.arg("lorem_ipsum.txt") .arg("--untagged")
.arg("alice_in_wonderland.txt") .arg(format!("--algorithm={algo}"))
.succeeds() .arg("lorem_ipsum.txt")
.stdout_only_fixture("sysv_multiple_files.expected"); .arg("alice_in_wonderland.txt")
.succeeds()
.stdout_is_fixture(format!("untagged/{algo}_multiple_files.expected"));
}
} }
#[test] #[test]
fn test_sysv_stdin() { fn test_untagged_algorithm_stdin() {
new_ucmd!() for algo in ALGOS {
.arg("-a=sysv") new_ucmd!()
.pipe_in_fixture("lorem_ipsum.txt") .arg("--untagged")
.succeeds() .arg(format!("--algorithm={algo}"))
.stdout_only_fixture("sysv_stdin.expected"); .pipe_in_fixture("lorem_ipsum.txt")
.succeeds()
.stdout_is_fixture(format!("untagged/{algo}_stdin.expected"));
}
} }

View file

@ -1075,6 +1075,88 @@ fn test_cp_parents_dest_not_directory() {
.stderr_contains("with --parents, the destination must be a directory"); .stderr_contains("with --parents, the destination must be a directory");
} }
#[test]
fn test_cp_parents_with_permissions_copy_file() {
let (at, mut ucmd) = at_and_ucmd!();
let dir = "dir";
let file = "p1/p2/file";
at.mkdir(dir);
at.mkdir_all("p1/p2");
at.touch(file);
let p1_mode = 0o0777;
let p2_mode = 0o0711;
let file_mode = 0o0702;
#[cfg(unix)]
{
at.set_mode("p1", p1_mode);
at.set_mode("p1/p2", p2_mode);
at.set_mode(file, file_mode);
}
ucmd.arg("-p")
.arg("--parents")
.arg(file)
.arg(dir)
.succeeds();
#[cfg(all(unix, not(target_os = "freebsd")))]
{
let p1_metadata = at.metadata("p1");
let p2_metadata = at.metadata("p1/p2");
let file_metadata = at.metadata(file);
assert_metadata_eq!(p1_metadata, at.metadata("dir/p1"));
assert_metadata_eq!(p2_metadata, at.metadata("dir/p1/p2"));
assert_metadata_eq!(file_metadata, at.metadata("dir/p1/p2/file"));
}
}
#[test]
fn test_cp_parents_with_permissions_copy_dir() {
let (at, mut ucmd) = at_and_ucmd!();
let dir1 = "dir";
let dir2 = "p1/p2";
let file = "p1/p2/file";
at.mkdir(dir1);
at.mkdir_all(dir2);
at.touch(file);
let p1_mode = 0o0777;
let p2_mode = 0o0711;
let file_mode = 0o0702;
#[cfg(unix)]
{
at.set_mode("p1", p1_mode);
at.set_mode("p1/p2", p2_mode);
at.set_mode(file, file_mode);
}
ucmd.arg("-p")
.arg("--parents")
.arg("-r")
.arg(dir2)
.arg(dir1)
.succeeds();
#[cfg(all(unix, not(target_os = "freebsd")))]
{
let p1_metadata = at.metadata("p1");
let p2_metadata = at.metadata("p1/p2");
let file_metadata = at.metadata(file);
assert_metadata_eq!(p1_metadata, at.metadata("dir/p1"));
assert_metadata_eq!(p2_metadata, at.metadata("dir/p1/p2"));
assert_metadata_eq!(file_metadata, at.metadata("dir/p1/p2/file"));
}
}
#[test] #[test]
#[cfg(unix)] #[cfg(unix)]
fn test_cp_writable_special_file_permissions() { fn test_cp_writable_special_file_permissions() {
@ -1581,13 +1663,13 @@ fn test_cp_one_file_system() {
use walkdir::WalkDir; use walkdir::WalkDir;
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
// Test must be run as root (or with `sudo -E`) // Test must be run as root (or with `sudo -E`)
if scene.cmd("whoami").run().stdout_str() != "root\n" { if scene.cmd("whoami").run().stdout_str() != "root\n" {
return; return;
} }
let at = scene.fixtures.clone();
let at_src = AtPath::new(&at.plus(TEST_MOUNT_COPY_FROM_FOLDER)); let at_src = AtPath::new(&at.plus(TEST_MOUNT_COPY_FROM_FOLDER));
let at_dst = AtPath::new(&at.plus(TEST_COPY_TO_FOLDER_NEW)); let at_dst = AtPath::new(&at.plus(TEST_COPY_TO_FOLDER_NEW));

View file

@ -282,6 +282,27 @@ fn test_date_for_invalid_file() {
} }
#[test] #[test]
#[cfg(unix)]
fn test_date_for_no_permission_file() {
let (at, mut ucmd) = at_and_ucmd!();
const FILE: &str = "file-no-perm-1";
use std::os::unix::fs::PermissionsExt;
let file = std::fs::OpenOptions::new()
.create(true)
.write(true)
.open(at.plus(FILE))
.unwrap();
file.set_permissions(std::fs::Permissions::from_mode(0o222))
.unwrap();
let result = ucmd.arg("--file").arg(FILE).fails();
result.no_stdout();
assert_eq!(
result.stderr_str().trim(),
format!("date: {FILE}: Permission denied")
);
}
fn test_date_for_dir_as_file() { fn test_date_for_dir_as_file() {
let result = new_ucmd!().arg("--file").arg("/").fails(); let result = new_ucmd!().arg("--file").arg("/").fails();
result.no_stdout(); result.no_stdout();

View file

@ -1536,3 +1536,29 @@ fn test_multiple_processes_reading_stdin() {
.succeeds() .succeeds()
.stdout_only("def\n"); .stdout_only("def\n");
} }
/// Test that discarding system file cache fails for stdin.
#[test]
#[cfg(target_os = "linux")]
fn test_nocache_stdin_error() {
#[cfg(not(target_env = "musl"))]
let detail = "Illegal seek";
#[cfg(target_env = "musl")]
let detail = "Invalid seek";
new_ucmd!()
.args(&["iflag=nocache", "count=0", "status=noxfer"])
.fails()
.code_is(1)
.stderr_only(format!("dd: failed to discard cache for: 'standard input': {detail}\n0+0 records in\n0+0 records out\n"));
}
/// Test for discarding system file cache.
#[test]
#[cfg(target_os = "linux")]
fn test_nocache_file() {
let (at, mut ucmd) = at_and_ucmd!();
at.write_bytes("f", b"a".repeat(1 << 20).as_slice());
ucmd.args(&["if=f", "of=/dev/null", "iflag=nocache", "status=noxfer"])
.succeeds()
.stderr_only("2048+0 records in\n2048+0 records out\n");
}

View file

@ -7,6 +7,10 @@ use crate::common::util::TestScenario;
use nix::unistd::{close, dup}; use nix::unistd::{close, dup};
use regex::Regex; use regex::Regex;
use std::collections::HashMap; use std::collections::HashMap;
#[cfg(target_os = "linux")]
use std::ffi::OsStr;
#[cfg(target_os = "linux")]
use std::os::unix::ffi::OsStrExt;
#[cfg(all(unix, feature = "chmod"))] #[cfg(all(unix, feature = "chmod"))]
use std::os::unix::io::IntoRawFd; use std::os::unix::io::IntoRawFd;
use std::path::Path; use std::path::Path;
@ -1239,7 +1243,7 @@ fn test_ls_long_total_size() {
("long_si", "total 8.2k"), ("long_si", "total 8.2k"),
] ]
.iter() .iter()
.cloned() .copied()
.collect() .collect()
} else { } else {
[ [
@ -1248,7 +1252,7 @@ fn test_ls_long_total_size() {
("long_si", "total 2"), ("long_si", "total 2"),
] ]
.iter() .iter()
.cloned() .copied()
.collect() .collect()
}; };
@ -3393,3 +3397,54 @@ fn test_tabsize_formatting() {
.succeeds() .succeeds()
.stdout_is("aaaaaaaa bbbb\ncccc dddddddd"); .stdout_is("aaaaaaaa bbbb\ncccc dddddddd");
} }
#[cfg(any(
target_os = "linux",
target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd",
target_os = "illumos",
target_os = "solaris"
))]
#[test]
fn test_device_number() {
use std::fs::{metadata, read_dir};
use std::os::unix::fs::{FileTypeExt, MetadataExt};
use uucore::libc::{dev_t, major, minor};
let dev_dir = read_dir("/dev").unwrap();
// let's use the first device for test
let blk_dev = dev_dir
.map(|res_entry| res_entry.unwrap())
.find(|entry| {
entry.file_type().unwrap().is_block_device()
|| entry.file_type().unwrap().is_char_device()
})
.expect("Expect a block/char device");
let blk_dev_path = blk_dev.path();
let blk_dev_meta = metadata(blk_dev_path.as_path()).unwrap();
let blk_dev_number = blk_dev_meta.rdev() as dev_t;
let (major, minor) = unsafe { (major(blk_dev_number), minor(blk_dev_number)) };
let major_minor_str = format!("{}, {}", major, minor);
let scene = TestScenario::new(util_name!());
scene
.ucmd()
.arg("-l")
.arg(blk_dev_path.to_str().expect("should be UTF-8 encoded"))
.succeeds()
.stdout_contains(major_minor_str);
}
#[test]
#[cfg(target_os = "linux")]
fn test_invalid_utf8() {
let (at, mut ucmd) = at_and_ucmd!();
let filename = OsStr::from_bytes(b"-\xE0-foo");
at.touch(filename);
ucmd.succeeds();
}

View file

@ -27,7 +27,7 @@ fn test_deleted_dir() {
use std::process::Command; use std::process::Command;
let ts = TestScenario::new(util_name!()); let ts = TestScenario::new(util_name!());
let at = ts.fixtures.clone(); let at = ts.fixtures;
let output = Command::new("sh") let output = Command::new("sh")
.arg("-c") .arg("-c")
.arg(format!( .arg(format!(

View file

@ -118,9 +118,10 @@ mod linux_only {
use std::os::unix::io::FromRawFd; use std::os::unix::io::FromRawFd;
let mut fds: [c_int; 2] = [0, 0]; let mut fds: [c_int; 2] = [0, 0];
if unsafe { libc::pipe(&mut fds as *mut c_int) } != 0 { assert!(
panic!("Failed to create pipe"); (unsafe { libc::pipe(&mut fds as *mut c_int) } == 0),
} "Failed to create pipe"
);
// Drop the read end of the pipe // Drop the read end of the pipe
let _ = unsafe { File::from_raw_fd(fds[0]) }; let _ = unsafe { File::from_raw_fd(fds[0]) };

View file

@ -1,3 +1,4 @@
use std::ffi::OsStr;
use std::process::{ExitStatus, Stdio}; use std::process::{ExitStatus, Stdio};
#[cfg(unix)] #[cfg(unix)]
@ -6,24 +7,26 @@ use std::os::unix::process::ExitStatusExt;
use crate::common::util::TestScenario; use crate::common::util::TestScenario;
#[cfg(unix)] #[cfg(unix)]
fn check_termination(result: &ExitStatus) { fn check_termination(result: ExitStatus) {
assert_eq!(result.signal(), Some(libc::SIGPIPE)); assert_eq!(result.signal(), Some(libc::SIGPIPE));
} }
#[cfg(not(unix))] #[cfg(not(unix))]
fn check_termination(result: &ExitStatus) { fn check_termination(result: ExitStatus) {
assert!(result.success(), "yes did not exit successfully"); assert!(result.success(), "yes did not exit successfully");
} }
const NO_ARGS: &[&str] = &[];
/// Run `yes`, capture some of the output, close the pipe, and verify it. /// Run `yes`, capture some of the output, close the pipe, and verify it.
fn run(args: &[&str], expected: &[u8]) { fn run(args: &[impl AsRef<OsStr>], expected: &[u8]) {
let mut cmd = new_ucmd!(); let mut cmd = new_ucmd!();
let mut child = cmd.args(args).set_stdout(Stdio::piped()).run_no_wait(); let mut child = cmd.args(args).set_stdout(Stdio::piped()).run_no_wait();
let buf = child.stdout_exact_bytes(expected.len()); let buf = child.stdout_exact_bytes(expected.len());
child.close_stdout(); child.close_stdout();
#[allow(deprecated)] #[allow(deprecated)]
check_termination(&child.wait_with_output().unwrap().status); check_termination(child.wait_with_output().unwrap().status);
assert_eq!(buf.as_slice(), expected); assert_eq!(buf.as_slice(), expected);
} }
@ -34,7 +37,7 @@ fn test_invalid_arg() {
#[test] #[test]
fn test_simple() { fn test_simple() {
run(&[], b"y\ny\ny\ny\n"); run(NO_ARGS, b"y\ny\ny\ny\n");
} }
#[test] #[test]
@ -44,7 +47,7 @@ fn test_args() {
#[test] #[test]
fn test_long_output() { fn test_long_output() {
run(&[], "y\n".repeat(512 * 1024).as_bytes()); run(NO_ARGS, "y\n".repeat(512 * 1024).as_bytes());
} }
/// Test with an output that seems likely to get mangled in case of incomplete writes. /// Test with an output that seems likely to get mangled in case of incomplete writes.
@ -88,3 +91,20 @@ fn test_piped_to_dev_full() {
} }
} }
} }
#[test]
#[cfg(any(unix, target_os = "wasi"))]
fn test_non_utf8() {
#[cfg(unix)]
use std::os::unix::ffi::OsStrExt;
#[cfg(target_os = "wasi")]
use std::os::wasi::ffi::OsStrExt;
run(
&[
OsStr::from_bytes(b"\xbf\xff\xee"),
OsStr::from_bytes(b"bar"),
],
&b"\xbf\xff\xee bar\n".repeat(5000),
);
}

View file

@ -2016,7 +2016,7 @@ impl UChild {
/// Read, consume and return the output as [`String`] from [`Child`]'s stdout. /// Read, consume and return the output as [`String`] from [`Child`]'s stdout.
/// ///
/// See also [`UChild::stdout_bytes] for side effects. /// See also [`UChild::stdout_bytes`] for side effects.
pub fn stdout(&mut self) -> String { pub fn stdout(&mut self) -> String {
String::from_utf8(self.stdout_bytes()).unwrap() String::from_utf8(self.stdout_bytes()).unwrap()
} }

View file

@ -0,0 +1,2 @@
BLAKE2b (lorem_ipsum.txt) = 0e97a09189e560c3789c0bff1f020166861ef857d1fbfe4574de1842e3c06cabb9575e4af6309a166158c2b408d3c038c1b49d828b35158142cdc0396d1195c3
BLAKE2b (alice_in_wonderland.txt) = 91b8b0f0868e905ad18b8ac35e4a1dacd289857b19258ab5d1e071761af758b0134ec152d4f011fe1825ca889c80c2e072ca70eb50548c25fc49a98937515af4

View file

@ -0,0 +1 @@
BLAKE2b (lorem_ipsum.txt) = 0e97a09189e560c3789c0bff1f020166861ef857d1fbfe4574de1842e3c06cabb9575e4af6309a166158c2b408d3c038c1b49d828b35158142cdc0396d1195c3

View file

@ -0,0 +1 @@
BLAKE2b (-) = 0e97a09189e560c3789c0bff1f020166861ef857d1fbfe4574de1842e3c06cabb9575e4af6309a166158c2b408d3c038c1b49d828b35158142cdc0396d1195c3

View file

@ -0,0 +1,2 @@
MD5 (lorem_ipsum.txt) = cd724690f7dc61775dfac400a71f2caa
MD5 (alice_in_wonderland.txt) = f6fa7033e16166a9589aa1c0388ffd58

View file

@ -0,0 +1 @@
MD5 (lorem_ipsum.txt) = cd724690f7dc61775dfac400a71f2caa

View file

@ -0,0 +1 @@
MD5 (-) = cd724690f7dc61775dfac400a71f2caa

View file

@ -0,0 +1,2 @@
SHA1 (lorem_ipsum.txt) = ab1dd0bae1d8883a3d18a66de6afbd28252cfbef
SHA1 (alice_in_wonderland.txt) = 22b54b2520e8b4fa59eb10719028a4e587c12d1e

View file

@ -0,0 +1 @@
SHA1 (lorem_ipsum.txt) = ab1dd0bae1d8883a3d18a66de6afbd28252cfbef

View file

@ -0,0 +1 @@
SHA1 (-) = ab1dd0bae1d8883a3d18a66de6afbd28252cfbef

View file

@ -0,0 +1,2 @@
SHA224 (lorem_ipsum.txt) = 3de66fbcad106e1b40ab391be56c51d2007eb1f9c655d0f4e29bfc01
SHA224 (alice_in_wonderland.txt) = 54c9c7d78458886418ce0845111fc49fe1c628ffd4bf3da14226ffd9

View file

@ -0,0 +1 @@
SHA224 (lorem_ipsum.txt) = 3de66fbcad106e1b40ab391be56c51d2007eb1f9c655d0f4e29bfc01

View file

@ -0,0 +1 @@
SHA224 (-) = 3de66fbcad106e1b40ab391be56c51d2007eb1f9c655d0f4e29bfc01

View file

@ -0,0 +1,2 @@
SHA256 (lorem_ipsum.txt) = f7c420501c50e00b309250100d67ea5e910981536b4582fe9c435bd92b3f1f02
SHA256 (alice_in_wonderland.txt) = 14ab7e5a0aa3a670222744714bc96961d51012cb216225d965db71824a46e5fe

View file

@ -0,0 +1 @@
SHA256 (lorem_ipsum.txt) = f7c420501c50e00b309250100d67ea5e910981536b4582fe9c435bd92b3f1f02

View file

@ -0,0 +1 @@
SHA256 (-) = f7c420501c50e00b309250100d67ea5e910981536b4582fe9c435bd92b3f1f02

View file

@ -0,0 +1,2 @@
SHA384 (lorem_ipsum.txt) = 4be4b90a0d0d32966992921019f24abc824dcfb8b1c408102f1f6788fb80ba9a9a4c5a7b575a3353a90a8ee719481dcb
SHA384 (alice_in_wonderland.txt) = b7966c97ef84ab5858db2e0cdd33fbaf4fa8346d84de65aba001e738c242598a43272854d0073ad1099404eaa1d93766

View file

@ -0,0 +1 @@
SHA384 (lorem_ipsum.txt) = 4be4b90a0d0d32966992921019f24abc824dcfb8b1c408102f1f6788fb80ba9a9a4c5a7b575a3353a90a8ee719481dcb

View file

@ -0,0 +1 @@
SHA384 (-) = 4be4b90a0d0d32966992921019f24abc824dcfb8b1c408102f1f6788fb80ba9a9a4c5a7b575a3353a90a8ee719481dcb

View file

@ -0,0 +1,2 @@
SHA512 (lorem_ipsum.txt) = 965464ab2556aad58ebc73d89ad221e559797529ecafc0f466c11795cff6d6e2c60f96a07c542cfd1f426e5e4fe0a48aa15667ba44096b213d0813cd038dfa05
SHA512 (alice_in_wonderland.txt) = 251646d5a7eb481e0f3aced7839d78dd5e97153f822dc55938e17059c485990d85d602e2881b528b565ab6262584a69c97b068b26bda81acc9356c53c7c1c96d

View file

@ -0,0 +1 @@
SHA512 (lorem_ipsum.txt) = 965464ab2556aad58ebc73d89ad221e559797529ecafc0f466c11795cff6d6e2c60f96a07c542cfd1f426e5e4fe0a48aa15667ba44096b213d0813cd038dfa05

View file

@ -0,0 +1 @@
SHA512 (-) = 965464ab2556aad58ebc73d89ad221e559797529ecafc0f466c11795cff6d6e2c60f96a07c542cfd1f426e5e4fe0a48aa15667ba44096b213d0813cd038dfa05

View file

@ -0,0 +1,2 @@
SM3 (lorem_ipsum.txt) = 6d296b805d060bfed22808df308dbb9b4317794dd4ed6740a10770a782699bc2
SM3 (alice_in_wonderland.txt) = d66617ae3c4e87828298dcd836f79efbab488c53b84e09c3e8e83a16c902418d

View file

@ -0,0 +1 @@
SM3 (lorem_ipsum.txt) = 6d296b805d060bfed22808df308dbb9b4317794dd4ed6740a10770a782699bc2

View file

@ -0,0 +1 @@
SM3 (-) = 6d296b805d060bfed22808df308dbb9b4317794dd4ed6740a10770a782699bc2

View file

@ -0,0 +1,2 @@
0e97a09189e560c3789c0bff1f020166861ef857d1fbfe4574de1842e3c06cabb9575e4af6309a166158c2b408d3c038c1b49d828b35158142cdc0396d1195c3 lorem_ipsum.txt
91b8b0f0868e905ad18b8ac35e4a1dacd289857b19258ab5d1e071761af758b0134ec152d4f011fe1825ca889c80c2e072ca70eb50548c25fc49a98937515af4 alice_in_wonderland.txt

View file

@ -0,0 +1 @@
0e97a09189e560c3789c0bff1f020166861ef857d1fbfe4574de1842e3c06cabb9575e4af6309a166158c2b408d3c038c1b49d828b35158142cdc0396d1195c3 lorem_ipsum.txt

View file

@ -0,0 +1 @@
0e97a09189e560c3789c0bff1f020166861ef857d1fbfe4574de1842e3c06cabb9575e4af6309a166158c2b408d3c038c1b49d828b35158142cdc0396d1195c3 -

View file

@ -0,0 +1,2 @@
08109 1 lorem_ipsum.txt
01814 1 alice_in_wonderland.txt

View file

@ -0,0 +1 @@
08109 1 lorem_ipsum.txt

View file

@ -0,0 +1 @@
08109 1

View file

@ -0,0 +1,2 @@
378294376 772 lorem_ipsum.txt
3805907707 302 alice_in_wonderland.txt

View file

@ -0,0 +1 @@
378294376 772 lorem_ipsum.txt

View file

@ -0,0 +1 @@
378294376 772

View file

@ -0,0 +1,2 @@
cd724690f7dc61775dfac400a71f2caa lorem_ipsum.txt
f6fa7033e16166a9589aa1c0388ffd58 alice_in_wonderland.txt

View file

@ -0,0 +1 @@
cd724690f7dc61775dfac400a71f2caa lorem_ipsum.txt

View file

@ -0,0 +1 @@
cd724690f7dc61775dfac400a71f2caa -

View file

@ -0,0 +1,2 @@
ab1dd0bae1d8883a3d18a66de6afbd28252cfbef lorem_ipsum.txt
22b54b2520e8b4fa59eb10719028a4e587c12d1e alice_in_wonderland.txt

View file

@ -0,0 +1 @@
ab1dd0bae1d8883a3d18a66de6afbd28252cfbef lorem_ipsum.txt

View file

@ -0,0 +1 @@
ab1dd0bae1d8883a3d18a66de6afbd28252cfbef -

View file

@ -0,0 +1,2 @@
3de66fbcad106e1b40ab391be56c51d2007eb1f9c655d0f4e29bfc01 lorem_ipsum.txt
54c9c7d78458886418ce0845111fc49fe1c628ffd4bf3da14226ffd9 alice_in_wonderland.txt

View file

@ -0,0 +1 @@
3de66fbcad106e1b40ab391be56c51d2007eb1f9c655d0f4e29bfc01 lorem_ipsum.txt

View file

@ -0,0 +1 @@
3de66fbcad106e1b40ab391be56c51d2007eb1f9c655d0f4e29bfc01 -

View file

@ -0,0 +1,2 @@
f7c420501c50e00b309250100d67ea5e910981536b4582fe9c435bd92b3f1f02 lorem_ipsum.txt
14ab7e5a0aa3a670222744714bc96961d51012cb216225d965db71824a46e5fe alice_in_wonderland.txt

View file

@ -0,0 +1 @@
f7c420501c50e00b309250100d67ea5e910981536b4582fe9c435bd92b3f1f02 lorem_ipsum.txt

View file

@ -0,0 +1 @@
f7c420501c50e00b309250100d67ea5e910981536b4582fe9c435bd92b3f1f02 -

View file

@ -0,0 +1,2 @@
4be4b90a0d0d32966992921019f24abc824dcfb8b1c408102f1f6788fb80ba9a9a4c5a7b575a3353a90a8ee719481dcb lorem_ipsum.txt
b7966c97ef84ab5858db2e0cdd33fbaf4fa8346d84de65aba001e738c242598a43272854d0073ad1099404eaa1d93766 alice_in_wonderland.txt

View file

@ -0,0 +1 @@
4be4b90a0d0d32966992921019f24abc824dcfb8b1c408102f1f6788fb80ba9a9a4c5a7b575a3353a90a8ee719481dcb lorem_ipsum.txt

View file

@ -0,0 +1 @@
4be4b90a0d0d32966992921019f24abc824dcfb8b1c408102f1f6788fb80ba9a9a4c5a7b575a3353a90a8ee719481dcb -

View file

@ -0,0 +1,2 @@
965464ab2556aad58ebc73d89ad221e559797529ecafc0f466c11795cff6d6e2c60f96a07c542cfd1f426e5e4fe0a48aa15667ba44096b213d0813cd038dfa05 lorem_ipsum.txt
251646d5a7eb481e0f3aced7839d78dd5e97153f822dc55938e17059c485990d85d602e2881b528b565ab6262584a69c97b068b26bda81acc9356c53c7c1c96d alice_in_wonderland.txt

View file

@ -0,0 +1 @@
965464ab2556aad58ebc73d89ad221e559797529ecafc0f466c11795cff6d6e2c60f96a07c542cfd1f426e5e4fe0a48aa15667ba44096b213d0813cd038dfa05 lorem_ipsum.txt

View file

@ -0,0 +1 @@
965464ab2556aad58ebc73d89ad221e559797529ecafc0f466c11795cff6d6e2c60f96a07c542cfd1f426e5e4fe0a48aa15667ba44096b213d0813cd038dfa05 -

View file

@ -0,0 +1,2 @@
6d296b805d060bfed22808df308dbb9b4317794dd4ed6740a10770a782699bc2 lorem_ipsum.txt
d66617ae3c4e87828298dcd836f79efbab488c53b84e09c3e8e83a16c902418d alice_in_wonderland.txt

View file

@ -0,0 +1 @@
6d296b805d060bfed22808df308dbb9b4317794dd4ed6740a10770a782699bc2 lorem_ipsum.txt

View file

@ -0,0 +1 @@
6d296b805d060bfed22808df308dbb9b4317794dd4ed6740a10770a782699bc2 -

View file

@ -0,0 +1,2 @@
6985 2 lorem_ipsum.txt
27441 1 alice_in_wonderland.txt

View file

@ -0,0 +1 @@
6985 2 lorem_ipsum.txt

View file

@ -0,0 +1 @@
6985 2

View file

@ -19,7 +19,8 @@ urllib.request.urlretrieve(
types = ("/*/*.sh", "/*/*.pl", "/*/*.xpl") types = ("/*/*.sh", "/*/*.pl", "/*/*.xpl")
tests = [] tests = []
error_or_skip_tests = [] error_tests = []
skip_tests = []
for files in types: for files in types:
tests.extend(glob.glob(base + files)) tests.extend(glob.glob(base + files))
@ -58,14 +59,23 @@ for d in data:
print("Could not find test '%s'. Maybe update the GNU repo?" % a) print("Could not find test '%s'. Maybe update the GNU repo?" % a)
sys.exit(1) sys.exit(1)
# if it is SKIP or ERROR, show it # if it is SKIP, show it
if data[d][e] in ("SKIP", "ERROR"): if data[d][e] == "SKIP":
list_of_files.remove(a) list_of_files.remove(a)
error_or_skip_tests.append(a) skip_tests.append(a)
# if it is ERROR, show it
if data[d][e] == "ERROR":
list_of_files.remove(a)
error_tests.append(a)
print("SKIP and ERROR tests:") print("===============")
show_list(error_or_skip_tests) print("SKIP tests:")
show_list(skip_tests)
print("")
print("===============")
print("ERROR tests:")
show_list(error_tests)
print("") print("")
print("===============") print("===============")
print("FAIL tests:") print("FAIL tests:")

98
util/why-skip.txt Normal file
View file

@ -0,0 +1,98 @@
# spell-checker:ignore epipe readdir restorecon SIGALRM capget bigtime rootfs enotsup
= trapping SIGPIPE is not supported =
tests/tail-2/pipe-f.sh
tests/misc/seq-epipe.sh
tests/misc/printf-surprise.sh
tests/misc/env-signal-handler.sh
= skipped test: breakpoint not hit =
tests/tail-2/inotify-race2.sh
tail-2/inotify-race.sh
= internal test failure: maybe LD_PRELOAD doesn't work? =
tests/rm/rm-readdir-fail.sh
tests/rm/r-root.sh
tests/df/skip-duplicates.sh
tests/df/no-mtab-status.sh
= LD_PRELOAD was ineffective? =
tests/cp/nfs-removal-race.sh
= failed to create hfs file system =
tests/mv/hardlink-case.sh
= temporarily disabled =
tests/mkdir/writable-under-readonly.sh
= this system lacks SMACK support =
tests/mkdir/smack-root.sh
tests/mkdir/smack-no-root.sh
tests/id/smack.sh
= this system lacks SELinux support =
tests/mkdir/selinux.sh
tests/mkdir/restorecon.sh
tests/misc/selinux.sh
tests/misc/chcon.sh
tests/install/install-Z-selinux.sh
tests/install/install-C-selinux.sh
tests/id/no-context.sh
tests/id/context.sh
tests/cp/no-ctx.sh
tests/cp/cp-a-selinux.sh
= failed to set xattr of file =
tests/misc/xattr.sh
= timeout returned 142. SIGALRM not handled? =
tests/misc/timeout-group.sh
= FULL_PARTITION_TMPDIR not defined =
tests/misc/tac-continue.sh
= can't get window size =
tests/misc/stty-row-col.sh
= The Swedish locale with blank thousands separator is unavailable. =
tests/misc/sort-h-thousands-sep.sh
= this shell lacks ulimit support =
tests/misc/csplit-heap.sh
= multicall binary is disabled =
tests/misc/coreutils.sh
= your ls doesn't call capget =
tests/ls/no-cap.sh
= not running on GNU/Hurd =
tests/id/gnu-zero-uids.sh
= file system cannot represent big timestamps =
tests/du/bigtime.sh
= no rootfs in mtab =
tests/df/skip-rootfs.sh
= insufficient mount/ext2 support =
tests/df/problematic-chars.sh
tests/cp/cp-mv-enotsup-xattr.sh
= 512 byte aligned O_DIRECT is not supported on this (file) system =
tests/dd/direct.sh
= skipped test: /usr/bin/touch -m -d '1998-01-15 23:00' didn't work =
tests/misc/ls-time.sh
= requires controlling input terminal =
tests/misc/stty-pairs.sh
tests/misc/stty.sh
tests/misc/stty-invalid.sh
= insufficient SEEK_DATA support =
tests/cp/sparse-perf.sh
tests/cp/sparse-extents.sh
tests/cp/sparse-extents-2.sh
tests/cp/sparse-2.sh