• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright (C) 2023 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License a
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from python.generators.diff_tests.testing import Path
17from python.generators.diff_tests.testing import Csv
18from python.generators.diff_tests.testing import DiffTestBlueprint
19from python.generators.diff_tests.testing import TestSuite
20
21
22class ProtoLog(TestSuite):
23
24  def test_has_expected_protolog_rows(self):
25    return DiffTestBlueprint(
26        trace=Path('protolog.textproto'),
27        query="SELECT id, ts, level, tag, message, stacktrace FROM protolog;",
28        out=Csv("""
29        "id","ts","level","tag","message","stacktrace"
30        0,857384100,"DEBUG","MyFirstGroup","Test message with a string (MyTestString), an int (1776), a double 8.88, and a boolean true.","A STACK TRACE"
31        1,857384110,"WARN","MySecondGroup","Test message with different int formats: 1776, 0o3360, 0x6f0, 888.000000, 8.880000e+02.","[NULL]"
32        2,857384130,"ERROR","MyThirdGroup","Message re-using interned string 'MyOtherTestString' == 'MyOtherTestString', but 'SomeOtherTestString' != 'MyOtherTestString'","[NULL]"
33        """))
34
35  def test_handles_packet_loss(self):
36    return DiffTestBlueprint(
37        trace=Path('protolog_packet_loss.textproto'),
38        query="SELECT id, ts, level, tag, message, stacktrace FROM protolog;",
39        out=Csv("""
40        "id","ts","level","tag","message","stacktrace"
41        0,857384130,"DEBUG","MyFirstGroup","Test message with two strings: MyTestString and MyTestString","[NULL]"
42        1,857384130,"DEBUG","MyFirstGroup","Test message with two strings: MyNextTestString and MyNextTestString","[NULL]"
43        """))
44