zstd icon indicating copy to clipboard operation
zstd copied to clipboard

tests/cli-tests/cltools/zstdless.sh fails with newer version of less

Open nc7s opened this issue 1 year ago • 3 comments

Describe the bug

Specifically, starting with git tag v611, or according to git bisect, commit b17b0802.

The result is as follows:

$ZSTD_SYMLINK_DIR='/home/runner/work/zstd-zstdless-test/zstd-zstdless-test/zstd/tests/cli-tests/bin/symlinks'
$ZSTD_REPO_DIR='/home/runner/work/zstd-zstdless-test/zstd-zstdless-test/zstd'
$DATAGEN_BIN='/home/runner/work/zstd-zstdless-test/zstd-zstdless-test/zstd/tests/datagen'
$ZSTDGREP_BIN='/home/runner/work/zstd-zstdless-test/zstd-zstdless-test/zstd/programs/zstdgrep'
$ZSTDLESS_BIN='/home/runner/work/zstd-zstdless-test/zstd-zstdless-test/zstd/programs/zstdless'
$COMMON='/home/runner/work/zstd-zstdless-test/zstd-zstdless-test/zstd/tests/cli-tests/common'
$PATH='/home/runner/work/zstd-zstdless-test/zstd-zstdless-test/zstd/tests/cli-tests/bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
$LC_ALL='C'
FAIL: cltools/zstdless.sh
FAIL: cltools/zstdless.sh.check_exit
Exit code mismatch! Expected 0 but got 1
FAIL: cltools/zstdless.sh.check_stderr
stderr does not match!
> diff expected actual
1,2d0
< zstd: can't stat bad.zst : No such file or directory -- ignored 
< bad.zst: No such file or directory

FAIL: cltools/zstdless.sh.check_stdout
stdout does not match!
> diff expected actual
---
< + pass parameters
< 1234
< + bad path

----------------------------------------
FAIL: cltools/zstdless.sh
FAILED 1 / 1 tests!

The problem is that the first invocation of zstdless exited with 1.

With strace and a bit of manual debugging (aka inserting printf all over the place), the code doing the exit is located here, reproduced below:

		if (!ignore_eoi)
		{
			if (n == 0)
				consecutive_nulls++;
			else
				consecutive_nulls = 0;
			if (consecutive_nulls > 20)
				quit(QUIT_ERROR);
		}

To Reproduce

Steps to reproduce the behavior:

  1. Get a version of less newer than v610 (i.e. v611 and later) or aforementioned commit
  2. Replace exec less in programs/zstdless with exec $NEWER_LESS
  3. Run tests/cli-tests/run.py --verbose cltools/zstdless.sh

There is also an actions run here for your convenience.

Expected behavior

The test should succeed.

nc7s avatar Jun 02 '24 15:06 nc7s