~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__dirstate_helpers.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    errors,
26
26
    osutils,
27
27
    tests,
 
28
    _dirstate_helpers_py,
28
29
    )
29
30
from bzrlib.tests import (
30
31
    test_dirstate,
60
61
    process_entry = compiled_dirstate_helpers_feature.module.ProcessEntryC
61
62
    pe_scenarios.append(('dirstate_Pyrex', {'_process_entry': process_entry}))
62
63
 
 
64
helper_scenarios = [('dirstate_Python', {'helpers': _dirstate_helpers_py})]
 
65
if compiled_dirstate_helpers_feature.available():
 
66
    helper_scenarios.append(('dirstate_Pyrex',
 
67
        {'helpers': compiled_dirstate_helpers_feature.module}))
 
68
 
63
69
 
64
70
class TestBisectPathMixin(object):
65
71
    """Test that _bisect_path_*() returns the expected values.
1337
1343
        state._sha1_provider = UppercaseSHA1Provider()
1338
1344
        self.assertChangedFileIds(['file-id'], tree)
1339
1345
 
 
1346
 
 
1347
class TestPackStat(tests.TestCase):
 
1348
    """Check packed representaton of stat values is robust on all inputs"""
 
1349
 
 
1350
    scenarios = helper_scenarios
 
1351
 
 
1352
    def pack(self, statlike_tuple):
 
1353
        return self.helpers.pack_stat(os.stat_result(statlike_tuple))
 
1354
 
 
1355
    @staticmethod
 
1356
    def unpack_field(packed_string, stat_field):
 
1357
        return _dirstate_helpers_py._unpack_stat(packed_string)[stat_field]
 
1358
 
 
1359
    def test_result(self):
 
1360
        self.assertEqual("AAAQAAAAABAAAAARAAAAAgAAAAEAAIHk",
 
1361
            self.pack((33252, 1, 2, 0, 0, 0, 4096, 15.5, 16.5, 17.5)))
 
1362
 
 
1363
    def test_giant_inode(self):
 
1364
        packed = self.pack((33252, 0xF80000ABC, 0, 0, 0, 0, 0, 0, 0, 0))
 
1365
        self.assertEqual(0x80000ABC, self.unpack_field(packed, "st_ino"))
 
1366
 
 
1367
    def test_giant_size(self):
 
1368
        packed = self.pack((33252, 0, 0, 0, 0, 0, (1 << 33) + 4096, 0, 0, 0))
 
1369
        self.assertEqual(4096, self.unpack_field(packed, "st_size"))
 
1370
 
 
1371
    def test_fractional_mtime(self):
 
1372
        packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, 16.9375, 0))
 
1373
        self.assertEqual(16, self.unpack_field(packed, "st_mtime"))
 
1374
 
 
1375
    def test_ancient_mtime(self):
 
1376
        packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, -11644473600.0, 0))
 
1377
        self.assertEqual(1240428288, self.unpack_field(packed, "st_mtime"))
 
1378
 
 
1379
    def test_distant_mtime(self):
 
1380
        packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, 64060588800.0, 0))
 
1381
        self.assertEqual(3931046656, self.unpack_field(packed, "st_mtime"))
 
1382
 
 
1383
    def test_fractional_ctime(self):
 
1384
        packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, 0, 17.5625))
 
1385
        self.assertEqual(17, self.unpack_field(packed, "st_ctime"))
 
1386
 
 
1387
    def test_ancient_ctime(self):
 
1388
        packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, 0, -11644473600.0))
 
1389
        self.assertEqual(1240428288, self.unpack_field(packed, "st_ctime"))
 
1390
 
 
1391
    def test_distant_ctime(self):
 
1392
        packed = self.pack((33252, 0, 0, 0, 0, 0, 0, 0, 0, 64060588800.0))
 
1393
        self.assertEqual(3931046656, self.unpack_field(packed, "st_ctime"))
 
1394
 
 
1395
    def test_negative_dev(self):
 
1396
        packed = self.pack((33252, 0, -0xFFFFFCDE, 0, 0, 0, 0, 0, 0, 0))
 
1397
        self.assertEqual(0x322, self.unpack_field(packed, "st_dev"))