1#!/bin/sh
2# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
3# Copyright (c) 2019 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=5
9TST_TESTFUNC="do_test"
10. zram_lib.sh
11
12# Test will create the following number of zram devices:
13dev_num=1
14# This is a list of parameters for zram devices.
15# Number of items must be equal to 'dev_num' parameter.
16zram_max_streams="2"
17
18# The zram sysfs node 'disksize' value can be either in bytes,
19# or you can use mem suffixes. But in some old kernels, mem
20# suffixes are not supported, for example, in RHEL6.6GA's kernel
21# layer, it uses strict_strtoull() to parse disksize which does
22# not support mem suffixes, in some newer kernels, they use
23# memparse() which supports mem suffixes. So here we just use
24# bytes to make sure everything works correctly.
25zram_sizes="107374182400" # 100GB
26zram_mem_limits="1M"
27
28do_test()
29{
30	case $1 in
31	 1) zram_max_streams;;
32	 2) zram_set_disksizes;;
33	 3) zram_set_memlimit;;
34	 4) zram_makeswap;;
35	 5) zram_swapoff;;
36	esac
37}
38
39tst_run
40