Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD fixes for the test suite #86

Merged
merged 1 commit into from
Dec 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ Robert Flemming <flemming@google.com>
Jeff Bailey <jeffbailey@google.com>
ohookins@gmail.com
mimianddaniel@gmail.com
Kevin Bowling
Kevin Bowling <kbowling@freebsd.org>
Joshua Pereyda
14 changes: 10 additions & 4 deletions nss_cache/caches/caches_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
__author__ = 'jaq@google.com (Jamie Wilkinson)'

import os
import platform
import stat
import tempfile
import unittest
Expand Down Expand Up @@ -48,24 +49,29 @@ class TestCls(mox.MoxTestBase):
def setUp(self):
self.workdir = tempfile.mkdtemp()
self.config = {'dir': self.workdir}
if platform.system() == 'FreeBSD':
# FreeBSD doesn't have a shadow file
self.shadow = config.MAP_PASSWORD
else:
self.shadow = config.MAP_SHADOW

def tearDown(self):
os.rmdir(self.workdir)

def testCopyOwnerMissing(self):
expected = os.stat(os.path.join('/etc', config.MAP_SHADOW))
expected = os.stat(os.path.join('/etc', self.shadow))
expected = stat.S_IMODE(expected.st_mode)
cache = FakeCacheCls(config=self.config, map_name=config.MAP_SHADOW)
cache = FakeCacheCls(config=self.config, map_name=self.shadow)
cache._Begin()
cache._Commit()
data = os.stat(os.path.join(self.workdir, cache.GetCacheFilename()))
self.assertEqual(expected, stat.S_IMODE(data.st_mode))
os.unlink(cache.GetCacheFilename())

def testCopyOwnerPresent(self):
expected = os.stat(os.path.join('/etc/', config.MAP_SHADOW))
expected = os.stat(os.path.join('/etc/', self.shadow))
expected = stat.S_IMODE(expected.st_mode)
cache = FakeCacheCls(config=self.config, map_name=config.MAP_SHADOW)
cache = FakeCacheCls(config=self.config, map_name=self.shadow)
cache._Begin()
cache._Commit()
data = os.stat(os.path.join(self.workdir, cache.GetCacheFilename()))
Expand Down
4 changes: 2 additions & 2 deletions nss_cache/command_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,8 @@ def testGetSingleMapMetadataTimestampEpochFalse(self):
c = command.Status()
values = c.GetSingleMapMetadata(config.MAP_PASSWORD, self.conf,
epoch=False)
self.failUnlessEqual('Wed Dec 31 16:00:02 1969',
values[1]['value'])
self.failUnless(values[1]['value'] in ['Wed Dec 31 16:00:02 1969',
'Thu Jan 1 00:00:02 1970'])

def testGetAutomountMapMetadata(self):
# need to stub out GetSingleMapMetadata (tested above) and then
Expand Down
2 changes: 1 addition & 1 deletion nss_cache/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def Lock(self, force=False):
fcntl.lockf(self._file, fcntl.LOCK_EX | fcntl.LOCK_NB)
return_val = True
except IOError, e:
if e.errno == fcntl.F_GETSIG:
if e.errno in [errno.EACCES, errno.EAGAIN]:
# Catch the error raised when the file is locked.
if not force:
self.log.debug('%s already locked!', self.filename)
Expand Down
4 changes: 2 additions & 2 deletions nss_cache/lock_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ def testForceLockTerminatesAndClearsLock(self):
self.mox.StubOutWithMock(fcntl, 'lockf')
fcntl.lockf(locker._file,
fcntl.LOCK_EX | fcntl.LOCK_NB).AndRaise(
IOError(fcntl.F_GETSIG, ''))
IOError(errno.EAGAIN, ''))
fcntl.lockf(locker._file,
fcntl.LOCK_EX | fcntl.LOCK_NB).AndRaise(
IOError(fcntl.F_GETSIG, ''))
IOError(errno.EAGAIN, ''))
self.mox.ReplayAll()

# This is a little weird due to recursion.
Expand Down
2 changes: 1 addition & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ def runAllTests(self):


if __name__ == '__main__':
os.chdir(os.path.dirname(sys.argv[0]))
os.chdir(sys.path[0])
NsscacheTestProgram()