diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2023-05-25 08:48:57 -0700 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2023-05-25 12:54:09 -0700 |
| commit | 2238dcc39358353cac21df75c3c3286ab20b8f53 (patch) | |
| tree | 1bb7ec8d7405ccd7fdb5a8a78d0cf5ef40bcc963 /lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py | |
| parent | daeee56798c51e8f007e8e8e6e677a420b14c9ef (diff) | |
[NFC][Py Reformat] Reformat python files in lldb
This is an ongoing series of commits that are reformatting our Python
code. Reformatting is done with `black` (23.1.0).
If you end up having problems merging this commit because you have made
changes to a python file, the best way to handle that is to run `git
checkout --ours <yourfile>` and then reformat it with black.
RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style
Differential revision: https://reviews.llvm.org/D151460
Diffstat (limited to 'lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py')
| -rw-r--r-- | lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py | 77 |
1 files changed, 45 insertions, 32 deletions
diff --git a/lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py b/lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py index 5894574a199f..4214bd108bfc 100644 --- a/lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py +++ b/lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py @@ -10,22 +10,23 @@ import time class ModuleCacheTestcaseSimple(TestBase): - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number in a(int) to break at. - self.cache_dir = os.path.join(self.getBuildDir(), 'lldb-module-cache') + self.cache_dir = os.path.join(self.getBuildDir(), "lldb-module-cache") # Set the lldb module cache directory to a directory inside the build # artifacts directory so no other tests are interfered with. - self.runCmd('settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir)) - self.runCmd('settings set symbols.enable-lldb-index-cache true') + self.runCmd( + 'settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir) + ) + self.runCmd("settings set symbols.enable-lldb-index-cache true") self.build() - def get_module_cache_files(self, basename): - module_file_glob = os.path.join(self.cache_dir, - "llvmcache-*%s*-symtab-*" % (basename)) + module_file_glob = os.path.join( + self.cache_dir, "llvmcache-*%s*-symtab-*" % (basename) + ) return glob.glob(module_file_glob) # Doesn't depend on any specific debug information. @@ -33,14 +34,14 @@ class ModuleCacheTestcaseSimple(TestBase): @skipIfWindows def test(self): """ - Test module cache functionality for a simple object file. + Test module cache functionality for a simple object file. - This will test that if we enable the module cache, we have a - corresponding index cache entry for the symbol table for the - executable. It also removes the executable, rebuilds so that the - modification time of the binary gets updated, and then creates a new - target and should cause the cache to get updated so the cache file - should get an updated modification time. + This will test that if we enable the module cache, we have a + corresponding index cache entry for the symbol table for the + executable. It also removes the executable, rebuilds so that the + modification time of the binary gets updated, and then creates a new + target and should cause the cache to get updated so the cache file + should get an updated modification time. """ exe = self.getBuildArtifact("a.out") @@ -55,8 +56,9 @@ class ModuleCacheTestcaseSimple(TestBase): # Make sure the symbol table gets loaded and cached main_module.GetNumSymbols() cache_files = self.get_module_cache_files("a.out") - self.assertEqual(len(cache_files), 1, - "make sure there is only one cache file for 'a.out'") + self.assertEqual( + len(cache_files), 1, "make sure there is only one cache file for 'a.out'" + ) symtab_cache_path = cache_files[0] exe_mtime_1 = os.path.getmtime(exe) symtab_mtime_1 = os.path.getmtime(symtab_cache_path) @@ -64,36 +66,47 @@ class ModuleCacheTestcaseSimple(TestBase): # get a different creation and modification time for the file since some # OSs store the modification time in seconds since Jan 1, 1970. os.remove(exe) - self.assertEqual(os.path.exists(exe), False, - 'make sure we were able to remove the executable') + self.assertEqual( + os.path.exists(exe), + False, + "make sure we were able to remove the executable", + ) time.sleep(2) # Now rebuild the binary so it has a different content which should # update the UUID to make the cache miss when it tries to load the # symbol table from the binary at the same path. - self.build(dictionary={'CFLAGS_EXTRAS': '-DEXTRA_FUNCTION'}) - self.assertEqual(os.path.exists(exe), True, - 'make sure executable exists after rebuild') + self.build(dictionary={"CFLAGS_EXTRAS": "-DEXTRA_FUNCTION"}) + self.assertEqual( + os.path.exists(exe), True, "make sure executable exists after rebuild" + ) # Make sure the modification time has changed or this test will fail. exe_mtime_2 = os.path.getmtime(exe) self.assertNotEqual( - exe_mtime_1, - exe_mtime_2, - "make sure the modification time of the executable has changed") + exe_mtime_1, + exe_mtime_2, + "make sure the modification time of the executable has changed", + ) # Make sure the module cache still has an out of date cache with the # same old modification time. - self.assertEqual(symtab_mtime_1, - os.path.getmtime(symtab_cache_path), - "check that the 'symtab' cache file modification time doesn't match the executable modification time after rebuild") + self.assertEqual( + symtab_mtime_1, + os.path.getmtime(symtab_cache_path), + "check that the 'symtab' cache file modification time doesn't match the executable modification time after rebuild", + ) # Create a new target and get the symbols again, and make sure the cache # gets updated for the symbol table cache target = self.createTestTarget(load_dependent_modules=False) main_module = target.GetModuleAtIndex(0) self.assertTrue(main_module.IsValid()) main_module.GetNumSymbols() - self.assertEqual(os.path.exists(symtab_cache_path), True, - 'make sure "symtab" cache files exists after cache is updated') + self.assertEqual( + os.path.exists(symtab_cache_path), + True, + 'make sure "symtab" cache files exists after cache is updated', + ) symtab_mtime_2 = os.path.getmtime(symtab_cache_path) self.assertNotEqual( - symtab_mtime_1, - symtab_mtime_2, - 'make sure modification time of "symtab-..." changed') + symtab_mtime_1, + symtab_mtime_2, + 'make sure modification time of "symtab-..." changed', + ) |
