[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / native_client_sdk / src / tools / tests / sel_ldr_test.py
blob6ad696154221535d6911de68299e5e42010a7788
1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 import os
7 import sys
8 import unittest
10 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
11 PARENT_DIR = os.path.dirname(SCRIPT_DIR)
12 DATA_DIR = os.path.join(SCRIPT_DIR, 'data')
13 CHROME_SRC = os.path.dirname(os.path.dirname(os.path.dirname(PARENT_DIR)))
14 MOCK_DIR = os.path.join(CHROME_SRC, "third_party", "pymock")
16 # For the mock library
17 sys.path.append(MOCK_DIR)
18 sys.path.append(PARENT_DIR)
20 import sel_ldr
21 import mock
24 class TestSelLdr(unittest.TestCase):
25 def testRequiresArg(self):
26 with mock.patch('sys.stderr'):
27 self.assertRaises(SystemExit, sel_ldr.main, [])
29 def testUsesHelper(self):
30 with mock.patch('subprocess.call') as call:
31 with mock.patch('os.path.exists'):
32 with mock.patch('os.path.isfile'):
33 with mock.patch('create_nmf.ParseElfHeader') as parse_header:
34 parse_header.return_value = ('x8-64', False)
35 with mock.patch('getos.GetPlatform') as get_platform:
36 # assert that when we are running on linux
37 # the helper is used.
38 get_platform.return_value = 'linux'
39 sel_ldr.main(['foo.nexe'])
40 parse_header.assert_called_once_with('foo.nexe')
41 self.assertEqual(call.call_count, 1)
42 cmd = call.call_args[0][0]
43 self.assertTrue('helper_bootstrap' in cmd[0])
45 # assert that when not running on linux the
46 # helper is not used.
47 get_platform.reset_mock()
48 parse_header.reset_mock()
49 call.reset_mock()
50 get_platform.return_value = 'win'
51 sel_ldr.main(['foo.nexe'])
52 parse_header.assert_called_once_with('foo.nexe')
53 self.assertEqual(call.call_count, 1)
54 cmd = call.call_args[0][0]
55 self.assertTrue('helper_bootstrap' not in cmd[0])
58 if __name__ == '__main__':
59 unittest.main()