()
| 1292 | |
| 1293 | @staticmethod |
| 1294 | def _fs_supports_holes(): |
| 1295 | # Return True if the platform knows the st_blocks stat attribute and |
| 1296 | # uses st_blocks units of 512 bytes, and if the filesystem is able to |
| 1297 | # store holes of 4 KiB in files. |
| 1298 | # |
| 1299 | # The function returns False if page size is larger than 4 KiB. |
| 1300 | # For example, ppc64 uses pages of 64 KiB. |
| 1301 | if sys.platform.startswith(("linux", "android")): |
| 1302 | # Linux evidentially has 512 byte st_blocks units. |
| 1303 | name = os.path.join(TEMPDIR, "sparse-test") |
| 1304 | with open(name, "wb") as fobj: |
| 1305 | # Seek to "punch a hole" of 4 KiB |
| 1306 | fobj.seek(4096) |
| 1307 | fobj.write(b'x' * 4096) |
| 1308 | fobj.truncate() |
| 1309 | s = os.stat(name) |
| 1310 | os_helper.unlink(name) |
| 1311 | return (s.st_blocks * 512 < s.st_size) |
| 1312 | else: |
| 1313 | return False |
| 1314 | |
| 1315 | |
| 1316 | class PaxReadTest(LongnameTest, ReadTest, unittest.TestCase): |
no test coverage detected