Files
linux/tools/testing/selftests/zram
Cheng-Han Wu 649ba27dfa selftests/zram: fix kernel_gte() for POSIX sh
Commit fc4eb486a5 ("selftests/zram: Skip max_comp_streams
interface on newer kernel") added kernel_gte() to zram_lib.sh.
The function uses the bash-specific [[ ... ]] conditional, but
zram selftests source this file while running under /bin/sh.

On systems where /bin/sh is dash, such as Debian, the following
test fails:

  dash -c '
  kernel_major=6; kernel_minor=1; major=6; minor=0
  if [ $kernel_major -gt $major ]; then
      echo ok
  elif [[ $kernel_major -eq $major && $kernel_minor -ge $minor ]]; then
      echo ok
  fi'

with:

  dash: 5: [[: not found

Use separate POSIX test expressions joined by && instead.

Fixes: fc4eb486a5 ("selftests/zram: Skip max_comp_streams interface on newer kernel")
Signed-off-by: Cheng-Han Wu <hank20010209@gmail.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2026-07-30 07:55:37 -06:00
..
2025-09-21 14:21:59 -07:00

zram: Compressed RAM based block devices
----------------------------------------
* Introduction

The zram module creates RAM based block devices named /dev/zram<id>
(<id> = 0, 1, ...). Pages written to these disks are compressed and stored
in memory itself. These disks allow very fast I/O and compression provides
good amounts of memory savings. Some of the usecases include /tmp storage,
use as swap disks, various caches under /var and maybe many more :)

Statistics for individual zram devices are exported through sysfs nodes at
/sys/block/zram<id>/

Kconfig required:
CONFIG_ZRAM=y
CONFIG_CRYPTO_LZ4=y
CONFIG_ZSMALLOC=y

ZRAM Testcases
--------------
zram_lib.sh: create library with initialization/cleanup functions
zram.sh: For sanity check of CONFIG_ZRAM and to run zram01 and zram02

Two functional tests: zram01 and zram02:
zram01.sh: creates general purpose ram disks with ext4 filesystems
zram02.sh: creates block device for swap

Commands required for testing:
 - bc
 - dd
 - free
 - awk
 - mkswap
 - swapon
 - swapoff
 - mkfs/ mkfs.ext4

For more information please refer:
kernel-source-tree/Documentation/admin-guide/blockdev/zram.rst