1 # Copyright 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
11 from .parsed_trace_events import *
13 class LogIOTest(unittest.TestCase):
14 def test_enable_with_file(self):
15 file = tempfile.NamedTemporaryFile()
16 trace_enable(open(file.name, 'w+'))
18 e = ParsedTraceEvents(trace_filename = file.name)
20 self.assertTrue(len(e) > 0)
22 def test_enable_with_filename(self):
23 file = tempfile.NamedTemporaryFile()
24 trace_enable(file.name)
26 e = ParsedTraceEvents(trace_filename = file.name)
28 self.assertTrue(len(e) > 0)
30 def test_enable_with_implicit_filename(self):
31 expected_filename = "%s.json" % sys.argv[0]
33 file = tempfile.NamedTemporaryFile()
36 e = ParsedTraceEvents(trace_filename = expected_filename)
38 self.assertTrue(len(e) > 0)
42 if os.path.exists(expected_filename):
43 os.unlink(expected_filename)