xref: /aosp_15_r20/external/executorch/runtime/platform/test/executor_pal_test.cpp (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #include <gtest/gtest.h>
10 
11 #include <executorch/runtime/platform/platform.h>
12 
TEST(ExecutorPalTest,Initialization)13 TEST(ExecutorPalTest, Initialization) {
14   /*
15    * Ensure `et_pal_init` can be called multiple times.
16    * It has already been called once in the main() function.
17    */
18   et_pal_init();
19 }
20 
TEST(ExecutorPalTest,TimestampCoherency)21 TEST(ExecutorPalTest, TimestampCoherency) {
22   et_pal_init();
23 
24   et_timestamp_t time_a = et_pal_current_ticks();
25   ASSERT_TRUE(time_a >= 0);
26 
27   et_timestamp_t time_b = et_pal_current_ticks();
28   ASSERT_TRUE(time_b >= time_a);
29 }
30 
TEST(ExecutorPalTest,TickRateRatioSanity)31 TEST(ExecutorPalTest, TickRateRatioSanity) {
32   auto tick_ns_ratio = et_pal_ticks_to_ns_multiplier();
33   ASSERT_TRUE(tick_ns_ratio.numerator > 0);
34   ASSERT_TRUE(tick_ns_ratio.denominator > 0);
35 }
36