zstd: add ptest support
PATCH 1/1 zstd: add ptest support
Add comprehensive ptest support for zstd running the full upstream test suite covering compression correctness, streaming, dictionaries, CLI behavior, and fuzz testing.
Tests included:
- fullbench: validates all internal compression/decompression functions
- poolTests: thread pool ordering and synchronization
- invalidDictionaries: dictionary error handling
- legacy: legacy format (v0.4+) compatibility
- fuzzer: randomized compression/decompression (200s, ~700+ rounds)
- zstreamtest: streaming API fuzzer (90s, ~250+ rounds)
- decodecorpus: random frame generation and decode (30s, ~450+ rounds)
- playTests.sh: comprehensive CLI validation including compression, decompression, multithreading, dictionaries, sparse files, frame concatenation, long distance matching, benchmarks, and round-trips
- cli-tests: 36 Python-based CLI integration tests covering compression, decompression, progress, file-stat, dictionaries, symlinks, and file handling
Tests excluded from cli-tests (environment limitations):
- compression/levels.sh: requires >8GB for --ultra/--max levels
- compression/window-resize.sh: requires >4GB for 1GB window
- file-stat/compress-file-to-dir-without-write-perm.sh: ptest runs as root which bypasses permission checks
- cltools/: requires GNU grep (--label), unavailable with BusyBox
Source .c/.h files from tests/ and programs/ are installed as training corpus for the dictionary builder tests.
zstreamtest requires 4096MB RAM for (hashLog=29 allocates ~2.8GB). Set QB_MEM:virtclass-mcextend-zstd = "-m 4096" in core-image-ptest.
Tested on qemux86-64 (4GB) with ptest-runner: 9 PASS, 0 FAIL. Runtime is ~13 min.
--- .../distro/include/ptest-packagelists.inc | 1 + meta/recipes-core/images/core-image-ptest.bb | 1 + meta/recipes-extended/zstd/zstd/run-ptest | 27 +++++++++++ meta/recipes-extended/zstd/zstd_1.5.7.bb | 48 ++++++++++++++++++- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100755 meta/recipes-extended/zstd/zstd/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -151,6 +151,7 @@ PTESTS_SLOW = "\ tcl \ tcl8 \ util-linux \ + zstd \ " # python3 ptests hang on qemuriscv64
meta/recipes-core/images/core-image-ptest.bb +1 -0
@@ -44,6 +44,7 @@ QB_MEM:virtclass-mcextend-python3-cryptography = "-m 5100" QB_MEM:virtclass-mcextend-python3-numpy = "-m 4096" QB_MEM:virtclass-mcextend-tcl = "-m 5100" QB_MEM:virtclass-mcextend-go = "-m 4096" +QB_MEM:virtclass-mcextend-zstd = "-m 4096" TEST_SUITES = "ping ssh parselogs ptest"
meta/recipes-extended/zstd/zstd/run-ptest new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT + +cd "$(dirname "$0")/tests" || exit 1 + +run_test() { + name=$1; shift + if "$@"; then echo "PASS: $name"; else echo "FAIL: $name"; fi +} + +run_test fullbench ./fullbench -i1 +run_test poolTests ./poolTests +run_test invalidDictionaries ./invalidDictionaries +run_test legacy ./legacy +run_test fuzzer ./fuzzer -v -T200s +run_test zstreamtest ./zstreamtest -v -T90s +run_test decodecorpus ./decodecorpus -t -T30 + +ZSTD_BIN=$(command -v zstd) DATAGEN_BIN=./datagen ZSTDRTTEST= ./playTests.sh +run_test playTests test $? -eq 0 + +if [ -d cli-tests ] && command -v python3 >/dev/null 2>&1; then + ./cli-tests/run.py --exec-prefix="" --zstd="$(command -v zstd)" --datagen=./datagen + run_test cli-tests test $? -eq 0 +else + echo "SKIP: cli-tests" +fi
meta/recipes-extended/zstd/zstd_1.5.7.bb +47 -1
57 lines not on this page · raw message
Signature · 1 line
2.34.1
Hi,
Sorry, this patch no longer applies on master, due to conflicts with the QB_MEM assignment. Could you rebase and resend?
Antonin
Hi Antonin,
Rebased on current master in v2. No functional changes.
Best Regards,
Pratik
________________________________________
From: Antonin Godard <[email protected]>
Sent: Tuesday, May 19, 2026 10:34 AM
To: Pratik Farkase; [email protected]
Cc: [email protected]
Subject: Re: [OE-core][PATCH v1] zstd: add ptest support
Hi,
Sorry, this patch no longer applies on master, due to conflicts with the QB_MEM assignment. Could you rebase and resend?
Antonin
PATCH v2 1/1 zstd: add ptest support
In reply to Pratik FarkaseAdd comprehensive ptest support for zstd running the full upstream test suite covering compression correctness, streaming, dictionaries, CLI behavior, and fuzz testing.
Tests included:
- fullbench: validates all internal compression/decompression functions
- poolTests: thread pool ordering and synchronization
- invalidDictionaries: dictionary error handling
- legacy: legacy format (v0.4+) compatibility
- fuzzer: randomized compression/decompression (200s, ~700+ rounds)
- zstreamtest: streaming API fuzzer (90s, ~250+ rounds)
- decodecorpus: random frame generation and decode (30s, ~450+ rounds)
- playTests.sh: comprehensive CLI validation including compression, decompression, multithreading, dictionaries, sparse files, frame concatenation, long distance matching, benchmarks, and round-trips
- cli-tests: 36 Python-based CLI integration tests covering compression, decompression, progress, file-stat, dictionaries, symlinks, and file handling
Tests excluded from cli-tests (environment limitations):
- compression/levels.sh: requires >8GB for --ultra/--max levels
- compression/window-resize.sh: requires >4GB for 1GB window
- file-stat/compress-file-to-dir-without-write-perm.sh: ptest runs as root which bypasses permission checks
- cltools/: requires GNU grep (--label), unavailable with BusyBox
Source .c/.h files from tests/ and programs/ are installed as training corpus for the dictionary builder tests.
zstreamtest requires 4096MB RAM for (hashLog=29 allocates ~2.8GB). Set QB_MEM:virtclass-mcextend-zstd = "-m 4096" in core-image-ptest.
Tested on qemux86-64 (4GB) with ptest-runner: 9 PASS, 0 FAIL. Runtime is ~13 min.
--- .../distro/include/ptest-packagelists.inc | 1 + meta/recipes-core/images/core-image-ptest.bb | 1 + meta/recipes-extended/zstd/zstd/run-ptest | 27 +++++++++++ meta/recipes-extended/zstd/zstd_1.5.7.bb | 48 ++++++++++++++++++- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100755 meta/recipes-extended/zstd/zstd/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -146,6 +146,7 @@ PTESTS_SLOW = "\ tcl \ tcl8 \ util-linux \ + zstd \ " # python3 ptests hang on qemuriscv64
meta/recipes-core/images/core-image-ptest.bb +1 -0
@@ -45,6 +45,7 @@ QB_MEM:virtclass-mcextend-python3-numpy = "-m 4096" QB_MEM:virtclass-mcextend-tcl = "-m 5100" QB_MEM:virtclass-mcextend-go = "-m 4096" QB_MEM:virtclass-mcextend-gnutls = "-m 1536" +QB_MEM:virtclass-mcextend-zstd = "-m 4096" TEST_SUITES = "ping ssh parselogs ptest"
meta/recipes-extended/zstd/zstd/run-ptest new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT + +cd "$(dirname "$0")/tests" || exit 1 + +run_test() { + name=$1; shift + if "$@"; then echo "PASS: $name"; else echo "FAIL: $name"; fi +} + +run_test fullbench ./fullbench -i1 +run_test poolTests ./poolTests +run_test invalidDictionaries ./invalidDictionaries +run_test legacy ./legacy +run_test fuzzer ./fuzzer -v -T200s +run_test zstreamtest ./zstreamtest -v -T90s +run_test decodecorpus ./decodecorpus -t -T30 + +ZSTD_BIN=$(command -v zstd) DATAGEN_BIN=./datagen ZSTDRTTEST= ./playTests.sh +run_test playTests test $? -eq 0 + +if [ -d cli-tests ] && command -v python3 >/dev/null 2>&1; then + ./cli-tests/run.py --exec-prefix="" --zstd="$(command -v zstd)" --datagen=./datagen + run_test cli-tests test $? -eq 0 +else + echo "SKIP: cli-tests" +fi
meta/recipes-extended/zstd/zstd_1.5.7.bb +47 -1
57 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 5 lines · Pratik Farkase via lists.openembedded.org
Add comprehensive ptest support for zstd running the full upstream test suite covering compression correctness, streaming, dictionaries, CLI behavior, and fuzz testing.
Quoted 14 lines
Tests included:
- fullbench: validates all internal compression/decompression functions
- poolTests: thread pool ordering and synchronization
- invalidDictionaries: dictionary error handling
- legacy: legacy format (v0.4+) compatibility
- fuzzer: randomized compression/decompression (200s, ~700+ rounds)
- zstreamtest: streaming API fuzzer (90s, ~250+ rounds)
- decodecorpus: random frame generation and decode (30s, ~450+ rounds)
-playTests.sh: comprehensive CLI validation including compression, decompression, multithreading, dictionaries, sparse files, frame concatenation, long distance matching, benchmarks, and round-trips
- cli-tests: 36 Python-based CLI integration tests covering compression, decompression, progress, file-stat, dictionaries, symlinks, and file handling
The primary goal of the ptests is integration testing so if we’re having to manually install and run the tests then it’s entirely reasonable if not desirable to pick a subset of the tests.
In this case, we don’t need to run the fuzzer tests and so on. I’d suggest maybe just fullbench and cli-tests would be sufficient here, less to install and faster execution.
Ross
Hi Ross,
Thanks for the feedback on v2. Sent an improved v3 with the test scope reduced as you suggested. Now only running fullbench and cli-tests — no fuzzers or stress tests. The result is a much leaner ptest: 36/36 PASS in ~32 seconds on qemux86-64, no extra memory requirements.
Best Regards,
Pratik
________________________________________
From: Ross Burton <[email protected]>
Sent: Monday, June 8, 2026 4:05 PM
To: Pratik Farkase
Cc: [email protected]; [email protected]
Subject: Re: [OE-core] [PATCH v2] zstd: add ptest support
Quoted 5 lines · Pratik Farkase via lists.openembedded.org
Add comprehensive ptest support for zstd running the full upstream test suite covering compression correctness, streaming, dictionaries, CLI behavior, and fuzz testing.
Quoted 14 lines
Tests included:
- fullbench: validates all internal compression/decompression functions
- poolTests: thread pool ordering and synchronization
- invalidDictionaries: dictionary error handling
- legacy: legacy format (v0.4+) compatibility
- fuzzer: randomized compression/decompression (200s, ~700+ rounds)
- zstreamtest: streaming API fuzzer (90s, ~250+ rounds)
- decodecorpus: random frame generation and decode (30s, ~450+ rounds)
-playTests.sh: comprehensive CLI validation including compression, decompression, multithreading, dictionaries, sparse files, frame concatenation, long distance matching, benchmarks, and round-trips
- cli-tests: 36 Python-based CLI integration tests covering compression, decompression, progress, file-stat, dictionaries, symlinks, and file handling
The primary goal of the ptests is integration testing so if we’re having to manually install and run the tests then it’s entirely reasonable if not desirable to pick a subset of the tests.
In this case, we don’t need to run the fuzzer tests and so on. I’d suggest maybe just fullbench and cli-tests would be sufficient here, less to install and faster execution.
Ross
PATCH v3 1/1 zstd: add ptest support
In reply to Pratik FarkaseAdd ptest support for zstd running fullbench and the upstream cli-tests suite, providing integration testing of compression, decompression, dictionaries, file handling, and CLI behavior.
Tests included:
- fullbench: validates all internal compression/decompression functions
- cli-tests: 36 shell-based integration tests covering compression, decompression, dictionaries, file-stat, progress, symlinks, and multi-threading
Tested on qemux86-64 with ptest-runner: fullbench PASS, cli-tests 36/36 PASS. Runtime is ~32 seconds.
---
Changes in v3:
- Reduced test scope to fullbench + cli-tests only
- Removed fuzzer, zstreamtest, decodecorpus, poolTests, invalidDictionaries, legacy, and playTests.sh
- No longer requires 4GB RAM (removed QB_MEM override)
- Moved from PTESTS_SLOW to PTESTS_FAST (~32s runtime vs ~13min in v2)
Changes in v2:
- Added source .c/.h files as training corpus for dictionary builder tests
- Fixed cli-tests invocation
.../distro/include/ptest-packagelists.inc | 1 + meta/recipes-extended/zstd/zstd/run-ptest | 18 ++++++++ meta/recipes-extended/zstd/zstd_1.5.7.bb | 41 ++++++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-extended/zstd/zstd/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -105,6 +105,7 @@ PTESTS_FAST = "\ wayland \ xz \ zlib \ + zstd \ " PTESTS_FAST:remove:mips64 = "qemu" PTESTS_PROBLEMS:append:mips64 = " qemu"
meta/recipes-extended/zstd/zstd/run-ptest new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT + +cd "$(dirname "$0")/tests" || exit 1 + +run_test() { + name=$1; shift + if "$@"; then echo "PASS: $name"; else echo "FAIL: $name"; fi +} + +run_test fullbench ./fullbench -i1 + +if [ -d cli-tests ] && command -v python3 >/dev/null 2>&1; then + ./cli-tests/run.py --exec-prefix="" --zstd="$(command -v zstd)" --datagen=./datagen + run_test cli-tests test $? -eq 0 +else + echo "SKIP: cli-tests" +fi
meta/recipes-extended/zstd/zstd_1.5.7.bb +40 -1
50 lines not on this page · raw message
Signature · 1 line
2.43.0
meta/recipes-extended/zstd/zstd_1.5.7.bb PACKAGE_BEFORE_PN = "libzstd" · line 76
Quoted 5 lines · Pratik Farkase via lists.openembedded.org
meta/recipes-extended/zstd/zstd_1.5.7.bb +5
-0+ # Remove tests incompatible with ptest environment: + # levels.sh: --ultra/--max levels require >8GB RAM + rm -f ${D}${PTEST_PATH}/tests/cli-tests/compression/levels.sh + # window-resize.sh: 1GB window size requires >4GB RAM + rm -f ${D}${PTEST_PATH}/tests/cli-tests/compression/window-resize.sh
Earlier versions of the patch adjusted RAM allocation for the image, and this one removes the tests instead. Why was this changed? Adjusting RAM is better, and it's standard procedure for ptests.
meta/recipes-extended/zstd/zstd_1.5.7.bb PACKAGE_BEFORE_PN = "libzstd" · line 79
Quoted 3 lines
meta/recipes-extended/zstd/zstd_1.5.7.bb +3
-0+ # compress-file-to-dir-without-write-perm.sh: ptest runs as root, + # which bypasses filesystem permission checks + rm -f ${D}${PTEST_PATH}/tests/cli-tests/file-stat/compress-file-to-dir-without-write-perm.sh
This as well should not be done: rather run ptests as a regular user, for example look at meta/recipes-extended/cpio/files/run-ptest.
meta/recipes-extended/zstd/zstd_1.5.7.bb PACKAGE_BEFORE_PN = "libzstd" · line 82
Quoted 3 lines
meta/recipes-extended/zstd/zstd_1.5.7.bb +3
-0+ # cltools/: zstdgrep requires GNU grep --label option not available + # in BusyBox grep + rm -rf ${D}${PTEST_PATH}/tests/cli-tests/cltools
This can addressed by adding GNU grep to ptest's package RDEPENDS.
Alex
Hi Alex,
Thanks for the review. cli-tests now run as the ptest user, GNU grep and less are added to RDEPENDS, and the QEMU image is given 4GB RAM and with these changes, 40 out of 41 cli-tests pass. The only remaining failure is compression/levels.sh, where zstd --max attempts to allocate ~8.5GB (kernel logs: __vm_enough_memory: bytes: 8597475328) on 64-bit systems. This exceeds what we can reasonably provide in a QEMU ptest environment. Would it be acceptable to exclude this single test, or do you have another suggestion?
Best Regards,
Pratik
________________________________________
From: Alexander Kanavin <[email protected]>
Sent: Thursday, August 27, 2026 12:09 PM
To: Pratik Farkase
Cc: [email protected]; [email protected]
Subject: Re: [OE-core][PATCH v3] zstd: add ptest support
meta/recipes-extended/zstd/zstd_1.5.7.bb PACKAGE_BEFORE_PN = "libzstd" · line 76
Quoted 5 lines · Pratik Farkase via lists.openembedded.org
meta/recipes-extended/zstd/zstd_1.5.7.bb +5
-0+ # Remove tests incompatible with ptest environment: + # levels.sh: --ultra/--max levels require >8GB RAM + rm -f ${D}${PTEST_PATH}/tests/cli-tests/compression/levels.sh + # window-resize.sh: 1GB window size requires >4GB RAM + rm -f ${D}${PTEST_PATH}/tests/cli-tests/compression/window-resize.sh
Earlier versions of the patch adjusted RAM allocation for the image, and this one removes the tests instead. Why was this changed? Adjusting RAM is better, and it's standard procedure for ptests.
meta/recipes-extended/zstd/zstd_1.5.7.bb PACKAGE_BEFORE_PN = "libzstd" · line 79
Quoted 3 lines
meta/recipes-extended/zstd/zstd_1.5.7.bb +3
-0+ # compress-file-to-dir-without-write-perm.sh: ptest runs as root, + # which bypasses filesystem permission checks + rm -f ${D}${PTEST_PATH}/tests/cli-tests/file-stat/compress-file-to-dir-without-write-perm.sh
This as well should not be done: rather run ptests as a regular user, for example look at meta/recipes-extended/cpio/files/run-ptest.
meta/recipes-extended/zstd/zstd_1.5.7.bb PACKAGE_BEFORE_PN = "libzstd" · line 82
Quoted 3 lines
meta/recipes-extended/zstd/zstd_1.5.7.bb +3
-0+ # cltools/: zstdgrep requires GNU grep --label option not available + # in BusyBox grep + rm -rf ${D}${PTEST_PATH}/tests/cli-tests/cltools
This can addressed by adding GNU grep to ptest's package RDEPENDS.
Alex
Quoted 1 line · Pratik Farkase
Thanks for the review. cli-tests now run as the ptest user, GNU grep and less are added to RDEPENDS, and the QEMU image is given 4GB RAM and with these changes, 40 out of 41 cli-tests pass. The only remaining failure is
compression/levels.sh, where zstd --max attempts to allocate ~8.5GB (kernel logs:__vm_enough_memory: bytes: 8597475328) on 64-bit systems. This exceeds what we can reasonably provide in a QEMU ptest environment. Would it be acceptable to exclude this single test, or do you have another suggestion?
It's not easy to suggest one way or the other. We should certainly be careful with allocating massive amounts of RAM to qemu processes, as ptests are run in parallel, and it adds up, and can exhaust the RAM on the build machine.
Is it possible to adjust the test itself, so that it skips the memory-intensive max level, but otherwise runs?
Alex
PATCH v4 1/1 zstd: add ptest support
In reply to Pratik FarkaseAdd ptest support for zstd running fullbench and the upstream cli-tests suite, providing integration testing of compression, decompression, dictionaries, file handling, and CLI behavior.
Tests included:
- fullbench: validates all internal compression/decompression functions
- cli-tests: 41 shell-based integration tests covering compression, decompression, dictionaries, file-stat, progress, symlinks, cltools, and multi-threading
The cli-tests run as the ptest user so that permission-related tests work correctly. The levels.sh test is patched to skip the --max compression level on systems with less than 10GB RAM, as it allocates ~8.5GB on 64-bit systems.
Tested on qemux86-64 (4GB RAM) with ptest-runner: fullbench PASS, cli-tests 41/41 PASS. Runtime is ~41 seconds.
---
Changes in v4:
- Run cli-tests as ptest user for permission tests
- Add GNU grep and less to RDEPENDS for cltools tests
- Install zstdgrep/zstdless scripts for cltools tests
- Patch levels.sh to skip --max level on systems with <10GB RAM
Changes in v3:
- Reduced test scope to fullbench + cli-tests only
- Removed fuzzers and stress tests
- Moved from PTESTS_SLOW to PTESTS_FAST
Changes in v2:
- Added source .c/.h files as training corpus for dictionary builder tests
- Fixed cli-tests invocation
.../distro/include/ptest-packagelists.inc | 1 + meta/recipes-core/images/core-image-ptest.bb | 1 + ...std-max-level-when-memory-is-insuffi.patch | 31 ++++++++++++++ meta/recipes-extended/zstd/zstd/run-ptest | 21 ++++++++++ meta/recipes-extended/zstd/zstd_1.5.7.bb | 40 ++++++++++++++++++- 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-extended/zstd/zstd/0001-cli-tests-skip-zstd-max-level-when-memory-is-insuffi.patch create mode 100644 meta/recipes-extended/zstd/zstd/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -150,6 +150,7 @@ PTESTS_SLOW = "\ tcl \ tcl8 \ util-linux \ + zstd \ " # python3 ptests hang on qemuriscv64
meta/recipes-core/images/core-image-ptest.bb +1 -0
@@ -45,6 +45,7 @@ QB_MEM:virtclass-mcextend-python3-numpy = "-m 4096" QB_MEM:virtclass-mcextend-tcl = "-m 5100" QB_MEM:virtclass-mcextend-go = "-m 4096" QB_MEM:virtclass-mcextend-gnutls = "-m 1536" +QB_MEM:virtclass-mcextend-zstd = "-m 4096" TEST_SUITES = "ping ssh parselogs ptest"
meta/recipes-extended/zstd/zstd/0001-cli-tests-skip-zstd-max-level-when-memory-is-insuffi.patch new file +31 -0
@@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Pratik Farkase <[email protected]> +Date: Thu, 27 Aug 2026 12:00:00 +0000 +Subject: [PATCH] cli-tests: skip zstd --max level when memory is insufficient + +The --max compression level on 64-bit systems allocates ~8.5GB, which +exceeds what is available in memory-constrained test environments such +as QEMU. Extend the existing 32-bit skip logic to also check available +system memory, using the same fallback (copy level-19 output as max). + +Upstream-Status: Submitted [https://github.com/facebook/zstd/issues/4748] +Signed-off-by: Pratik Farkase <[email protected]> +--- + tests/cli-tests/compression/levels.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/cli-tests/compression/levels.sh b/tests/cli-tests/compression/levels.sh +index b8230f2..7846d3e 100755 +--- a/tests/cli-tests/compression/levels.sh ++++ b/tests/cli-tests/compression/levels.sh +@@ -16,8 +16,8 @@ zstd --fast=10 file -o file-f10.zst -q + zstd --fast=1 file -o file-f1.zst -q + zstd -1 file -o file-1.zst -q + zstd -19 file -o file-19.zst -q +-if echo "$version_info" | grep -q '32-bit'; then +- # skip --max test: not enough address space ++if echo "$version_info" | grep -q '32-bit' || [ "$(awk '/MemTotal/{print $2}' /proc/meminfo)" -lt 10000000 ]; then ++ # skip --max test: not enough address space or memory (<10GB) + cp file-19.zst file-max.zst + else + zstd --max file -o file-max.zst -q
meta/recipes-extended/zstd/zstd/run-ptest new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT + +cd "$(dirname "$0")/tests" || exit 1 + +run_test() { + name=$1; shift + if "$@"; then echo "PASS: $name"; else echo "FAIL: $name"; fi +} + +run_test fullbench ./fullbench -i1 + +if [ -d cli-tests ] && command -v python3 >/dev/null 2>&1; then + # cli-tests needs to write to bin/symlinks and scratch dirs. + # Run as ptest user so permission-related tests work correctly. + chown -R ptest:ptest . + su ptest -s /bin/sh -c "./cli-tests/run.py --exec-prefix='' --zstd='$(command -v zstd)' --datagen=./datagen" + run_test cli-tests test $? -eq 0 +else + echo "SKIP: cli-tests" +fi
meta/recipes-extended/zstd/zstd_1.5.7.bb +39 -1
@@ -12,7 +12,10 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=0822a32f7acdbe013606746641746ee8 \ file://COPYING;md5=39bba7d2cf0ba1036f2a6e2be52fe3f0 \ " -SRC_URI = "git://github.com/facebook/zstd.git;branch=release;protocol=https;tag=v${PV}" +SRC_URI = "git://github.com/facebook/zstd.git;branch=release;protocol=https;tag=v${PV} \ + file://run-ptest \ + file://0001-cli-tests-skip-zstd-max-level-when-memory-is-insuffi.patch \ + " SRCREV = "f8745da6ff1ad1e7bab384bd1f9d742439278e99" UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)"
@@ -44,3 +47,38 @@ PACKAGE_BEFORE_PN = "libzstd" FILES:libzstd = "${libdir}/libzstd${SOLIBS}" BBCLASSEXTEND = "native nativesdk" + +inherit ptest + +do_compile_ptest() { + oe_runmake -C ${S}/tests fullbench datagen \ + ZSTD_LEGACY_SUPPORT=${ZSTD_LEGACY_SUPPORT} +} + +do_install_ptest() { + install -d ${D}${PTEST_PATH}/tests + install -d ${D}${PTEST_PATH}/programs + + # Test binaries + install -m 0755 ${S}/tests/fullbench ${D}${PTEST_PATH}/tests/ + install -m 0755 ${S}/tests/datagen ${D}${PTEST_PATH}/tests/ + + # cli-tests + cp -r ${S}/tests/cli-tests ${D}${PTEST_PATH}/tests/ + + # Golden test data needed by cli-tests + for d in golden-compression golden-decompression golden-dictionaries; do + cp -r ${S}/tests/$d ${D}${PTEST_PATH}/tests/ + done + + # zstdgrep/zstdless scripts needed by cltools tests + install -m 0755 ${S}/programs/zstdgrep ${D}${PTEST_PATH}/programs/ + install -m 0755 ${S}/programs/zstdless ${D}${PTEST_PATH}/programs/ + + # The levels.sh expected stderr includes set -v traces that change + # after patching the memory check. Remove the exact match file so + # the test framework ignores stderr comparison. + rm -f ${D}${PTEST_PATH}/tests/cli-tests/compression/levels.sh.stderr.exact +} + +RDEPENDS:${PN}-ptest += "bash grep less python3-core python3-modules"
Signature · 1 line
2.43.0
Quoted 15 lines · Pratik Farkase
Add ptest support for zstd running fullbench and the upstream cli-tests suite, providing integration testing of compression, decompression, dictionaries, file handling, and CLI behavior.
Tests included:
- fullbench: validates all internal compression/decompression functions
- cli-tests: 41 shell-based integration tests covering compression, decompression, dictionaries, file-stat, progress, symlinks, cltools, and multi-threadingThe cli-tests run as the ptest user so that permission-related tests work correctly. The
levels.shtest is patched to skip the --max compression level on systems with less than 10GB RAM, as it allocates ~8.5GB on 64-bit systems.
Quoted 5 lines
Tested on qemux86-64 (4GB RAM) with ptest-runner: fullbench PASS, cli-tests 41/41 PASS. Runtime is ~41 seconds.
Signed-off-by Pratik Farkase <[email protected]>---
Hi Pratik,
Thanks for adding tests. It looks like some of these are failing on the autobuilder:
Failed ptests:
{'zstd': ['compression/window-resize.sh',
'compression/window-resize.sh.check_stdout',
'cli-tests']}https://autobuilder.yoctoproject.org/valkyrie/#/builders/73/builds/4443
Test outputs can be found here:
https://valkyrie.yocto.io/pub/non-release/20260831-42/testresults/qemux86-64-ptest/core-image-ptest-zstd/
Can you have a look at the issue?
Thanks,
Mathieu
Signature · 3 lines
Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v5 1/1 zstd: add ptest support
In reply to Pratik FarkaseAdd ptest support for zstd running fullbench and the upstream cli-tests suite, providing integration testing of compression, decompression, dictionaries, file handling, and CLI behavior.
Tests included:
- fullbench: validates all internal compression/decompression functions
- cli-tests: 41 shell-based integration tests covering compression, decompression, dictionaries, file-stat, progress, symlinks, cltools, and multi-threading
The cli-tests run as the ptest user so that permission-related tests work correctly. The levels.sh test is patched to skip the --max compression level on systems with less than 10GB RAM, as it allocates ~8.5GB on 64-bit systems.
Tested on qemux86-64 (4GB RAM) with ptest-runner: fullbench PASS, cli-tests 41/41 PASS. Runtime is ~41 seconds.
---
Changes in v5:
- Add IMAGE_ROOTFS_EXTRA_SPACE override for zstd ptest image (window-resize.sh creates a 1GB file and needs sufficient disk)
Changes in v4:
- Run cli-tests as ptest user for permission tests
- Add GNU grep and less to RDEPENDS for cltools tests
- Install zstdgrep/zstdless scripts for cltools tests
- Patch levels.sh to skip --max level on systems with <10GB RAM
Changes in v3:
- Reduced test scope to fullbench + cli-tests only (per Ross's review)
- Removed fuzzers and stress tests
- Moved from PTESTS_SLOW to PTESTS_FAST
Changes in v2:
- Added source .c/.h files as training corpus for dictionary builder tests
- Fixed cli-tests invocation
.../distro/include/ptest-packagelists.inc | 1 + meta/recipes-core/images/core-image-ptest.bb | 2 + ...std-max-level-when-memory-is-insuffi.patch | 31 ++++++++++++++ meta/recipes-extended/zstd/zstd/run-ptest | 21 ++++++++++ meta/recipes-extended/zstd/zstd_1.5.7.bb | 40 ++++++++++++++++++- 5 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-extended/zstd/zstd/0001-cli-tests-skip-zstd-max-level-when-memory-is-insuffi.patch create mode 100644 meta/recipes-extended/zstd/zstd/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -150,6 +150,7 @@ PTESTS_SLOW = "\ tcl \ tcl8 \ util-linux \ + zstd \ " # python3 ptests hang on qemuriscv64
meta/recipes-core/images/core-image-ptest.bb +2 -0
@@ -45,6 +45,8 @@ QB_MEM:virtclass-mcextend-python3-numpy = "-m 4096" QB_MEM:virtclass-mcextend-tcl = "-m 5100" QB_MEM:virtclass-mcextend-go = "-m 4096" QB_MEM:virtclass-mcextend-gnutls = "-m 1536" +QB_MEM:virtclass-mcextend-zstd = "-m 4096" +IMAGE_ROOTFS_EXTRA_SPACE:virtclass-mcextend-zstd = "1524288" TEST_SUITES = "ping ssh parselogs ptest"
meta/recipes-extended/zstd/zstd/0001-cli-tests-skip-zstd-max-level-when-memory-is-insuffi.patch new file +31 -0
@@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Pratik Farkase <[email protected]> +Date: Thu, 27 Aug 2026 12:00:00 +0000 +Subject: [PATCH] cli-tests: skip zstd --max level when memory is insufficient + +The --max compression level on 64-bit systems allocates ~8.5GB, which +exceeds what is available in memory-constrained test environments such +as QEMU. Extend the existing 32-bit skip logic to also check available +system memory, using the same fallback (copy level-19 output as max). + +Upstream-Status: Inappropriate [https://github.com/facebook/zstd/issues/4748] +Signed-off-by: Pratik Farkase <[email protected]> +--- + tests/cli-tests/compression/levels.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/cli-tests/compression/levels.sh b/tests/cli-tests/compression/levels.sh +index b8230f2..7846d3e 100755 +--- a/tests/cli-tests/compression/levels.sh ++++ b/tests/cli-tests/compression/levels.sh +@@ -16,8 +16,8 @@ zstd --fast=10 file -o file-f10.zst -q + zstd --fast=1 file -o file-f1.zst -q + zstd -1 file -o file-1.zst -q + zstd -19 file -o file-19.zst -q +-if echo "$version_info" | grep -q '32-bit'; then +- # skip --max test: not enough address space ++if echo "$version_info" | grep -q '32-bit' || [ "$(awk '/MemTotal/{print $2}' /proc/meminfo)" -lt 10000000 ]; then ++ # skip --max test: not enough address space or memory (<10GB) + cp file-19.zst file-max.zst + else + zstd --max file -o file-max.zst -q
meta/recipes-extended/zstd/zstd/run-ptest new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT + +cd "$(dirname "$0")/tests" || exit 1 + +run_test() { + name=$1; shift + if "$@"; then echo "PASS: $name"; else echo "FAIL: $name"; fi +} + +run_test fullbench ./fullbench -i1 + +if [ -d cli-tests ] && command -v python3 >/dev/null 2>&1; then + # cli-tests needs to write to bin/symlinks and scratch dirs. + # Run as ptest user so permission-related tests work correctly. + chown -R ptest:ptest . + su ptest -s /bin/sh -c "./cli-tests/run.py --exec-prefix='' --zstd='$(command -v zstd)' --datagen=./datagen" + run_test cli-tests test $? -eq 0 +else + echo "SKIP: cli-tests" +fi
meta/recipes-extended/zstd/zstd_1.5.7.bb +39 -1
@@ -12,7 +12,10 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=0822a32f7acdbe013606746641746ee8 \ file://COPYING;md5=39bba7d2cf0ba1036f2a6e2be52fe3f0 \ " -SRC_URI = "git://github.com/facebook/zstd.git;branch=release;protocol=https;tag=v${PV}" +SRC_URI = "git://github.com/facebook/zstd.git;branch=release;protocol=https;tag=v${PV} \ + file://run-ptest \ + file://0001-cli-tests-skip-zstd-max-level-when-memory-is-insuffi.patch \ + " SRCREV = "f8745da6ff1ad1e7bab384bd1f9d742439278e99" UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)"
@@ -44,3 +47,38 @@ PACKAGE_BEFORE_PN = "libzstd" FILES:libzstd = "${libdir}/libzstd${SOLIBS}" BBCLASSEXTEND = "native nativesdk" + +inherit ptest + +do_compile_ptest() { + oe_runmake -C ${S}/tests fullbench datagen \ + ZSTD_LEGACY_SUPPORT=${ZSTD_LEGACY_SUPPORT} +} + +do_install_ptest() { + install -d ${D}${PTEST_PATH}/tests + install -d ${D}${PTEST_PATH}/programs + + # Test binaries + install -m 0755 ${S}/tests/fullbench ${D}${PTEST_PATH}/tests/ + install -m 0755 ${S}/tests/datagen ${D}${PTEST_PATH}/tests/ + + # cli-tests + cp -r ${S}/tests/cli-tests ${D}${PTEST_PATH}/tests/ + + # Golden test data needed by cli-tests + for d in golden-compression golden-decompression golden-dictionaries; do + cp -r ${S}/tests/$d ${D}${PTEST_PATH}/tests/ + done + + # zstdgrep/zstdless scripts needed by cltools tests + install -m 0755 ${S}/programs/zstdgrep ${D}${PTEST_PATH}/programs/ + install -m 0755 ${S}/programs/zstdless ${D}${PTEST_PATH}/programs/ + + # The levels.sh expected stderr includes set -v traces that change + # after patching the memory check. Remove the exact match file so + # the test framework ignores stderr comparison. + rm -f ${D}${PTEST_PATH}/tests/cli-tests/compression/levels.sh.stderr.exact +} + +RDEPENDS:${PN}-ptest += "bash grep less python3-core python3-modules"
Signature · 1 line
2.43.0
PATCH v6 1/1 zstd: add ptest support
In reply to Pratik FarkaseAdd ptest support for zstd running fullbench and the upstream cli-tests suite, providing integration testing of compression, decompression, dictionaries, file handling, and CLI behavior.
Tests included:
- fullbench: validates all internal compression/decompression functions
- cli-tests: 41 shell-based integration tests covering compression, decompression, dictionaries, file-stat, progress, symlinks, cltools, and multi-threading
The cli-tests run as the ptest user so that permission-related tests work correctly. The levels.sh test is patched to skip the --max compression level on systems with less than 10GB RAM, as it allocates ~8.5GB on 64-bit systems.
Tested on qemux86-64 (4GB RAM) with ptest-runner: fullbench PASS, cli-tests 41/41 PASS. Runtime is ~41 seconds.
---
Changes in v6:
- Move IMAGE_ROOTFS_EXTRA_SPACE override next to the other IMAGE_ROOTFS_EXTRA_SPACE entries for consistency
Changes in v5:
- Add IMAGE_ROOTFS_EXTRA_SPACE override for zstd ptest image (window-resize.sh creates a 1GB file and needs sufficient disk)
Changes in v4:
- Run cli-tests as ptest user for permission tests
- Add GNU grep and less to RDEPENDS for cltools tests
- Install zstdgrep/zstdless scripts for cltools tests
- Patch levels.sh to skip --max level on systems with <10GB RAM
Changes in v3:
- Reduced test scope to fullbench + cli-tests only (per Ross's review)
- Removed fuzzers and stress tests
- Moved from PTESTS_SLOW to PTESTS_FAST
Changes in v2:
- Added source .c/.h files as training corpus for dictionary builder tests
- Fixed cli-tests invocation
.../distro/include/ptest-packagelists.inc | 1 + meta/recipes-core/images/core-image-ptest.bb | 4 ++ ...std-max-level-when-memory-is-insuffi.patch | 31 ++++++++++++++ meta/recipes-extended/zstd/zstd/run-ptest | 21 ++++++++++ meta/recipes-extended/zstd/zstd_1.5.7.bb | 40 ++++++++++++++++++- 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-extended/zstd/zstd/0001-cli-tests-skip-zstd-max-level-when-memory-is-insuffi.patch create mode 100644 meta/recipes-extended/zstd/zstd/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -150,6 +150,7 @@ PTESTS_SLOW = "\ tcl \ tcl8 \ util-linux \ + zstd \ " # python3 ptests hang on qemuriscv64
meta/recipes-core/images/core-image-ptest.bb +4 -0
@@ -36,6 +36,9 @@ IMAGE_ROOTFS_EXTRA_SPACE:virtclass-mcextend-python3-numpy = "3048576" # golang go-ptest requires extra space IMAGE_ROOTFS_EXTRA_SPACE:virtclass-mcextend-go = "1524288" +# zstd cli-tests create large temporary files (e.g. 1GB for window-resize) +IMAGE_ROOTFS_EXTRA_SPACE:virtclass-mcextend-zstd = "1524288" + # ptests need more memory than standard to avoid the OOM killer QB_MEM = "-m 1024" QB_MEM:virtclass-mcextend-lttng-tools = "-m 4096"
@@ -45,6 +48,7 @@ QB_MEM:virtclass-mcextend-python3-numpy = "-m 4096" QB_MEM:virtclass-mcextend-tcl = "-m 5100" QB_MEM:virtclass-mcextend-go = "-m 4096" QB_MEM:virtclass-mcextend-gnutls = "-m 1536" +QB_MEM:virtclass-mcextend-zstd = "-m 4096" TEST_SUITES = "ping ssh parselogs ptest"
meta/recipes-extended/zstd/zstd/0001-cli-tests-skip-zstd-max-level-when-memory-is-insuffi.patch new file +31 -0
@@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Pratik Farkase <[email protected]> +Date: Thu, 27 Aug 2026 12:00:00 +0000 +Subject: [PATCH] cli-tests: skip zstd --max level when memory is insufficient + +The --max compression level on 64-bit systems allocates ~8.5GB, which +exceeds what is available in memory-constrained test environments such +as QEMU. Extend the existing 32-bit skip logic to also check available +system memory, using the same fallback (copy level-19 output as max). + +Upstream-Status: Inappropriate [https://github.com/facebook/zstd/issues/4748] +Signed-off-by: Pratik Farkase <[email protected]> +--- + tests/cli-tests/compression/levels.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/cli-tests/compression/levels.sh b/tests/cli-tests/compression/levels.sh +index b8230f2..7846d3e 100755 +--- a/tests/cli-tests/compression/levels.sh ++++ b/tests/cli-tests/compression/levels.sh +@@ -16,8 +16,8 @@ zstd --fast=10 file -o file-f10.zst -q + zstd --fast=1 file -o file-f1.zst -q + zstd -1 file -o file-1.zst -q + zstd -19 file -o file-19.zst -q +-if echo "$version_info" | grep -q '32-bit'; then +- # skip --max test: not enough address space ++if echo "$version_info" | grep -q '32-bit' || [ "$(awk '/MemTotal/{print $2}' /proc/meminfo)" -lt 10000000 ]; then ++ # skip --max test: not enough address space or memory (<10GB) + cp file-19.zst file-max.zst + else + zstd --max file -o file-max.zst -q
meta/recipes-extended/zstd/zstd/run-ptest new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT + +cd "$(dirname "$0")/tests" || exit 1 + +run_test() { + name=$1; shift + if "$@"; then echo "PASS: $name"; else echo "FAIL: $name"; fi +} + +run_test fullbench ./fullbench -i1 + +if [ -d cli-tests ] && command -v python3 >/dev/null 2>&1; then + # cli-tests needs to write to bin/symlinks and scratch dirs. + # Run as ptest user so permission-related tests work correctly. + chown -R ptest:ptest . + su ptest -s /bin/sh -c "./cli-tests/run.py --exec-prefix='' --zstd='$(command -v zstd)' --datagen=./datagen" + run_test cli-tests test $? -eq 0 +else + echo "SKIP: cli-tests" +fi
meta/recipes-extended/zstd/zstd_1.5.7.bb +39 -1
@@ -12,7 +12,10 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=0822a32f7acdbe013606746641746ee8 \ file://COPYING;md5=39bba7d2cf0ba1036f2a6e2be52fe3f0 \ " -SRC_URI = "git://github.com/facebook/zstd.git;branch=release;protocol=https;tag=v${PV}" +SRC_URI = "git://github.com/facebook/zstd.git;branch=release;protocol=https;tag=v${PV} \ + file://run-ptest \ + file://0001-cli-tests-skip-zstd-max-level-when-memory-is-insuffi.patch \ + " SRCREV = "f8745da6ff1ad1e7bab384bd1f9d742439278e99" UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)"
@@ -44,3 +47,38 @@ PACKAGE_BEFORE_PN = "libzstd" FILES:libzstd = "${libdir}/libzstd${SOLIBS}" BBCLASSEXTEND = "native nativesdk" + +inherit ptest + +do_compile_ptest() { + oe_runmake -C ${S}/tests fullbench datagen \ + ZSTD_LEGACY_SUPPORT=${ZSTD_LEGACY_SUPPORT} +} + +do_install_ptest() { + install -d ${D}${PTEST_PATH}/tests + install -d ${D}${PTEST_PATH}/programs + + # Test binaries + install -m 0755 ${S}/tests/fullbench ${D}${PTEST_PATH}/tests/ + install -m 0755 ${S}/tests/datagen ${D}${PTEST_PATH}/tests/ + + # cli-tests + cp -r ${S}/tests/cli-tests ${D}${PTEST_PATH}/tests/ + + # Golden test data needed by cli-tests + for d in golden-compression golden-decompression golden-dictionaries; do + cp -r ${S}/tests/$d ${D}${PTEST_PATH}/tests/ + done + + # zstdgrep/zstdless scripts needed by cltools tests + install -m 0755 ${S}/programs/zstdgrep ${D}${PTEST_PATH}/programs/ + install -m 0755 ${S}/programs/zstdless ${D}${PTEST_PATH}/programs/ + + # The levels.sh expected stderr includes set -v traces that change + # after patching the memory check. Remove the exact match file so + # the test framework ignores stderr comparison. + rm -f ${D}${PTEST_PATH}/tests/cli-tests/compression/levels.sh.stderr.exact +} + +RDEPENDS:${PN}-ptest += "bash grep less python3-core python3-modules"
Signature · 1 line
2.43.0