Beispiel #1
0
 def testAbandonTransaction(self):
     outfile = self.MakeTestScript()
     t = igd_time.TimeTZ(tzfile=outfile.name)
     t.StartTransaction()
     t.LocalTimeZoneName = 'This should not be written.'
     t.AbandonTransaction()
     self.assertEqual(outfile.read().strip(), '')
Beispiel #2
0
    def testUCLibcIsReallyReallyReallyPickyAboutWhitespace(self):
        # uClibC will only accept a TZ file with exactly one newline at the end.
        tzwrite = 'PST8PDT,M3.2.0/2,M11.1.0/2'

        t = igd_time.TimeTZ()
        t.LocalTimeZoneName = tzwrite + '\n\n\n\n\n'
        self.loop.RunOnce(timeout=1)
        actual = open(self.tzfile).read()
        self.assertEqual(actual, tzwrite + '\n')

        os.remove(self.tzfile)
        t = igd_time.TimeTZ()
        t.LocalTimeZoneName = tzwrite
        self.loop.RunOnce(timeout=1)
        actual = open(self.tzfile).read()
        self.assertEqual(actual, tzwrite + '\n')
Beispiel #3
0
    def testUCLibcIsReallyReallyReallyPickyAboutWhitespace(self):
        # uClibC will only accept a TZ file with exactly one newline at the end.
        tzwrite = 'PST8PDT,M3.2.0/2,M11.1.0/2'

        outfile = self.MakeTestScript()
        t = igd_time.TimeTZ(tzfile=outfile.name)
        t.StartTransaction()
        t.LocalTimeZoneName = tzwrite + '\n\n\n\n\n'
        t.CommitTransaction()
        self.assertEqual(outfile.read(), tzwrite + '\n')

        outfile = self.MakeTestScript()
        t = igd_time.TimeTZ(tzfile=outfile.name)
        t.StartTransaction()
        t.LocalTimeZoneName = tzwrite
        t.CommitTransaction()
        self.assertEqual(outfile.read(), tzwrite + '\n')
Beispiel #4
0
 def testSetLocalTimeZoneName(self):
     outfile = self.MakeTestScript()
     t = igd_time.TimeTZ(tzfile=outfile.name)
     expected = 'PST8PDT,M3.2.0/2,M11.1.0/2'
     t.StartTransaction()
     t.LocalTimeZoneName = expected
     t.CommitTransaction()
     self.assertEqual(outfile.read().strip(), expected)
Beispiel #5
0
 def testSetLocalTimeZoneName(self):
     t = igd_time.TimeTZ()
     t.LocalTimeZoneName = 'UTC0'
     self.loop.RunOnce(timeout=1)
     expectedTZ = 'UTC0\n'
     actualTZ = open(self.tzfile).read()
     self.assertEqual(actualTZ, expectedTZ)
     # UTCtzfile copied from /usr/share/zoneinfo/posix/UTC,
     # and modified with hex editor to remove the portions
     # not handled by igd_time.py
     expectedLT = open('testdata/igd_time/UTCtzfile').read()
     actualLT = open(self.localtimefile).read()
     self.assertEqual(actualLT, expectedLT)
Beispiel #6
0
 def testGetLocalTimeZoneName(self):
     t = igd_time.TimeTZ(tzfile='testdata/igd_time/TZ')
     self.assertEqual(t.LocalTimeZoneName, 'POSIX')
Beispiel #7
0
 def testCurrentLocalTime(self):
     t = igd_time.TimeTZ()
     self.assertEqual(t.CurrentLocalTime, '2009-02-13T23:31:30.987654Z')
Beispiel #8
0
 def testValidateExports(self):
     t = igd_time.TimeTZ()
     t.ValidateExports()
Beispiel #9
0
 def testGetLocalTimeZoneName(self):
     igd_time.TZFILE = 'testdata/igd_time/TZ'
     t = igd_time.TimeTZ()
     self.assertEqual(t.LocalTimeZoneName, 'POSIX')
Beispiel #10
0
 def testValidateExports(self):
     t = igd_time.TimeTZ()
     tr.handle.ValidateExports(t)
Beispiel #11
0
 def testTimeSyncedStatus(self):
     t = igd_time.TimeTZ()
     igd_time.TIMESYNCEDFILE = '/nonexistant'
     self.assertEqual(t.Status, 'Unsynchronized')
     igd_time.TIMESYNCEDFILE = 'testdata/igd_time/time.synced'
     self.assertEqual(t.Status, 'Synchronized')
Beispiel #12
0
 def testIncorrectPosixTzNotThatAcsWouldEverSendOneNopeNopeNope(self):
     t = igd_time.TimeTZ()
     t.LocalTimeZoneName = 'This is not a timezone'
     self.loop.RunOnce(timeout=1)
     self.assertFalse(os.path.exists(self.localtimefile))
     self.assertFalse(os.path.exists(self.tzfile))