root / test / py / ganeti.utils.mlock_unittest.py @ cb44e3db
History | View | Annotate | Download (1.5 kB)
1 | 4b6fa0bf | Luca Bigliardi | #!/usr/bin/python
|
---|---|---|---|
2 | 4b6fa0bf | Luca Bigliardi | #
|
3 | 4b6fa0bf | Luca Bigliardi | |
4 | 36a4acd4 | Michael Hanselmann | # Copyright (C) 2010, 2011 Google Inc.
|
5 | 4b6fa0bf | Luca Bigliardi | #
|
6 | 4b6fa0bf | Luca Bigliardi | # This program is free software; you can redistribute it and/or modify
|
7 | 4b6fa0bf | Luca Bigliardi | # it under the terms of the GNU General Public License as published by
|
8 | 4b6fa0bf | Luca Bigliardi | # the Free Software Foundation; either version 2 of the License, or
|
9 | 4b6fa0bf | Luca Bigliardi | # (at your option) any later version.
|
10 | 4b6fa0bf | Luca Bigliardi | #
|
11 | 4b6fa0bf | Luca Bigliardi | # This program is distributed in the hope that it will be useful, but
|
12 | 4b6fa0bf | Luca Bigliardi | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 4b6fa0bf | Luca Bigliardi | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 4b6fa0bf | Luca Bigliardi | # General Public License for more details.
|
15 | 4b6fa0bf | Luca Bigliardi | #
|
16 | 4b6fa0bf | Luca Bigliardi | # You should have received a copy of the GNU General Public License
|
17 | 4b6fa0bf | Luca Bigliardi | # along with this program; if not, write to the Free Software
|
18 | 4b6fa0bf | Luca Bigliardi | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | 4b6fa0bf | Luca Bigliardi | # 02110-1301, USA.
|
20 | 4b6fa0bf | Luca Bigliardi | |
21 | 4b6fa0bf | Luca Bigliardi | |
22 | 4b6fa0bf | Luca Bigliardi | """Script for testing utils.Mlockall
|
23 | 4b6fa0bf | Luca Bigliardi |
|
24 | 4b6fa0bf | Luca Bigliardi | This test is run in a separate process because it changes memory behaviour.
|
25 | 4b6fa0bf | Luca Bigliardi |
|
26 | 4b6fa0bf | Luca Bigliardi | """
|
27 | 4b6fa0bf | Luca Bigliardi | |
28 | 4b6fa0bf | Luca Bigliardi | import unittest |
29 | 4b6fa0bf | Luca Bigliardi | |
30 | 4b6fa0bf | Luca Bigliardi | from ganeti import utils |
31 | 4c32a8bd | Luca Bigliardi | from ganeti import errors |
32 | 4b6fa0bf | Luca Bigliardi | |
33 | 4b6fa0bf | Luca Bigliardi | import testutils |
34 | 4b6fa0bf | Luca Bigliardi | |
35 | 4b6fa0bf | Luca Bigliardi | |
36 | 36a4acd4 | Michael Hanselmann | # WARNING: The following tests modify the memory behaviour at runtime. Don't
|
37 | 36a4acd4 | Michael Hanselmann | # add unrelated tests here.
|
38 | 36a4acd4 | Michael Hanselmann | |
39 | 36a4acd4 | Michael Hanselmann | |
40 | 4c32a8bd | Luca Bigliardi | class TestMlockallWithCtypes(unittest.TestCase): |
41 | 4c32a8bd | Luca Bigliardi | """Whether Mlockall() works if ctypes is present.
|
42 | 4c32a8bd | Luca Bigliardi |
|
43 | 4c32a8bd | Luca Bigliardi | """
|
44 | 142c1ad0 | Guido Trotter | |
45 | 4c32a8bd | Luca Bigliardi | def test(self): |
46 | 4c32a8bd | Luca Bigliardi | if utils.ctypes:
|
47 | 142c1ad0 | Guido Trotter | utils.Mlockall() |
48 | 4c32a8bd | Luca Bigliardi | |
49 | 4c32a8bd | Luca Bigliardi | |
50 | 4c32a8bd | Luca Bigliardi | class TestMlockallWithNoCtypes(unittest.TestCase): |
51 | 4c32a8bd | Luca Bigliardi | """Whether Mlockall() raises an error if ctypes is not present.
|
52 | 4c32a8bd | Luca Bigliardi |
|
53 | 4c32a8bd | Luca Bigliardi | """
|
54 | 142c1ad0 | Guido Trotter | |
55 | 4b6fa0bf | Luca Bigliardi | def test(self): |
56 | 4c32a8bd | Luca Bigliardi | self.assertRaises(errors.NoCtypesError, utils.Mlockall, _ctypes=None) |
57 | 4b6fa0bf | Luca Bigliardi | |
58 | 4b6fa0bf | Luca Bigliardi | |
59 | 4b6fa0bf | Luca Bigliardi | if __name__ == "__main__": |
60 | 4b6fa0bf | Luca Bigliardi | testutils.GanetiTestProgram() |