summaryrefslogtreecommitdiffstats
path: root/tools/isolate/trace_inputs_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/isolate/trace_inputs_test.py')
-rwxr-xr-xtools/isolate/trace_inputs_test.py140
1 files changed, 71 insertions, 69 deletions
diff --git a/tools/isolate/trace_inputs_test.py b/tools/isolate/trace_inputs_test.py
index d95518c..22edf52 100755
--- a/tools/isolate/trace_inputs_test.py
+++ b/tools/isolate/trace_inputs_test.py
@@ -95,76 +95,78 @@ class TraceInputs(unittest.TestCase):
self._test(value, expected)
-class StraceInputs(unittest.TestCase):
- def _test_lines(self, lines, files, non_existent):
- context = trace_inputs.Strace.Context(lambda _: False)
- for line in lines:
- context.on_line(line)
- self.assertEquals(sorted(files), sorted(context.files))
- self.assertEquals(sorted(non_existent), sorted(context.non_existent))
-
- def test_empty(self):
- self._test_lines([], [], [])
-
- def test_close(self):
- lines = [
- '31426 close(7) = 0',
- ]
- self._test_lines(lines, [], [])
-
- def test_clone(self):
- # Grand-child with relative directory.
- lines = [
- '86 chdir("%s") = 0' % ROOT_DIR,
- '86 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID'
- '|SIGCHLD, child_tidptr=0x7f5350f829d0) = 14',
- ') = ? <unavailable>',
- '14 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID'
- '|SIGCHLD, child_tidptr=0x7f5350f829d0) = 70',
- '14 close(75) = 0',
- '70 open("%s", O_RDONLY) = 76' % os.path.basename(FILE_NAME),
- ]
- files = [
- FILE_NAME,
- ]
- self._test_lines(lines, files, [])
-
- def test_open(self):
- lines = [
- '42 chdir("/home/foo_bar_user/src") = 0',
- '42 execve("../out/unittests", '
- '["../out/unittests"...], [/* 44 vars */]) = 0',
- '42 open("out/unittests.log", O_WRONLY|O_CREAT|O_APPEND, 0666) = 8',
- ]
- files = [
- '/home/foo_bar_user/src/../out/unittests',
- '/home/foo_bar_user/src/out/unittests.log',
- ]
- self._test_lines(lines, [], files)
-
- def test_open_resumed(self):
- lines = [
- '42 chdir("/home/foo_bar_user/src") = 0',
- '42 execve("../out/unittests", '
- '["../out/unittests"...], [/* 44 vars */]) = 0',
- '42 open("out/unittests.log", O_WRONLY|O_CREAT|O_APPEND <unfinished ...>',
- '42 <... open resumed> ) = 3',
- ]
- files = [
- '/home/foo_bar_user/src/../out/unittests',
- '/home/foo_bar_user/src/out/unittests.log',
- ]
- self._test_lines(lines, [], files)
-
- def test_sig_unexpected(self):
- lines = [
- '27 exit_group(0) = ?',
- ]
- try:
+if trace_inputs.get_flavor() == 'linux':
+ class StraceInputs(unittest.TestCase):
+ def _test_lines(self, lines, files, non_existent):
+ context = trace_inputs.Strace.Context(lambda _: False)
+ for line in lines:
+ context.on_line(line)
+ self.assertEquals(sorted(files), sorted(context.files))
+ self.assertEquals(sorted(non_existent), sorted(context.non_existent))
+
+ def test_empty(self):
+ self._test_lines([], [], [])
+
+ def test_close(self):
+ lines = [
+ '31426 close(7) = 0',
+ ]
self._test_lines(lines, [], [])
- self.fail()
- except KeyError, e:
- self.assertEqual(27, e.args[0])
+
+ def test_clone(self):
+ # Grand-child with relative directory.
+ lines = [
+ '86 chdir("%s") = 0' % ROOT_DIR,
+ '86 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID'
+ '|SIGCHLD, child_tidptr=0x7f5350f829d0) = 14',
+ ') = ? <unavailable>',
+ '14 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID'
+ '|SIGCHLD, child_tidptr=0x7f5350f829d0) = 70',
+ '14 close(75) = 0',
+ '70 open("%s", O_RDONLY) = 76' % os.path.basename(FILE_NAME),
+ ]
+ files = [
+ FILE_NAME,
+ ]
+ self._test_lines(lines, files, [])
+
+ def test_open(self):
+ lines = [
+ '42 chdir("/home/foo_bar_user/src") = 0',
+ '42 execve("../out/unittests", '
+ '["../out/unittests"...], [/* 44 vars */]) = 0',
+ '42 open("out/unittests.log", O_WRONLY|O_CREAT|O_APPEND, 0666) = 8',
+ ]
+ files = [
+ '/home/foo_bar_user/src/../out/unittests',
+ '/home/foo_bar_user/src/out/unittests.log',
+ ]
+ self._test_lines(lines, [], files)
+
+ def test_open_resumed(self):
+ lines = [
+ '42 chdir("/home/foo_bar_user/src") = 0',
+ '42 execve("../out/unittests", '
+ '["../out/unittests"...], [/* 44 vars */]) = 0',
+ '42 open("out/unittests.log", O_WRONLY|O_CREAT|O_APPEND '
+ '<unfinished ...>',
+ '42 <... open resumed> ) = 3',
+ ]
+ files = [
+ '/home/foo_bar_user/src/../out/unittests',
+ '/home/foo_bar_user/src/out/unittests.log',
+ ]
+ self._test_lines(lines, [], files)
+
+ def test_sig_unexpected(self):
+ lines = [
+ '27 exit_group(0) = ?',
+ ]
+ try:
+ self._test_lines(lines, [], [])
+ self.fail()
+ except KeyError, e:
+ self.assertEqual(27, e.args[0])
if __name__ == '__main__':