Restore compatibility with non-linux operating systems
This partially reverts fce48c2893 which
removes windows support along with the other non-linux operating
systems.
Some developers may run unit tests on non-linux operating systems such
as mac OS, and this avoids hard-failure in such usage.
Change-Id: Ia0deb0bce2b87df0297178c75b41f7bf065ddf2d
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
committed by
Takashi Kajinami
parent
699b3ca96b
commit
c343be92a6
@@ -14,6 +14,7 @@
|
||||
|
||||
import enum
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
import cffi
|
||||
@@ -113,10 +114,17 @@ ffi = cffi.FFI()
|
||||
ffi.cdef(CDEF)
|
||||
|
||||
|
||||
crt = ffi.dlopen(None)
|
||||
_prctl = crt.prctl
|
||||
_capget = crt.capget
|
||||
_capset = crt.capset
|
||||
if platform.system() == 'Linux':
|
||||
# mock.patching crt.* directly seems to upset cffi. Use an
|
||||
# indirection point here for easier testing.
|
||||
crt = ffi.dlopen(None)
|
||||
_prctl = crt.prctl
|
||||
_capget = crt.capget
|
||||
_capset = crt.capset
|
||||
else:
|
||||
_prctl = None
|
||||
_capget = None
|
||||
_capset = None
|
||||
|
||||
|
||||
def set_keepcaps(enable):
|
||||
|
||||
@@ -46,11 +46,9 @@ The privsep daemon exits when the communication channel is closed,
|
||||
from concurrent import futures
|
||||
import enum
|
||||
import errno
|
||||
import fcntl
|
||||
import grp
|
||||
import logging as pylogging
|
||||
import os
|
||||
import pwd
|
||||
import platform
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -70,6 +68,11 @@ from oslo_privsep._i18n import _
|
||||
from oslo_privsep import capabilities
|
||||
from oslo_privsep import comm
|
||||
|
||||
if platform.system() == 'Linux':
|
||||
import fcntl
|
||||
import grp
|
||||
import pwd
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import eventlet
|
||||
import fixtures
|
||||
import functools
|
||||
import logging as pylogging
|
||||
import platform
|
||||
import sys
|
||||
import time
|
||||
from unittest import mock
|
||||
@@ -24,6 +25,7 @@ from unittest import mock
|
||||
from oslo_log import formatters
|
||||
from oslo_log import log as logging
|
||||
from oslotest import base
|
||||
import testtools
|
||||
|
||||
from oslo_privsep import capabilities
|
||||
from oslo_privsep import comm
|
||||
@@ -86,6 +88,8 @@ class LogRecorder(pylogging.Formatter):
|
||||
return super().format(record)
|
||||
|
||||
|
||||
@testtools.skipIf(platform.system() != 'Linux',
|
||||
'works only on Linux platform.')
|
||||
class LogTest(testctx.TestContextTestCase):
|
||||
def test_priv_loglevel(self):
|
||||
logger = self.useFixture(fixtures.FakeLogger(
|
||||
@@ -153,6 +157,8 @@ class LogTest(testctx.TestContextTestCase):
|
||||
formatter.format(record)
|
||||
|
||||
|
||||
@testtools.skipIf(platform.system() != 'Linux',
|
||||
'works only on Linux platform.')
|
||||
class LogTestDaemonTraceback(testctx.TestContextTestCase):
|
||||
def setUp(self):
|
||||
self.config_override = {'log_daemon_traceback': True}
|
||||
@@ -179,6 +185,8 @@ class LogTestDaemonTraceback(testctx.TestContextTestCase):
|
||||
self.assertEqual(logging.WARN, record.levelno)
|
||||
|
||||
|
||||
@testtools.skipIf(platform.system() != 'Linux',
|
||||
'works only on Linux platform.')
|
||||
class DaemonTest(base.BaseTestCase):
|
||||
|
||||
@mock.patch('os.setuid')
|
||||
@@ -215,6 +223,8 @@ class DaemonTest(base.BaseTestCase):
|
||||
[])
|
||||
|
||||
|
||||
@testtools.skipIf(platform.system() != 'Linux',
|
||||
'works only on Linux platform.')
|
||||
class WithContextTest(testctx.TestContextTestCase):
|
||||
|
||||
def test_unexported(self):
|
||||
|
||||
@@ -15,12 +15,15 @@
|
||||
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import shlex
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
import testtools
|
||||
|
||||
from oslo_privsep import comm
|
||||
from oslo_privsep import daemon
|
||||
from oslo_privsep import priv_context
|
||||
@@ -63,6 +66,8 @@ def fail(custom=False):
|
||||
raise RuntimeError("I can't let you do that Dave")
|
||||
|
||||
|
||||
@testtools.skipIf(platform.system() != 'Linux',
|
||||
'works only on Linux platform.')
|
||||
class PrivContextTest(testctx.TestContextTestCase):
|
||||
|
||||
def test_set_client_mode(self):
|
||||
@@ -129,6 +134,8 @@ class PrivContextTest(testctx.TestContextTestCase):
|
||||
self.assertTrue(context.start_lock.__enter__.called)
|
||||
|
||||
|
||||
@testtools.skipIf(platform.system() != 'Linux',
|
||||
'works only on Linux platform.')
|
||||
class SeparationTest(testctx.TestContextTestCase):
|
||||
def test_getpid(self):
|
||||
# Verify that priv_getpid() was executed in another process.
|
||||
@@ -149,6 +156,8 @@ class SeparationTest(testctx.TestContextTestCase):
|
||||
self.assertNotMyPid(priv_getpid())
|
||||
|
||||
|
||||
@testtools.skipIf(platform.system() != 'Linux',
|
||||
'works only on Linux platform.')
|
||||
class RootwrapTest(testctx.TestContextTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
@@ -186,6 +195,8 @@ class RootwrapTest(testctx.TestContextTestCase):
|
||||
self.assertEqual(42, res)
|
||||
|
||||
|
||||
@testtools.skipIf(platform.system() != 'Linux',
|
||||
'works only on Linux platform.')
|
||||
class SerializationTest(testctx.TestContextTestCase):
|
||||
def test_basic_functionality(self):
|
||||
self.assertEqual(43, add1(42))
|
||||
|
||||
Reference in New Issue
Block a user