• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (C) 2025 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 <android-base/file.h>
18 #include <android-base/parseint.h>
19 #include <android-base/properties.h>
20 #include <android-base/strings.h>
21 #include <gmock/gmock.h>
22 #include <gtest/gtest.h>
23 
24 class VtsGblTest : public testing::Test {};
25 
TEST_F(VtsGblTest,TestRunningProp)26 TEST_F(VtsGblTest, TestRunningProp) {
27   // TODO: Check assumptions. feature flag or API level?
28   const int32_t gbl_version =
29       android::base::GetIntProperty("ro.boot.gbl.version", -1);
30   const std::string build_number =
31       android::base::GetProperty("ro.boot.gbl.build_number", "");
32 
33   if (gbl_version == -1) {
34     GTEST_SKIP() << "Device not booted with GBL";
35   }
36 
37   GTEST_LOG_(INFO) << "GBL version: " << gbl_version;
38   GTEST_LOG_(INFO) << "GBL build_number: " << build_number;
39 
40   if (android::base::StartsWith(build_number, "eng.")) {
41     GTEST_LOG_(WARNING) << "GBL is a local eng build";
42   }
43   ASSERT_THAT(build_number, testing::MatchesRegex("P?[0-9]+"))
44       << "Invalid build ID";
45   if (build_number[0] == 'P') {
46     GTEST_LOG_(INFO) << "GBL appears to be a presubmit build";
47   } else {
48     uint64_t build_incremental = 0;
49     EXPECT_TRUE(android::base::ParseUint(build_number, &build_incremental))
50         << "Failed to parse build id";
51     // TODO: Update this number after build script is updated to embed build id
52     // in artifact
53     // EXPECT_GE(build_incremental, 12345678)
54     //     << "GBL build number should be at least ...";
55   }
56 }
57