@@ -150,6 +150,7 @@ PTESTS_SLOW = "\
tcl \
tcl8 \
util-linux \
+ zstd \
"
# python3 ptests hang on qemuriscv64
@@ -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"
new file mode 100644
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Pratik Farkase <pratik.farkase@est.tech>
+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 <pratik.farkase@est.tech>
+---
+ 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
new file mode 100644
@@ -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
@@ -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"
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-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. Signed-off-by: Pratik Farkase <pratik.farkase@est.tech> --- 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