• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 at
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  */
16 
17 #include "src/trace_processor/prelude/table_functions/descendant.h"
18 
19 #include "src/trace_processor/prelude/table_functions/tables_py.h"
20 #include "test/gtest_and_gmock.h"
21 
22 namespace perfetto {
23 namespace trace_processor {
24 namespace {
25 
TEST(Ancestor,SliceTableNullConstraint)26 TEST(Ancestor, SliceTableNullConstraint) {
27   // Insert a row to make sure that we are not returning an empty table just
28   // because the source is empty.
29   TraceStorage storage;
30   storage.mutable_slice_table()->Insert({});
31 
32   Descendant generator{Descendant::Type::kSlice, &storage};
33 
34   // Check that if we pass start_id = NULL as a constraint, we correctly return
35   // an empty table.
36   std::unique_ptr<Table> res;
37   Constraint c{tables::DescendantSliceTable::ColumnIndex::start_id,
38                FilterOp::kEq, SqlValue()};
39   base::Status status = generator.ComputeTable({c}, {}, BitVector(), res);
40   ASSERT_TRUE(status.ok());
41   ASSERT_EQ(res->row_count(), 0u);
42 }
43 
TEST(Ancestor,SliceByStackTableNullConstraint)44 TEST(Ancestor, SliceByStackTableNullConstraint) {
45   // Insert a row to make sure that we are not returning an empty table just
46   // because the source is empty.
47   TraceStorage storage;
48   storage.mutable_slice_table()->Insert({});
49 
50   Descendant generator{Descendant::Type::kSliceByStack, &storage};
51 
52   // Check that if we pass start_id = NULL as a constraint, we correctly return
53   // an empty table.
54   std::unique_ptr<Table> res;
55   Constraint c{tables::DescendantSliceByStackTable::ColumnIndex::start_stack_id,
56                FilterOp::kEq, SqlValue()};
57   base::Status status = generator.ComputeTable({c}, {}, BitVector(), res);
58   ASSERT_TRUE(status.ok());
59   ASSERT_EQ(res->row_count(), 0u);
60 }
61 
62 }  // namespace
63 }  // namespace trace_processor
64 }  // namespace perfetto
65