Best Python code snippet using avocado_python
ndctl.py
Source:ndctl.py
...726 def test_write_infoblock_supported_align(self):727 """728 Test write_infoblock with align size729 """730 if not self.plib.check_ndctl_subcmd("write-infoblock"):731 self.cancel("Binary does not support write-infoblock")732 region = self.get_default_region()733 self.plib.disable_namespace(region=region)734 self.plib.destroy_namespace(region=region)735 self.plib.create_namespace(region=region, mode='devdax')736 ns_name = self.plib.run_ndctl_list_val(737 self.plib.run_ndctl_list("-N -r %s" % region)[0], 'dev')738 self.plib.disable_namespace(namespace=ns_name)739 map_align = memory.get_supported_huge_pages_size()[0] * 1024740 self.write_read_infoblock(ns_name, align=map_align)741 self.plib.enable_namespace(namespace=ns_name)742 @avocado.fail_on(pmem.PMemException)743 def test_write_infoblock_unalign(self):744 """745 Test write_infoblock with unsupported align size746 """747 if not self.plib.check_ndctl_subcmd("write-infoblock"):748 self.cancel("Binary does not support write-infoblock")749 region = self.get_default_region()750 self.plib.disable_namespace(region=region)751 self.plib.destroy_namespace(region=region)752 self.plib.create_namespace(region=region, mode='devdax')753 ns_name = self.plib.run_ndctl_list_val(754 self.plib.run_ndctl_list("-N -r %s" % region)[0], 'dev')755 self.plib.disable_namespace(namespace=ns_name)756 map_align = memory.get_supported_huge_pages_size()[0] * 1024757 self.write_read_infoblock(758 ns_name, align=self.get_unsupported_alignval(map_align))759 try:760 self.plib.enable_namespace(namespace=ns_name)761 except pmem.PMemException:762 self.log.info("Failed as expected")763 else:764 self.log.info(self.plib.run_ndctl_list())765 self.fail("Enabling namespace must have failed")766 idle_ns = self.plib.run_ndctl_list('-Ni -r %s' % region)767 if len(idle_ns) > 1:768 found = False769 for namespace in idle_ns:770 if int(self.plib.run_ndctl_list_val(namespace, 'size')) != 0:771 found = True772 break773 else:774 self.fail("Created namespace is not found")775 if not found:776 self.fail("Namespace with infoblock written not found")777 self.plib.destroy_namespace(namespace=ns_name, force=True)778 @avocado.fail_on(pmem.PMemException)779 def test_write_infoblock_align_default(self):780 """781 Test write_infoblock with align size782 """783 if not self.plib.check_ndctl_subcmd("write-infoblock"):784 self.cancel("Binary does not support write-infoblock")785 region = self.get_default_region()786 self.plib.disable_namespace(region=region)787 self.plib.destroy_namespace(region=region)788 self.plib.create_namespace(region=region, mode='devdax')789 ns_name = self.plib.run_ndctl_list_val(790 self.plib.run_ndctl_list("-N -r %s" % region)[0], 'dev')791 align = self.plib.run_ndctl_list_val(792 self.plib.run_ndctl_list("-N -r %s" % region)[0], 'align')793 self.plib.disable_namespace(namespace=ns_name)794 write_block = self.write_read_infoblock(ns_name)795 if align != self.plib.run_ndctl_list_val(write_block, 'align'):796 self.fail("Alignment is not same as default alignment")797 @avocado.fail_on(pmem.PMemException)798 def test_write_infoblock_size(self):799 """800 Test write_infoblock with align size801 """802 if not self.plib.check_ndctl_subcmd("write-infoblock"):803 self.cancel("Binary does not support write-infoblock")804 region = self.get_default_region()805 self.plib.disable_namespace(region=region)806 self.plib.destroy_namespace(region=region)807 self.plib.create_namespace(region=region, mode='devdax')808 ns_name = self.plib.run_ndctl_list_val(809 self.plib.run_ndctl_list("-N -r %s" % region)[0], 'dev')810 size = self.plib.run_ndctl_list_val(811 self.plib.run_ndctl_list("-N -r %s" % region)[0], 'size')812 self.plib.disable_namespace(namespace=ns_name)813 align = self.get_size_alignval()814 size = size - align815 self.write_read_infoblock(ns_name, size=size)816 self.plib.enable_namespace(namespace=ns_name)817 @avocado.fail_on(pmem.PMemException)818 def test_write_infoblock_size_unaligned(self):819 """820 Test write_infoblock with align size821 """822 if not self.plib.check_ndctl_subcmd("write-infoblock"):823 self.cancel("Binary does not support write-infoblock")824 region = self.get_default_region()825 self.plib.disable_namespace(region=region)826 self.plib.destroy_namespace(region=region)827 self.plib.create_namespace(region=region, mode='devdax')828 ns_name = self.plib.run_ndctl_list_val(829 self.plib.run_ndctl_list("-N -r %s" % region)[0], 'dev')830 size = self.plib.run_ndctl_list_val(831 self.plib.run_ndctl_list("-N -r %s" % region)[0], 'size')832 self.plib.disable_namespace(namespace=ns_name)833 align = memory.get_page_size()834 size = size - align835 self.write_read_infoblock(ns_name, size=size, align=align)836 try:...
pmem.py
Source:pmem.py
...57 out = process.system_output(cmd).decode().splitlines()58 if command in out:59 return True60 return False61 def check_ndctl_subcmd(self, command):62 """Check if given sub command is supported by ndctl"""63 return self.check_subcmd(self.ndctl, command)64 def check_daxctl_subcmd(self, command):65 """Check if given sub command is supported by daxctl"""66 return self.check_subcmd(self.daxctl, command)67 def run_ndctl_list(self, option=''):68 """69 Get the json of each provided options70 :param option: optional arguments to ndctl list command71 :return: By default returns entire list of json objects72 :rtype: list of json objects73 """74 try:75 cmd = '%s list %s' % (self.ndctl, option)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!