Best Python code snippet using avocado_python
vatest.py
Source:vatest.py
...55 if memory.meminfo.Hugepagesize.m == self.hsizes[0]:56 page_chunker = self.hsizes[1]57 else:58 page_chunker = self.hsizes[0]59 self.exist_pages = memory.get_num_huge_pages()60 if self.scenario_arg in [10, 11, 12]:61 self.log.info("Using Multiple hugepages")62 if len(self.hsizes) == 1:63 self.cancel('Scenario is not applicable')64 if memory.meminfo.Hugepagesize.m != self.hsizes[0]:65 self.hsizes.reverse()66 # Leaving half size for default pagesize67 total_mem = (0.9 * memory.meminfo.MemFree.m) / 268 self.def_chunks = int(total_mem / 16384)69 for hp_size in self.hsizes:70 nr_pgs = int((total_mem / 2) / hp_size)71 genio.write_file(self.hp_file %72 str(hp_size * 1024), str(nr_pgs))73 n_pages = genio.read_file(self.hp_file % str(74 self.hsizes[0] * 1024)).rstrip("\n")75 n_pages2 = genio.read_file(self.hp_file % str(76 self.hsizes[1] * 1024)).rstrip("\n")77 self.n_chunks = (int(n_pages) * self.hsizes[0]) // 1638478 self.n_chunks2 = (int(n_pages2) * self.hsizes[1]) // 1638479 if self.scenario_arg not in [1, 2, 10, 11, 12]:80 max_hpages = int((0.9 * memory.meminfo.MemFree.m) / page_chunker)81 if self.scenario_arg in [3, 4, 5, 6]:82 memory.set_num_huge_pages(max_hpages)83 nr_pages = memory.get_num_huge_pages()84 else:85 genio.write_file(self.hp_file % str(86 page_chunker * 1024), str(max_hpages))87 nr_pages = genio.read_file(self.hp_file % str(88 page_chunker * 1024)).rstrip("\n")89 self.n_chunks = (int(nr_pages) * page_chunker) // 1638490 for packages in ['gcc', 'make']:91 if not smm.check_installed(packages) and not smm.install(packages):92 self.cancel('%s is needed for the test to be run' % packages)93 shutil.copyfile(self.get_data('va_test.c'),94 os.path.join(self.teststmpdir, 'va_test.c'))95 shutil.copyfile(self.get_data('Makefile'),96 os.path.join(self.teststmpdir, 'Makefile'))97 build.make(self.teststmpdir)...
hugepage_mem_stress.py
Source:hugepage_mem_stress.py
...65 stress_tool.join(stress_duration)66 if params.get_boolean("non_existent_point"):67 error_context.context("Check large memory pages free on host.",68 logging.info)69 if utils_memory.get_num_huge_pages() != utils_memory.get_num_huge_pages_free():70 test.fail("HugePages leaked.")71 finally:...
allocpages.py
Source:allocpages.py
...14 try:15 expected_size = params.get("expected_size", "")16 number_of_huge_pages = params.get("number_of_hugepages", "")17 previous_allocation = ""18 previous_allocation = get_num_huge_pages()19 logging.debug("Try to set '%s' huge pages."20 " Expected size: '%s'. Actual size: '%s'." %21 (number_of_huge_pages, expected_size,22 get_huge_page_size()))23 virsh.allocpages(expected_size, number_of_huge_pages,24 ignore_status=False)25 actual_allocation = get_num_huge_pages()26 if str(actual_allocation) != str(number_of_huge_pages):27 test.fail("Huge page allocation failed."28 " Expected '%s', got '%s'." %29 (number_of_huge_pages, actual_allocation))30 finally:31 if previous_allocation:32 logging.debug("Restore huge page allocation")...
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!!