zram02.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License as
  6. # published by the Free Software Foundation; either version 2 of
  7. # the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it would be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # Test checks that we can create swap zram device.
  15. #
  16. # Author: Alexey Kodanev <alexey.kodanev@oracle.com>
  17. # Modified: Naresh Kamboju <naresh.kamboju@linaro.org>
  18. TCID="zram02"
  19. ERR_CODE=0
  20. . ./zram_lib.sh
  21. # Test will create the following number of zram devices:
  22. dev_num=1
  23. # This is a list of parameters for zram devices.
  24. # Number of items must be equal to 'dev_num' parameter.
  25. zram_max_streams="2"
  26. # The zram sysfs node 'disksize' value can be either in bytes,
  27. # or you can use mem suffixes. But in some old kernels, mem
  28. # suffixes are not supported, for example, in RHEL6.6GA's kernel
  29. # layer, it uses strict_strtoull() to parse disksize which does
  30. # not support mem suffixes, in some newer kernels, they use
  31. # memparse() which supports mem suffixes. So here we just use
  32. # bytes to make sure everything works correctly.
  33. zram_sizes="1048576" # 1M
  34. zram_mem_limits="1M"
  35. check_prereqs
  36. zram_load
  37. zram_max_streams
  38. zram_set_disksizes
  39. zram_set_memlimit
  40. zram_makeswap
  41. zram_swapoff
  42. zram_cleanup
  43. zram_unload
  44. if [ $ERR_CODE -ne 0 ]; then
  45. echo "$TCID : [FAIL]"
  46. else
  47. echo "$TCID : [PASS]"
  48. fi