facebook / facebook/zstd

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

Open
#4,057 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
C
Stars
27.9k
Forks
2.6k
Avg merge
1d 3h
Merged PRs (30d)
8

Description

**Describe the bug**

Specifically, starting with git [tag v611](https://github.com/gwsw/less/commit/dd7d1f50ceba744f0d178d99db3242019618d277), or according to git bisect, [commit b17b0802](https://github.com/gwsw/less/commit/b17b0802471c8b30d4f2f5085f621a5ea9e2d052).

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](https://github.com/gwsw/less/blob/dba9042ddb84ecb6a0570b7277ddedd31336f5f2/os.c#L276-L284), reproduced below:

```c
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](https://github.com/nc7s/zstd-zstdless-test/actions/runs/9339401031/job/25703715574) for your convenience.

**Expected behavior**

The test should succeed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.