Blame tests/test_needs_restarting.py

Packit 3a9065
# Copyright (C) 2014 Red Hat, Inc.
Packit 3a9065
#
Packit 3a9065
# This copyrighted material is made available to anyone wishing to use,
Packit 3a9065
# modify, copy, or redistribute it subject to the terms and conditions of
Packit 3a9065
# the GNU General Public License v.2, or (at your option) any later version.
Packit 3a9065
# This program is distributed in the hope that it will be useful, but WITHOUT
Packit 3a9065
# ANY WARRANTY expressed or implied, including the implied warranties of
Packit 3a9065
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
Packit 3a9065
# Public License for more details.  You should have received a copy of the
Packit 3a9065
# GNU General Public License along with this program; if not, write to the
Packit 3a9065
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit 3a9065
# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
Packit 3a9065
# source code or documentation are not subject to the GNU General Public
Packit 3a9065
# License and may only be used or replicated with the express permission of
Packit 3a9065
# Red Hat, Inc.
Packit 3a9065
#
Packit 3a9065
Packit 3a9065
Packit 3a9065
from __future__ import absolute_import
Packit 3a9065
from __future__ import print_function
Packit 3a9065
from __future__ import unicode_literals
Packit 3a9065
Packit 3a9065
import needs_restarting
Packit 3a9065
import tests.support
Packit 3a9065
Packit 3a9065
DEL_FILE = '3dcf000000-3dcf032000 r-xp 00000000 08:02 140759                ' \
Packit 3a9065
           '         /usr/lib64/libXfont.so.1.4.1;5408628d (deleted)'
Packit 3a9065
MM_FILE = '7fc4e1168000-7fc4e1169000 rw-s 1096dd000 00:05 7749' \
Packit 3a9065
          '                      /dev/dri/card0'
Packit 3a9065
SO_FILE = '30efe06000-30efe07000 r--p 00006000 08:02 139936' \
Packit 3a9065
          '                         /usr/lib64/libSM.so.6.0.1'
Packit 3a9065
Packit 3a9065
Packit 3a9065
class NeedsRestartingTest(tests.support.TestCase):
Packit 3a9065
    def test_smap2opened_file(self):
Packit 3a9065
        func = needs_restarting.smap2opened_file
Packit 3a9065
        self.assertIsNone(func(1, 'Shared_Dirty:          0 kB'))
Packit 3a9065
        self.assertIsNone(func(1, MM_FILE))
Packit 3a9065
Packit 3a9065
        ofile = func(5, SO_FILE)
Packit 3a9065
        self.assertFalse(ofile.deleted)
Packit 3a9065
        self.assertEqual(ofile.name, '/usr/lib64/libSM.so.6.0.1')
Packit 3a9065
        self.assertEqual(ofile.pid, 5)
Packit 3a9065
Packit 3a9065
        ofile = func(5, DEL_FILE)
Packit 3a9065
        self.assertTrue(ofile.deleted)
Packit 3a9065
        self.assertEqual(ofile.name, '/usr/lib64/libXfont.so.1.4.1;5408628d')
Packit 3a9065
Packit 3a9065
Packit 3a9065
class OpenedFileTest(tests.support.TestCase):
Packit 3a9065
    def test_presumed_name(self):
Packit 3a9065
        ofile = needs_restarting.OpenedFile(
Packit 3a9065
            100, '/usr/lib64/libgtk-3.so.0.1000.9;54085c6e', True)
Packit 3a9065
        self.assertEqual(ofile.presumed_name, '/usr/lib64/libgtk-3.so.0.1000.9')