chromium/third_party/perfetto/src/trace_processor/importers/common/clock_tracker_unittest.cc

/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "src/trace_processor/importers/common/clock_tracker.h"

#include <optional>
#include <random>

#include "src/trace_processor/importers/common/machine_tracker.h"
#include "src/trace_processor/importers/common/metadata_tracker.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/types/trace_processor_context.h"
#include "test/gtest_and_gmock.h"

#include "protos/perfetto/common/builtin_clock.pbzero.h"
#include "protos/perfetto/trace/clock_snapshot.pbzero.h"

namespace perfetto {
namespace trace_processor {

class ClockTrackerTest : public ::testing::Test {};

namespace {

NiceMock;
Clock;

constexpr auto REALTIME =;
constexpr auto BOOTTIME =;
constexpr auto MONOTONIC =;
constexpr auto MONOTONIC_COARSE =;
constexpr auto MONOTONIC_RAW =;

TEST_F(ClockTrackerTest, ClockDomainConversions) {}

TEST_F(ClockTrackerTest, ToTraceTimeFromSnapshot) {}

// When a clock moves backwards conversions *from* that clock are forbidden
// but conversions *to* that clock should still work.
// Think to the case of REALTIME going backwards from 3AM to 2AM during DST day.
// You can't convert 2.10AM REALTIME to BOOTTIME because there are two possible
// answers, but you can still unambiguosly convert BOOTTIME into REALTIME.
TEST_F(ClockTrackerTest, RealTimeClockMovingBackwards) {}

// Simulate the following scenario:
// MONOTONIC = MONOTONIC_COARSE + 10
// BOOTTIME = MONOTONIC + 1000 (until T=200)
// BOOTTIME = MONOTONIC + 2000 (from T=200)
// Then resolve MONOTONIC_COARSE. This requires a two-level resolution:
// MONOTONIC_COARSE -> MONOTONIC -> BOOTTIME.
TEST_F(ClockTrackerTest, ChainedResolutionSimple) {}

TEST_F(ClockTrackerTest, ChainedResolutionHard) {}

// Regression test for b/158182858. When taking two snapshots back-to-back,
// MONOTONIC_COARSE might be stuck to the last value. We should still be able
// to convert both ways in this case.
TEST_F(ClockTrackerTest, NonStrictlyMonotonic) {}

TEST_F(ClockTrackerTest, SequenceScopedClocks) {}

// Tests that the cache doesn't affect the results of Convert() in unexpected
// ways.
TEST_F(ClockTrackerTest, CacheDoesntAffectResults) {}

// Test clock conversion with offset to the host.
TEST_F(ClockTrackerTest, ClockOffset) {}

// Test conversion of remote machine timestamps without offset. This can happen
// if timestamp conversion for remote machines is done by trace data
// post-processing.
TEST_F(ClockTrackerTest, RemoteNoClockOffset) {}

// Test clock offset of non-defualt trace time clock domain.
TEST_F(ClockTrackerTest, NonDefaultTraceTimeClock) {}

}  // namespace
}  // namespace trace_processor
}  // namespace perfetto