1#!/bin/sh 2# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 3# Copyright (c) 2019-2021 Petr Vorel <pvorel@suse.cz> 4# Author: Alexey Kodanev <alexey.kodanev@oracle.com> 5# 6# Test checks that we can create swap zram device. 7 8TST_CNT=6 9TST_TESTFUNC="do_test" 10. zram_lib.sh 11 12# List of parameters for zram devices. 13# For each number the test creates own zram device. 14zram_max_streams="2" 15 16# The zram sysfs node 'disksize' value can be either in bytes, 17# or you can use mem suffixes. But in some old kernels, mem 18# suffixes are not supported, for example, in RHEL6.6GA's kernel 19# layer, it uses strict_strtoull() to parse disksize which does 20# not support mem suffixes, in some newer kernels, they use 21# memparse() which supports mem suffixes. So here we just use 22# bytes to make sure everything works correctly. 23zram_sizes="107374182400" # 100GB 24zram_mem_limits="1M" 25 26zram_makeswap() 27{ 28 tst_res TINFO "make swap with zram device(s)" 29 tst_require_cmds mkswap swapon swapoff 30 local i=0 31 32 for i in $(seq $dev_start $dev_end); do 33 ROD mkswap /dev/zram$i 34 ROD swapon /dev/zram$i 35 tst_res TINFO "done with /dev/zram$i" 36 dev_makeswap=$i 37 done 38 39 tst_res TPASS "making zram swap succeeded" 40} 41 42zram_swapoff() 43{ 44 tst_require_cmds swapoff 45 local i 46 47 for i in $(seq $dev_start $dev_end); do 48 ROD swapoff /dev/zram$i 49 done 50 dev_makeswap=-1 51 52 tst_res TPASS "swapoff completed" 53} 54 55do_test() 56{ 57 case $1 in 58 1) zram_max_streams;; 59 2) zram_compress_alg;; 60 3) zram_set_disksizes;; 61 4) zram_set_memlimit;; 62 5) zram_makeswap;; 63 6) zram_swapoff;; 64 esac 65} 66 67tst_run 68