How would you test it? Check a rule that holds for every input
Beyond the examples, test a property that has to hold for every input. In each stretch between two samples, either the stack is empty or exactly one call is innermost. So the self times must add up to the time the stack wasn't empty.
The test below checks that on 3,000 random runs, against the practice problem's two functions. trace(samples) turns the samples into start and end events, and function_times(events, include_callees=False) gives each function's self time from them. busy_time(samples) is the time the stack wasn't empty, and you write it in the editor:
import random
def test_self_times_add_up_to_busy_time():
rng = random.Random(3)
for _ in range(3000):
t, samples = 0, []
for _ in range(rng.randint(0, 8)):
t += rng.randint(1, 5)
samples.append((t, [rng.choice("abc") for _ in range(rng.randint(0, 4))]))
own = function_times(trace(samples), include_callees=False)
assert sum(own.values()) == busy_time(samples)
Random stacks over three names hit recursion, new callers and empty stacks far more often than hand-written cases do.
In the editor, write busy_time(samples): add up each gap between neighboring samples where the first sample's stack isn't empty. With it, the test passes on all 3,000 runs.