diff --git a/.github/workflows/CI-linux.yml b/.github/workflows/CI-linux.yml index be292e3..8f5b4e1 100644 --- a/.github/workflows/CI-linux.yml +++ b/.github/workflows/CI-linux.yml @@ -43,6 +43,7 @@ on: env: DEBIAN_FRONTEND: noninteractive RUSTFLAGS: "-Dwarnings" + WITH_MIRI: ${{ inputs.rust-toolchain-name == 'nightly' && inputs.flavor == 'dev' && inputs.builder-target != 'riscv64' }} SRC_DIR: ${{ github.workspace }}/rawspeed.rs CODECOV_TOKEN_EXISTS: ${{ secrets.CODECOV_TOKEN != '' }} CODE_COVERAGE_SUPPORTED: ${{ inputs.flavor != 'RustFmt' && inputs.flavor != 'doc' && (inputs.target-os != 'windows' || inputs.rust-toolchain-abi == 'msvc') }} @@ -61,6 +62,8 @@ jobs: timeout-minutes: 1 run: | set -xe + WITH_CODE_COVERAGE=${{ env.CODE_COVERAGE_SUPPORTED == 'true' && (inputs.builder-host == inputs.builder-target || (env.ENDIANNESS == 'big' && inputs.builder-target != 's390x')) && (github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true') }} + echo "WITH_CODE_COVERAGE=$(echo ${WITH_CODE_COVERAGE})" >> $GITHUB_ENV if [ "${{ inputs.builder-target }}" = "x86_64" ] \ || [ "${{ inputs.builder-target }}" = "aarch64" ] \ || [ "${{ inputs.builder-target }}" = "i686" ] \ @@ -271,32 +274,53 @@ jobs: eatmydata apt install ${{ env.PACKAGES }} eatmydata apt clean rm -rf /var/lib/apt/lists/* - - name: Install Rust toolchain and targets - timeout-minutes: 1 + - name: Install Rust toolchain and targets and crates + timeout-minutes: 4 run: | set -xe + RUST_COMPONENTS="" + RUST_CRATES="" eatmydata curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y . "$HOME/.cargo/env" eatmydata rustup toolchain install ${{ inputs.rust-toolchain-name }} --allow-downgrade --profile minimal eatmydata rustup default ${{ inputs.rust-toolchain-name }} eatmydata rustup target add ${{ env.RUST_TARGET }} if [ "${{ inputs.flavor }}" = "RustFmt" ]; then - eatmydata rustup component add rustfmt + RUST_COMPONENTS="${RUST_COMPONENTS} \ + rustfmt \ + " elif [ "${{ inputs.flavor }}" = "doc" ]; then /bin/true elif [ "${{ inputs.flavor }}" = "dev" ] || [ "${{ inputs.flavor }}" = "release" ]; then - eatmydata rustup component add clippy + RUST_COMPONENTS="${RUST_COMPONENTS} \ + clippy \ + " else exit 1 fi - - name: Install necessary Rust packages for code coverage - if: env.CODE_COVERAGE_SUPPORTED == 'true' && (inputs.builder-host == inputs.builder-target || (env.ENDIANNESS == 'big' && inputs.builder-target != 's390x')) && (github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true') - timeout-minutes: 2 - run: | - set -xe - . "$HOME/.cargo/env" - eatmydata rustup component add llvm-tools-preview - eatmydata cargo install cargo-llvm-cov + if [ "${{ env.WITH_CODE_COVERAGE }}" = "true" ]; then + RUST_COMPONENTS="${RUST_COMPONENTS} \ + llvm-tools-preview \ + " + RUST_CRATES="${RUST_CRATES} \ + cargo-llvm-cov \ + " + fi + if [ "${{ env.WITH_MIRI }}" = "true" ]; then + RUST_COMPONENTS="${RUST_COMPONENTS} \ + rust-src \ + miri \ + " + RUST_CRATES="${RUST_CRATES} \ + cargo-nextest \ + " + fi + if [ "${RUST_COMPONENTS}" != "" ]; then + eatmydata rustup component add ${RUST_COMPONENTS} + fi + if [ "${RUST_CRATES}" != "" ]; then + eatmydata cargo install ${RUST_CRATES} + fi - name: Fetch/Checkout msvc-wine git repo timeout-minutes: 1 if: inputs.target-os == 'windows' && inputs.rust-toolchain-abi == 'msvc' @@ -400,7 +424,7 @@ jobs: cargo test --target ${{ env.RUST_TARGET }} --profile ${{ inputs.flavor }} - name: Run tests to collect code coverage timeout-minutes: 2 - if: env.CODE_COVERAGE_SUPPORTED == 'true' && (inputs.builder-host == inputs.builder-target || (env.ENDIANNESS == 'big' && inputs.builder-target != 's390x')) && (github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true') + if: env.WITH_CODE_COVERAGE == 'true' env: RUSTFLAGS: "-C instrument-coverage" run: | @@ -411,7 +435,7 @@ jobs: cargo llvm-cov --no-report --target ${{ env.RUST_TARGET }} --profile ${{ inputs.flavor }} - name: Aggregate code coverage timeout-minutes: 1 - if: env.CODE_COVERAGE_SUPPORTED == 'true' && (inputs.builder-host == inputs.builder-target || (env.ENDIANNESS == 'big' && inputs.builder-target != 's390x')) && (github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true') + if: env.WITH_CODE_COVERAGE == 'true' run: | set -xe . "$HOME/.cargo/env" @@ -419,7 +443,7 @@ jobs: cargo llvm-cov report --codecov --output-path $SRC_DIR/codecov.json --target ${{ env.RUST_TARGET }} --profile ${{ inputs.flavor }} - name: Upload coverage reports to Codecov timeout-minutes: 1 - if: env.CODE_COVERAGE_SUPPORTED == 'true' && (inputs.builder-host == inputs.builder-target || (env.ENDIANNESS == 'big' && inputs.builder-target != 's390x')) && (github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true') + if: env.WITH_CODE_COVERAGE == 'true' uses: codecov/codecov-action@v5 env: OS: ${{ inputs.os }} @@ -435,6 +459,14 @@ jobs: files: ${{ env.SRC_DIR }}/codecov.json root_dir: ${{ env.SRC_DIR }} fail_ci_if_error: true + - name: Run tests under Miri + timeout-minutes: 10 + if: env.WITH_MIRI == 'true' + run: | + set -xe + . "$HOME/.cargo/env" + cd "$SRC_DIR" + cargo miri nextest run --target ${{ env.RUST_TARGET }} - name: Build docs timeout-minutes: 1 if: inputs.flavor == 'doc' diff --git a/.github/workflows/CI-macOS.yml b/.github/workflows/CI-macOS.yml index 5d12c3a..d62c189 100644 --- a/.github/workflows/CI-macOS.yml +++ b/.github/workflows/CI-macOS.yml @@ -38,6 +38,12 @@ jobs: name: ${{ inputs.runs-on }}, XCode ${{ inputs.xcode-version }}, Rust ${{ inputs.rust-toolchain-name }}, profile ${{ inputs.flavor }} runs-on: ${{ inputs.runs-on }} steps: + - name: Configure necessary env variables + timeout-minutes: 1 + run: | + set -xe + WITH_CODE_COVERAGE=${{ github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true' }} + echo "WITH_CODE_COVERAGE=$(echo ${WITH_CODE_COVERAGE})" >> $GITHUB_ENV - name: Fetch/Checkout RawSpeed.RS git repo timeout-minutes: 1 uses: actions/checkout@v4 @@ -54,21 +60,29 @@ jobs: brew autoremove --quiet brew cleanup --quiet --prune=all - name: Install Rust - timeout-minutes: 1 + timeout-minutes: 4 run: | set -xe curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y rustup toolchain install ${{ inputs.rust-toolchain-name }} --allow-downgrade --profile minimal rustup default ${{ inputs.rust-toolchain-name }} - rustup component add clippy - - name: Install necessary packages for code coverage - if: github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true' - timeout-minutes: 3 - run: | - set -xe - . "$HOME/.cargo/env" - rustup component add llvm-tools-preview - cargo install cargo-llvm-cov + RUST_COMPONENTS="${RUST_COMPONENTS} \ + clippy \ + " + if [ "${{ env.WITH_CODE_COVERAGE }}" = "true" ]; then + RUST_COMPONENTS="${RUST_COMPONENTS} \ + llvm-tools-preview \ + " + RUST_CRATES="${RUST_CRATES} \ + cargo-llvm-cov \ + " + fi + if [ "${RUST_COMPONENTS}" != "" ]; then + rustup component add ${RUST_COMPONENTS} + fi + if [ "${RUST_CRATES}" != "" ]; then + cargo install ${RUST_CRATES} + fi - name: Run cargo check timeout-minutes: 1 run: | @@ -99,7 +113,7 @@ jobs: cargo test --profile ${{ inputs.flavor }} - name: Run tests to collect code coverage timeout-minutes: 1 - if: github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true' + if: env.WITH_CODE_COVERAGE == 'true' env: RUSTFLAGS: "-C instrument-coverage" run: | @@ -110,7 +124,7 @@ jobs: cargo llvm-cov --no-report --profile ${{ inputs.flavor }} - name: Aggregate code coverage timeout-minutes: 1 - if: github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true' + if: env.WITH_CODE_COVERAGE == 'true' run: | set -xe . "$HOME/.cargo/env" @@ -118,7 +132,7 @@ jobs: cargo llvm-cov report --codecov --output-path $SRC_DIR/codecov.json --profile ${{ inputs.flavor }} - name: Upload coverage reports to Codecov timeout-minutes: 1 - if: github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true' + if: env.WITH_CODE_COVERAGE == 'true' uses: codecov/codecov-action@v5 env: OS: ${{ inputs.os }} diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4effafb..dbb651a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,18 +11,56 @@ concurrency: cancel-in-progress: true jobs: - linux-fast: + linux-fast-native: strategy: fail-fast: false matrix: os: [ linux ] stack: - - { runs-on: "ubuntu-latest", host: "x86_64", target: "x86_64", vendor: "unknown", os: "linux", abi: "gnu" } - - { runs-on: "ubuntu-24.04-arm", host: "aarch64", target: "aarch64", vendor: "unknown", os: "linux", abi: "gnu" } + - { runs-on: "ubuntu-latest", host: "x86_64", target: "x86_64", vendor: "unknown", os: "linux", abi: "gnu" } + - { runs-on: "ubuntu-24.04-arm", host: "aarch64", target: "aarch64", vendor: "unknown", os: "linux", abi: "gnu" } + - { runs-on: "ubuntu-latest", host: "x86_64", target: "i686", vendor: "unknown", os: "linux", abi: "gnu" } + distro: + - { image: "debian:trixie-slim", LLVM: 19 } + rust-toolchain-name: [ stable, nightly ] + flavor: [ dev, release ] + exclude: + - rust-toolchain-name: nightly + flavor: dev + uses: ./.github/workflows/CI-linux.yml + with: + os: ${{ matrix.os }} + runs-on: ${{ matrix.stack.runs-on }} + builder-host: ${{ matrix.stack.host }} + builder-target: ${{ matrix.stack.target }} + target-vendor: ${{ matrix.stack.vendor }} + target-os: ${{ matrix.stack.os }} + rust-toolchain-abi: ${{ matrix.stack.abi }} + distro-image: ${{ matrix.distro.image }} + distro-LLVM: ${{ matrix.distro.LLVM }} + rust-toolchain-name: ${{ matrix.rust-toolchain-name }} + flavor: ${{ matrix.flavor }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + linux-fast-cross: + strategy: + fail-fast: false + matrix: + os: [ linux ] + stack: + - { runs-on: "ubuntu-24.04-arm", host: "aarch64", target: "armv6", vendor: "unknown", os: "linux", abi: "gnueabi" } + - { runs-on: "ubuntu-24.04-arm", host: "aarch64", target: "armv7", vendor: "unknown", os: "linux", abi: "gnueabihf" } + - { runs-on: "ubuntu-latest", host: "x86_64", target: "powerpc64", vendor: "unknown", os: "linux", abi: "gnu" } + - { runs-on: "ubuntu-latest", host: "x86_64", target: "powerpc64le", vendor: "unknown", os: "linux", abi: "gnu" } + - { runs-on: "ubuntu-latest", host: "x86_64", target: "s390x", vendor: "unknown", os: "linux", abi: "gnu" } + - { runs-on: "ubuntu-latest", host: "x86_64", target: "riscv64", vendor: "unknown", os: "linux", abi: "gnu" } distro: - { image: "debian:trixie-slim", LLVM: 19 } rust-toolchain-name: [ stable, nightly ] flavor: [ dev, release ] + exclude: + - rust-toolchain-name: nightly + flavor: dev uses: ./.github/workflows/CI-linux.yml with: os: ${{ matrix.os }} @@ -38,7 +76,7 @@ jobs: flavor: ${{ matrix.flavor }} secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - windows-cross: + windows-fast: strategy: fail-fast: false matrix: @@ -53,6 +91,8 @@ jobs: rust-toolchain-name: [ stable, nightly ] flavor: [ dev, release ] exclude: + - rust-toolchain-name: nightly + flavor: dev - stack: { runs-on: "ubuntu-24.04-arm", host: "aarch64", target: "aarch64", vendor: "pc", os: "windows" } abi: gnu - stack: { runs-on: "ubuntu-latest", host: "x86_64", target: "i686", vendor: "pc", os: "windows" } @@ -72,14 +112,63 @@ jobs: flavor: ${{ matrix.flavor }} secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - linux-cross: - needs: [ linux-fast, windows-cross, macOS-fast ] + macOS: + strategy: + fail-fast: false + matrix: + compiler: + - { os: macos, os-ver: 15, host: "aarch64", target: "aarch64", XCode: 16.3, LLVM: 19 } + - { os: macos, os-ver: 13, host: "x86_64", target: "x86_64", XCode: 15.2, LLVM: 16 } + rust-toolchain-name: [ stable, nightly ] + flavor: [ dev, release ] + uses: ./.github/workflows/CI-macOS.yml + with: + os: ${{ matrix.compiler.os }} + runs-on: ${{ matrix.compiler.os }}-${{ matrix.compiler.os-ver }} + builder-host: ${{ matrix.compiler.host }} + builder-target: ${{ matrix.compiler.target }} + xcode-version: ${{ matrix.compiler.XCode }} + LLVM_VER: ${{ matrix.compiler.LLVM }} + rust-toolchain-name: ${{ matrix.rust-toolchain-name }} + flavor: ${{ matrix.flavor }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + linux-slow-native: + needs: [ linux-fast-native, linux-fast-cross, windows-fast, macOS ] strategy: fail-fast: false matrix: os: [ linux ] stack: + - { runs-on: "ubuntu-latest", host: "x86_64", target: "x86_64", vendor: "unknown", os: "linux", abi: "gnu" } + - { runs-on: "ubuntu-24.04-arm", host: "aarch64", target: "aarch64", vendor: "unknown", os: "linux", abi: "gnu" } - { runs-on: "ubuntu-latest", host: "x86_64", target: "i686", vendor: "unknown", os: "linux", abi: "gnu" } + distro: + - { image: "debian:trixie-slim", LLVM: 19 } + rust-toolchain-name: [ nightly ] + flavor: [ dev ] + uses: ./.github/workflows/CI-linux.yml + with: + os: ${{ matrix.os }} + runs-on: ${{ matrix.stack.runs-on }} + builder-host: ${{ matrix.stack.host }} + builder-target: ${{ matrix.stack.target }} + target-vendor: ${{ matrix.stack.vendor }} + target-os: ${{ matrix.stack.os }} + rust-toolchain-abi: ${{ matrix.stack.abi }} + distro-image: ${{ matrix.distro.image }} + distro-LLVM: ${{ matrix.distro.LLVM }} + rust-toolchain-name: ${{ matrix.rust-toolchain-name }} + flavor: ${{ matrix.flavor }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + linux-slow-cross: + needs: [ linux-fast-native, linux-fast-cross, windows-fast, macOS ] + strategy: + fail-fast: false + matrix: + os: [ linux ] + stack: - { runs-on: "ubuntu-24.04-arm", host: "aarch64", target: "armv6", vendor: "unknown", os: "linux", abi: "gnueabi" } - { runs-on: "ubuntu-24.04-arm", host: "aarch64", target: "armv7", vendor: "unknown", os: "linux", abi: "gnueabihf" } - { runs-on: "ubuntu-latest", host: "x86_64", target: "powerpc64", vendor: "unknown", os: "linux", abi: "gnu" } @@ -88,8 +177,8 @@ jobs: - { runs-on: "ubuntu-latest", host: "x86_64", target: "riscv64", vendor: "unknown", os: "linux", abi: "gnu" } distro: - { image: "debian:trixie-slim", LLVM: 19 } - rust-toolchain-name: [ stable, nightly ] - flavor: [ dev, release ] + rust-toolchain-name: [ nightly ] + flavor: [ dev ] uses: ./.github/workflows/CI-linux.yml with: os: ${{ matrix.os }} @@ -105,29 +194,44 @@ jobs: flavor: ${{ matrix.flavor }} secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - macOS-fast: + windows-slow: + needs: [ linux-fast-native, linux-fast-cross, windows-fast, macOS ] strategy: fail-fast: false matrix: - compiler: - - { os: macos, os-ver: 15, host: "aarch64", target: "aarch64", XCode: 16.3, LLVM: 19 } - - { os: macos, os-ver: 13, host: "x86_64", target: "x86_64", XCode: 15.2, LLVM: 16 } - rust-toolchain-name: [ stable, nightly ] - flavor: [ dev, release ] - uses: ./.github/workflows/CI-macOS.yml + os: [ linux ] + stack: + - { runs-on: "ubuntu-latest", host: "x86_64", target: "x86_64", vendor: "pc", os: "windows" } + - { runs-on: "ubuntu-latest", host: "x86_64", target: "i686", vendor: "pc", os: "windows" } + - { runs-on: "ubuntu-24.04-arm", host: "aarch64", target: "aarch64", vendor: "pc", os: "windows" } + distro: + - { image: "debian:trixie-slim", LLVM: 19 } + abi: [ gnu, msvc ] + rust-toolchain-name: [ nightly ] + flavor: [ dev ] + exclude: + - stack: { runs-on: "ubuntu-24.04-arm", host: "aarch64", target: "aarch64", vendor: "pc", os: "windows" } + abi: gnu + - stack: { runs-on: "ubuntu-latest", host: "x86_64", target: "i686", vendor: "pc", os: "windows" } + abi: msvc + uses: ./.github/workflows/CI-linux.yml with: - os: ${{ matrix.compiler.os }} - runs-on: ${{ matrix.compiler.os }}-${{ matrix.compiler.os-ver }} - builder-host: ${{ matrix.compiler.host }} - builder-target: ${{ matrix.compiler.target }} - xcode-version: ${{ matrix.compiler.XCode }} - LLVM_VER: ${{ matrix.compiler.LLVM }} + os: ${{ matrix.os }} + runs-on: ${{ matrix.stack.runs-on }} + builder-host: ${{ matrix.stack.host }} + builder-target: ${{ matrix.stack.target }} + target-vendor: ${{ matrix.stack.vendor }} + target-os: ${{ matrix.stack.os }} + rust-toolchain-abi: ${{ matrix.abi }} + distro-image: ${{ matrix.distro.image }} + distro-LLVM: ${{ matrix.distro.LLVM }} rust-toolchain-name: ${{ matrix.rust-toolchain-name }} flavor: ${{ matrix.flavor }} secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} build-docs: - needs: [ linux-fast, windows-cross, linux-cross, macOS-fast ] + needs: [ linux-fast-native, linux-fast-cross, windows-fast, macOS, + linux-slow-native, linux-slow-cross, windows-slow] uses: ./.github/workflows/CI-linux.yml with: os: linux diff --git a/src/common/common/tests.rs b/src/common/common/tests.rs index f3fdcbf..53d2f88 100644 --- a/src/common/common/tests.rs +++ b/src/common/common/tests.rs @@ -114,7 +114,7 @@ fn extract_high_bits_allones_input_test() { } #[test] -fn extract_high_bits_input_test() { +fn extract_high_bits_input_exhaustive_test() { macro_rules! test { ($($t:ty)+) => { $( @@ -133,7 +133,7 @@ fn extract_high_bits_input_test() { } test!(u8); - test!(u16); + // test!(u16); // test!(u32); // test!(u64); } @@ -265,7 +265,7 @@ fn extract_low_bits_allones_input_test() { } #[test] -fn extract_low_bits_input_test() { +fn extract_low_bits_input_exhaustive_test() { macro_rules! test { ($($t:ty)+) => { $( @@ -285,7 +285,7 @@ fn extract_low_bits_input_test() { } test!(u8); - test!(u16); + // test!(u16); // test!(u32); // test!(u64); } diff --git a/src/memory/layoutfulbox/layoutfulbox/tests.rs b/src/memory/layoutfulbox/layoutfulbox/tests.rs index 9fdfd76..e6a310c 100644 --- a/src/memory/layoutfulbox/layoutfulbox/tests.rs +++ b/src/memory/layoutfulbox/layoutfulbox/tests.rs @@ -110,12 +110,8 @@ fn usable_0xu8_test() { #[test] #[cfg_attr( - miri, - ignore = "miri fails with: miri resource exhaustion: tried to allocate more memory than available to compiler" -)] -#[cfg_attr( - not(target_pointer_width = "64"), - ignore = "iff isize === i32, allocation of isize::MAX can succeed, we don't want that" + any(not(target_pointer_width = "64"), miri), + ignore = "this test only makes sense for ridiculous allocations sizes (1PB+?), but at the same time requires native compilation (i.e. no interpreters/sanitizers)" )] fn usable_max_test() { assert_eq!( diff --git a/src/memory/nd-slice-procurement/ndsliceprocurement/tests.rs b/src/memory/nd-slice-procurement/ndsliceprocurement/tests.rs index ba259af..9d50e2a 100644 --- a/src/memory/nd-slice-procurement/ndsliceprocurement/tests.rs +++ b/src/memory/nd-slice-procurement/ndsliceprocurement/tests.rs @@ -223,12 +223,8 @@ fn basic_u8_test() { #[test] #[cfg_attr( - miri, - ignore = "miri fails with: miri resource exhaustion: tried to allocate more memory than available to compiler" -)] -#[cfg_attr( - not(target_pointer_width = "64"), - ignore = "iff isize === i32, allocation of isize::MAX can succeed, we don't want that" + any(not(target_pointer_width = "64"), miri), + ignore = "this test only makes sense for ridiculous allocations sizes (1PB+?), but at the same time requires native compilation (i.e. no interpreters/sanitizers)" )] fn usable_max_test() { assert_eq!( diff --git a/src/memory/variable_length_load/variable_length_load/tests.rs b/src/memory/variable_length_load/variable_length_load/tests.rs index 5b5ab26..eb8851b 100644 --- a/src/memory/variable_length_load/variable_length_load/tests.rs +++ b/src/memory/variable_length_load/variable_length_load/tests.rs @@ -45,7 +45,7 @@ fn basic_test() { #[test] fn exhaustive_test() { - for input_length in 0..=64_usize { + for input_length in 0..=8_usize { let mut res: Vec = vec![]; for i in 0..input_length { res.push((1 + i).try_into().unwrap()); diff --git a/src/misc/md5/md5/tests.rs b/src/misc/md5/md5/tests.rs index 02a4798..9e5cdd0 100644 --- a/src/misc/md5/md5/tests.rs +++ b/src/misc/md5/md5/tests.rs @@ -293,19 +293,14 @@ fn full_test() { #[test] fn in_parts_test() { - for testcase in TESTCASES { - let rest = testcase.slice; - for len0 in 0..rest.len() { - let (part_0, rest) = rest.split_at(len0); - for len1 in 0..rest.len() { - let (part_1, rest) = rest.split_at(len1); - let mut hasher = MD5::default(); - hasher.extend(part_0); - hasher.extend(part_1); - hasher.extend(rest); - assert_eq!(hasher.flush(), testcase.state); - } - } + let testcase = TESTCASES.iter().max_by_key(|c| c.slice.len()).unwrap(); + let rest = testcase.slice; + for len0 in 0..rest.len() { + let (part_0, rest) = rest.split_at(len0); + let mut hasher = MD5::default(); + hasher.extend(part_0); + hasher.extend(rest); + assert_eq!(hasher.flush(), testcase.state); } }