Skip to content

Commit 914b551

Browse files
committed
[lldb/test] Add test for CMTime data formatter
Add a test for the CMTime data formatter. The coverage report showed that this code path was untested.
1 parent a6faf85 commit 914b551

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
OBJC_SOURCES := main.m
2+
3+
CFLAGS_EXTRAS := -w
4+
5+
LD_EXTRAS := -framework CoreMedia
6+
include Makefile.rules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# encoding: utf-8
2+
3+
import lldb
4+
from lldbsuite.test.decorators import *
5+
from lldbsuite.test.lldbtest import *
6+
from lldbsuite.test import lldbutil
7+
8+
9+
class CMTimeDataFormatterTestCase(TestBase):
10+
11+
mydir = TestBase.compute_mydir(__file__)
12+
13+
@skipUnlessDarwin
14+
def test_nsindexpath_with_run_command(self):
15+
"""Test formatters for CMTime."""
16+
self.build()
17+
self.runCmd("file " + self.getBuildArtifact("a.out"),
18+
CURRENT_EXECUTABLE_SET)
19+
20+
line = line_number('main.m', '// break here')
21+
lldbutil.run_break_set_by_file_and_line(
22+
self, "main.m", line, num_expected_locations=1, loc_exact=True)
23+
24+
self.runCmd("run", RUN_SUCCEEDED)
25+
26+
self.expect(
27+
"thread list",
28+
STOPPED_DUE_TO_BREAKPOINT,
29+
substrs=['stopped', 'stop reason = breakpoint'])
30+
31+
self.expect(
32+
'frame variable t1',
33+
substrs=[
34+
'1 10th of a second', 'value = 1', 'timescale = 10',
35+
'epoch = 0'
36+
])
37+
self.expect(
38+
'frame variable t2',
39+
substrs=['10 seconds', 'value = 10', 'timescale = 1', 'epoch = 0'])
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- main.m ------------------------------------------------*- ObjC -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#import <CoreMedia/CoreMedia.h>
10+
11+
int main(int argc, const char **argv)
12+
{
13+
@autoreleasepool
14+
{
15+
CMTime t1 = CMTimeMake(1, 10);
16+
CMTime t2 = CMTimeMake(10, 1);
17+
18+
CMTimeShow(t1); // break here
19+
CMTimeShow(t2);
20+
}
21+
return 0;
22+
}

0 commit comments

Comments
 (0)