Add toolchain_test.py to naclbuild.py
[nacl-build.git] / cmd_env_test.py
blobd4748df36c8dae85173e48f841843a2a5ffe8b31
1 # Copyright (C) Cmed Ltd, 2008, 2009
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU Lesser General Public License as
5 # published by the Free Software Foundation; either version 2.1 of the
6 # License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16 # 02110-1301, USA.
18 import os
19 import unittest
21 import cmd_env
24 class ProcessListTest(unittest.TestCase):
26 def test_list_processes(self):
27 # Assumes /proc is available
28 matches = [proc for proc in cmd_env.list_processes()
29 if proc.get_pid() == os.getpid()]
30 self.assertEquals(len(matches), 1)
31 self.assertEquals(matches[0].get_root_dir(), "/")
34 class IsPathBelowTest(unittest.TestCase):
36 def test(self):
37 cases = [("/foo", "/foobar", False),
38 ("/foo", "/bar", False),
39 ("/foo", "/foo/bar", True),
40 ("/foo/", "/foo/bar", True)]
41 for parent, child, is_below in cases:
42 self.assertEquals(cmd_env.is_path_below(parent, child), is_below)
45 if __name__ == "__main__":
46 unittest.main()