#!/bin/bash # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # This program is distributed in the hope that it would be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # Test checks that we can create swap zram device. # # Author: Alexey Kodanev # Modified: Naresh Kamboju global TCID := '"zram02'" global ERR_CODE := '0' source ./zram_lib.sh # Test will create the following number of zram devices: global dev_num := '1' # This is a list of parameters for zram devices. # Number of items must be equal to 'dev_num' parameter. global zram_max_streams := '"2'" # The zram sysfs node 'disksize' value can be either in bytes, # or you can use mem suffixes. But in some old kernels, mem # suffixes are not supported, for example, in RHEL6.6GA's kernel # layer, it uses strict_strtoull() to parse disksize which does # not support mem suffixes, in some newer kernels, they use # memparse() which supports mem suffixes. So here we just use # bytes to make sure everything works correctly. global zram_sizes := '"1048576'" # 1M global zram_mem_limits := '"1M'" check_prereqs zram_load zram_max_streams zram_set_disksizes zram_set_memlimit zram_makeswap zram_swapoff zram_cleanup zram_unload if test $ERR_CODE -ne 0 { echo "$TCID : [FAIL]" } else { echo "$TCID : [PASS]" } (CommandList children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:TCID) op:Equal rhs:{(DQ (zram02))} spids:[52])] spids: [52] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ERR_CODE) op:Equal rhs:{(0)} spids:[57])] spids: [57] ) (C {(.)} {(./zram_lib.sh)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:dev_num) op:Equal rhs:{(1)} spids:[69])] spids: [69] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:zram_max_streams) op:Equal rhs:{(DQ (2))} spids:[78])] spids: [78] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:zram_sizes) op:Equal rhs:{(DQ (1048576))} spids:[105])] spids: [105] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:zram_mem_limits) op:Equal rhs:{(DQ (1M))} spids:[113])] spids: [113] ) (C {(check_prereqs)}) (C {(zram_load)}) (C {(zram_max_streams)}) (C {(zram_set_disksizes)}) (C {(zram_set_memlimit)}) (C {(zram_makeswap)}) (C {(zram_swapoff)}) (C {(zram_cleanup)}) (C {(zram_unload)}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$ERR_CODE")} {(-ne)} {(0)} {(Lit_Other "]")}) terminator: ) ] action: [(C {(echo)} {(DQ ($ VSub_Name "$TCID") (" : [FAIL]"))})] spids: [-1 151] ) ] else_action: [(C {(echo)} {(DQ ($ VSub_Name "$TCID") (" : [PASS]"))})] spids: [161 171] ) ] )