Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | /* |
| 18 | * The tests in this file operate on a higher level than the tests in the other |
| 19 | * files. Here, all tests execute the idmap2 binary and only depend on |
| 20 | * libidmap2 to verify the output of idmap2. |
| 21 | */ |
| 22 | #include <fcntl.h> |
| 23 | #include <sys/stat.h> |
| 24 | #include <sys/types.h> |
| 25 | #include <sys/wait.h> |
| 26 | #include <unistd.h> |
| 27 | |
| 28 | #include <cerrno> |
| 29 | #include <cstdlib> |
| 30 | #include <cstring> // strerror |
| 31 | #include <fstream> |
| 32 | #include <memory> |
| 33 | #include <sstream> |
| 34 | #include <string> |
| 35 | #include <vector> |
| 36 | |
| 37 | #include "gmock/gmock.h" |
| 38 | #include "gtest/gtest.h" |
| 39 | |
| 40 | #include "androidfw/PosixUtils.h" |
Mårten Kongstad | 1da49dc | 2019-01-14 10:03:53 +0100 | [diff] [blame] | 41 | #include "private/android_filesystem_config.h" |
Mårten Kongstad | d10d06d | 2019-01-07 17:26:25 -0800 | [diff] [blame] | 42 | |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 43 | #include "idmap2/FileUtils.h" |
| 44 | #include "idmap2/Idmap.h" |
| 45 | |
| 46 | #include "TestHelpers.h" |
| 47 | |
| 48 | using ::android::util::ExecuteBinary; |
| 49 | using ::testing::NotNull; |
| 50 | |
Mårten Kongstad | 0eba72a | 2018-11-29 08:23:14 +0100 | [diff] [blame] | 51 | namespace android::idmap2 { |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 52 | |
| 53 | class Idmap2BinaryTests : public Idmap2Tests {}; |
| 54 | |
Mårten Kongstad | 744ccfe | 2018-12-20 14:56:14 +0100 | [diff] [blame] | 55 | namespace { |
| 56 | |
| 57 | void AssertIdmap(const Idmap& idmap, const std::string& target_apk_path, |
| 58 | const std::string& overlay_apk_path) { |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 59 | // check that the idmap file looks reasonable (IdmapTests is responsible for |
| 60 | // more in-depth verification) |
| 61 | ASSERT_EQ(idmap.GetHeader()->GetMagic(), kIdmapMagic); |
| 62 | ASSERT_EQ(idmap.GetHeader()->GetVersion(), kIdmapCurrentVersion); |
| 63 | ASSERT_EQ(idmap.GetHeader()->GetTargetPath(), target_apk_path); |
| 64 | ASSERT_EQ(idmap.GetHeader()->GetOverlayPath(), overlay_apk_path); |
Mårten Kongstad | b877902 | 2018-11-29 09:53:17 +0100 | [diff] [blame] | 65 | ASSERT_EQ(idmap.GetData().size(), 1U); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | #define ASSERT_IDMAP(idmap_ref, target_apk_path, overlay_apk_path) \ |
| 69 | do { \ |
| 70 | ASSERT_NO_FATAL_FAILURE(AssertIdmap(idmap_ref, target_apk_path, overlay_apk_path)); \ |
| 71 | } while (0) |
| 72 | |
Mårten Kongstad | 1da49dc | 2019-01-14 10:03:53 +0100 | [diff] [blame] | 73 | #ifdef __ANDROID__ |
| 74 | #define SKIP_TEST_IF_CANT_EXEC_IDMAP2 \ |
| 75 | do { \ |
| 76 | const uid_t uid = getuid(); \ |
| 77 | if (uid != AID_ROOT && uid != AID_SYSTEM) { \ |
| 78 | GTEST_SKIP(); \ |
| 79 | } \ |
| 80 | } while (0) |
| 81 | #else |
| 82 | #define SKIP_TEST_IF_CANT_EXEC_IDMAP2 |
| 83 | #endif |
| 84 | |
Mårten Kongstad | 744ccfe | 2018-12-20 14:56:14 +0100 | [diff] [blame] | 85 | } // namespace |
| 86 | |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 87 | TEST_F(Idmap2BinaryTests, Create) { |
Mårten Kongstad | 1da49dc | 2019-01-14 10:03:53 +0100 | [diff] [blame] | 88 | SKIP_TEST_IF_CANT_EXEC_IDMAP2; |
| 89 | |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 90 | // clang-format off |
| 91 | auto result = ExecuteBinary({"idmap2", |
| 92 | "create", |
| 93 | "--target-apk-path", GetTargetApkPath(), |
| 94 | "--overlay-apk-path", GetOverlayApkPath(), |
| 95 | "--idmap-path", GetIdmapPath()}); |
| 96 | // clang-format on |
| 97 | ASSERT_THAT(result, NotNull()); |
| 98 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 99 | |
| 100 | struct stat st; |
| 101 | ASSERT_EQ(stat(GetIdmapPath().c_str(), &st), 0); |
| 102 | |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 103 | std::ifstream fin(GetIdmapPath()); |
Mårten Kongstad | ce42490 | 2019-03-01 08:35:37 +0100 | [diff] [blame] | 104 | const auto idmap = Idmap::FromBinaryStream(fin); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 105 | fin.close(); |
| 106 | |
Mårten Kongstad | ce42490 | 2019-03-01 08:35:37 +0100 | [diff] [blame] | 107 | ASSERT_TRUE(idmap); |
| 108 | ASSERT_IDMAP(**idmap, GetTargetApkPath(), GetOverlayApkPath()); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 109 | |
| 110 | unlink(GetIdmapPath().c_str()); |
| 111 | } |
| 112 | |
| 113 | TEST_F(Idmap2BinaryTests, Dump) { |
Mårten Kongstad | 1da49dc | 2019-01-14 10:03:53 +0100 | [diff] [blame] | 114 | SKIP_TEST_IF_CANT_EXEC_IDMAP2; |
| 115 | |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 116 | // clang-format off |
| 117 | auto result = ExecuteBinary({"idmap2", |
| 118 | "create", |
| 119 | "--target-apk-path", GetTargetApkPath(), |
| 120 | "--overlay-apk-path", GetOverlayApkPath(), |
| 121 | "--idmap-path", GetIdmapPath()}); |
| 122 | // clang-format on |
| 123 | ASSERT_THAT(result, NotNull()); |
| 124 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 125 | |
| 126 | // clang-format off |
| 127 | result = ExecuteBinary({"idmap2", |
| 128 | "dump", |
| 129 | "--idmap-path", GetIdmapPath()}); |
| 130 | // clang-format on |
| 131 | ASSERT_THAT(result, NotNull()); |
| 132 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 133 | ASSERT_NE(result->stdout.find("0x7f010000 -> 0x7f010000 integer/int1"), std::string::npos); |
Winson | b410020 | 2019-02-06 12:05:32 -0800 | [diff] [blame] | 134 | ASSERT_NE(result->stdout.find("0x7f02000a -> 0x7f020000 string/str1"), std::string::npos); |
| 135 | ASSERT_NE(result->stdout.find("0x7f02000c -> 0x7f020001 string/str3"), std::string::npos); |
| 136 | ASSERT_NE(result->stdout.find("0x7f02000d -> 0x7f020002 string/str4"), std::string::npos); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 137 | ASSERT_EQ(result->stdout.find("00000210: 007f target package id"), std::string::npos); |
| 138 | |
| 139 | // clang-format off |
| 140 | result = ExecuteBinary({"idmap2", |
| 141 | "dump", |
| 142 | "--verbose", |
| 143 | "--idmap-path", GetIdmapPath()}); |
| 144 | // clang-format on |
| 145 | ASSERT_THAT(result, NotNull()); |
| 146 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 147 | ASSERT_NE(result->stdout.find("00000000: 504d4449 magic"), std::string::npos); |
| 148 | ASSERT_NE(result->stdout.find("00000210: 007f target package id"), std::string::npos); |
| 149 | |
| 150 | // clang-format off |
| 151 | result = ExecuteBinary({"idmap2", |
| 152 | "dump", |
| 153 | "--verbose", |
| 154 | "--idmap-path", GetTestDataPath() + "/DOES-NOT-EXIST"}); |
| 155 | // clang-format on |
| 156 | ASSERT_THAT(result, NotNull()); |
| 157 | ASSERT_NE(result->status, EXIT_SUCCESS); |
| 158 | |
| 159 | unlink(GetIdmapPath().c_str()); |
| 160 | } |
| 161 | |
| 162 | TEST_F(Idmap2BinaryTests, Scan) { |
Mårten Kongstad | 1da49dc | 2019-01-14 10:03:53 +0100 | [diff] [blame] | 163 | SKIP_TEST_IF_CANT_EXEC_IDMAP2; |
| 164 | |
Ryan Mitchell | 1982345 | 2019-01-29 12:01:24 -0800 | [diff] [blame] | 165 | const std::string overlay_static_no_name_apk_path = |
| 166 | GetTestDataPath() + "/overlay/overlay-no-name-static.apk"; |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 167 | const std::string overlay_static_1_apk_path = GetTestDataPath() + "/overlay/overlay-static-1.apk"; |
| 168 | const std::string overlay_static_2_apk_path = GetTestDataPath() + "/overlay/overlay-static-2.apk"; |
Ryan Mitchell | 1982345 | 2019-01-29 12:01:24 -0800 | [diff] [blame] | 169 | const std::string idmap_static_no_name_path = |
| 170 | Idmap::CanonicalIdmapPathFor(GetTempDirPath(), overlay_static_no_name_apk_path); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 171 | const std::string idmap_static_1_path = |
| 172 | Idmap::CanonicalIdmapPathFor(GetTempDirPath(), overlay_static_1_apk_path); |
| 173 | const std::string idmap_static_2_path = |
| 174 | Idmap::CanonicalIdmapPathFor(GetTempDirPath(), overlay_static_2_apk_path); |
| 175 | |
| 176 | // single input directory, recursive |
| 177 | // clang-format off |
| 178 | auto result = ExecuteBinary({"idmap2", |
| 179 | "scan", |
| 180 | "--input-directory", GetTestDataPath(), |
| 181 | "--recursive", |
| 182 | "--target-package-name", "test.target", |
| 183 | "--target-apk-path", GetTargetApkPath(), |
Mårten Kongstad | d10d06d | 2019-01-07 17:26:25 -0800 | [diff] [blame] | 184 | "--output-directory", GetTempDirPath(), |
| 185 | "--override-policy", "public"}); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 186 | // clang-format on |
| 187 | ASSERT_THAT(result, NotNull()); |
| 188 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 189 | std::stringstream expected; |
Ryan Mitchell | 1982345 | 2019-01-29 12:01:24 -0800 | [diff] [blame] | 190 | expected << idmap_static_no_name_path << std::endl; |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 191 | expected << idmap_static_1_path << std::endl; |
| 192 | expected << idmap_static_2_path << std::endl; |
| 193 | ASSERT_EQ(result->stdout, expected.str()); |
| 194 | |
Ryan Mitchell | 1982345 | 2019-01-29 12:01:24 -0800 | [diff] [blame] | 195 | auto idmap_static_no_name_raw_string = utils::ReadFile(idmap_static_no_name_path); |
| 196 | auto idmap_static_no_name_raw_stream = std::istringstream(*idmap_static_no_name_raw_string); |
Mårten Kongstad | ce42490 | 2019-03-01 08:35:37 +0100 | [diff] [blame] | 197 | auto idmap_static_no_name = Idmap::FromBinaryStream(idmap_static_no_name_raw_stream); |
| 198 | ASSERT_TRUE(idmap_static_no_name); |
| 199 | ASSERT_IDMAP(**idmap_static_no_name, GetTargetApkPath(), overlay_static_no_name_apk_path); |
Ryan Mitchell | 1982345 | 2019-01-29 12:01:24 -0800 | [diff] [blame] | 200 | |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 201 | auto idmap_static_1_raw_string = utils::ReadFile(idmap_static_1_path); |
| 202 | auto idmap_static_1_raw_stream = std::istringstream(*idmap_static_1_raw_string); |
Mårten Kongstad | ce42490 | 2019-03-01 08:35:37 +0100 | [diff] [blame] | 203 | auto idmap_static_1 = Idmap::FromBinaryStream(idmap_static_1_raw_stream); |
| 204 | ASSERT_TRUE(idmap_static_1); |
| 205 | ASSERT_IDMAP(**idmap_static_1, GetTargetApkPath(), overlay_static_1_apk_path); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 206 | |
| 207 | auto idmap_static_2_raw_string = utils::ReadFile(idmap_static_2_path); |
| 208 | auto idmap_static_2_raw_stream = std::istringstream(*idmap_static_2_raw_string); |
Mårten Kongstad | ce42490 | 2019-03-01 08:35:37 +0100 | [diff] [blame] | 209 | auto idmap_static_2 = Idmap::FromBinaryStream(idmap_static_2_raw_stream); |
| 210 | ASSERT_TRUE(idmap_static_2); |
| 211 | ASSERT_IDMAP(**idmap_static_2, GetTargetApkPath(), overlay_static_2_apk_path); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 212 | |
Ryan Mitchell | 1982345 | 2019-01-29 12:01:24 -0800 | [diff] [blame] | 213 | unlink(idmap_static_no_name_path.c_str()); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 214 | unlink(idmap_static_2_path.c_str()); |
| 215 | unlink(idmap_static_1_path.c_str()); |
| 216 | |
| 217 | // multiple input directories, non-recursive |
| 218 | // clang-format off |
| 219 | result = ExecuteBinary({"idmap2", |
| 220 | "scan", |
| 221 | "--input-directory", GetTestDataPath() + "/target", |
| 222 | "--input-directory", GetTestDataPath() + "/overlay", |
| 223 | "--target-package-name", "test.target", |
| 224 | "--target-apk-path", GetTargetApkPath(), |
Mårten Kongstad | d10d06d | 2019-01-07 17:26:25 -0800 | [diff] [blame] | 225 | "--output-directory", GetTempDirPath(), |
| 226 | "--override-policy", "public"}); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 227 | // clang-format on |
| 228 | ASSERT_THAT(result, NotNull()); |
| 229 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 230 | ASSERT_EQ(result->stdout, expected.str()); |
Ryan Mitchell | 1982345 | 2019-01-29 12:01:24 -0800 | [diff] [blame] | 231 | unlink(idmap_static_no_name_path.c_str()); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 232 | unlink(idmap_static_2_path.c_str()); |
| 233 | unlink(idmap_static_1_path.c_str()); |
| 234 | |
| 235 | // the same input directory given twice, but no duplicate entries |
| 236 | // clang-format off |
| 237 | result = ExecuteBinary({"idmap2", |
| 238 | "scan", |
| 239 | "--input-directory", GetTestDataPath(), |
| 240 | "--input-directory", GetTestDataPath(), |
| 241 | "--recursive", |
| 242 | "--target-package-name", "test.target", |
| 243 | "--target-apk-path", GetTargetApkPath(), |
Mårten Kongstad | d10d06d | 2019-01-07 17:26:25 -0800 | [diff] [blame] | 244 | "--output-directory", GetTempDirPath(), |
| 245 | "--override-policy", "public"}); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 246 | // clang-format on |
| 247 | ASSERT_THAT(result, NotNull()); |
| 248 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 249 | ASSERT_EQ(result->stdout, expected.str()); |
Ryan Mitchell | 1982345 | 2019-01-29 12:01:24 -0800 | [diff] [blame] | 250 | unlink(idmap_static_no_name_path.c_str()); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 251 | unlink(idmap_static_2_path.c_str()); |
| 252 | unlink(idmap_static_1_path.c_str()); |
| 253 | |
| 254 | // no APKs in input-directory: ok, but no output |
| 255 | // clang-format off |
| 256 | result = ExecuteBinary({"idmap2", |
| 257 | "scan", |
| 258 | "--input-directory", GetTempDirPath(), |
| 259 | "--target-package-name", "test.target", |
| 260 | "--target-apk-path", GetTargetApkPath(), |
Mårten Kongstad | d10d06d | 2019-01-07 17:26:25 -0800 | [diff] [blame] | 261 | "--output-directory", GetTempDirPath(), |
| 262 | "--override-policy", "public"}); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 263 | // clang-format on |
| 264 | ASSERT_THAT(result, NotNull()); |
| 265 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 266 | ASSERT_EQ(result->stdout, ""); |
| 267 | } |
| 268 | |
| 269 | TEST_F(Idmap2BinaryTests, Lookup) { |
Mårten Kongstad | 1da49dc | 2019-01-14 10:03:53 +0100 | [diff] [blame] | 270 | SKIP_TEST_IF_CANT_EXEC_IDMAP2; |
| 271 | |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 272 | // clang-format off |
| 273 | auto result = ExecuteBinary({"idmap2", |
| 274 | "create", |
| 275 | "--target-apk-path", GetTargetApkPath(), |
| 276 | "--overlay-apk-path", GetOverlayApkPath(), |
| 277 | "--idmap-path", GetIdmapPath()}); |
| 278 | // clang-format on |
| 279 | ASSERT_THAT(result, NotNull()); |
| 280 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 281 | |
| 282 | // clang-format off |
| 283 | result = ExecuteBinary({"idmap2", |
| 284 | "lookup", |
| 285 | "--idmap-path", GetIdmapPath(), |
| 286 | "--config", "", |
Winson | b410020 | 2019-02-06 12:05:32 -0800 | [diff] [blame] | 287 | "--resid", "0x7f02000a"}); // string/str1 |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 288 | // clang-format on |
| 289 | ASSERT_THAT(result, NotNull()); |
| 290 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 291 | ASSERT_NE(result->stdout.find("overlay-1"), std::string::npos); |
| 292 | ASSERT_EQ(result->stdout.find("overlay-1-sv"), std::string::npos); |
| 293 | |
| 294 | // clang-format off |
| 295 | result = ExecuteBinary({"idmap2", |
| 296 | "lookup", |
| 297 | "--idmap-path", GetIdmapPath(), |
| 298 | "--config", "", |
| 299 | "--resid", "test.target:string/str1"}); |
| 300 | // clang-format on |
| 301 | ASSERT_THAT(result, NotNull()); |
| 302 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 303 | ASSERT_NE(result->stdout.find("overlay-1"), std::string::npos); |
| 304 | ASSERT_EQ(result->stdout.find("overlay-1-sv"), std::string::npos); |
| 305 | |
| 306 | // clang-format off |
| 307 | result = ExecuteBinary({"idmap2", |
| 308 | "lookup", |
| 309 | "--idmap-path", GetIdmapPath(), |
| 310 | "--config", "sv", |
| 311 | "--resid", "test.target:string/str1"}); |
| 312 | // clang-format on |
| 313 | ASSERT_THAT(result, NotNull()); |
| 314 | ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr; |
| 315 | ASSERT_NE(result->stdout.find("overlay-1-sv"), std::string::npos); |
| 316 | |
| 317 | unlink(GetIdmapPath().c_str()); |
| 318 | } |
| 319 | |
| 320 | TEST_F(Idmap2BinaryTests, InvalidCommandLineOptions) { |
Mårten Kongstad | 1da49dc | 2019-01-14 10:03:53 +0100 | [diff] [blame] | 321 | SKIP_TEST_IF_CANT_EXEC_IDMAP2; |
| 322 | |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 323 | const std::string invalid_target_apk_path = GetTestDataPath() + "/DOES-NOT-EXIST"; |
| 324 | |
| 325 | // missing mandatory options |
| 326 | // clang-format off |
| 327 | auto result = ExecuteBinary({"idmap2", |
| 328 | "create"}); |
| 329 | // clang-format on |
| 330 | ASSERT_THAT(result, NotNull()); |
| 331 | ASSERT_NE(result->status, EXIT_SUCCESS); |
| 332 | |
| 333 | // missing argument to option |
| 334 | // clang-format off |
| 335 | result = ExecuteBinary({"idmap2", |
| 336 | "create", |
| 337 | "--target-apk-path", GetTargetApkPath(), |
| 338 | "--overlay-apk-path", GetOverlayApkPath(), |
| 339 | "--idmap-path"}); |
| 340 | // clang-format on |
| 341 | ASSERT_THAT(result, NotNull()); |
| 342 | ASSERT_NE(result->status, EXIT_SUCCESS); |
| 343 | |
| 344 | // invalid target apk path |
| 345 | // clang-format off |
| 346 | result = ExecuteBinary({"idmap2", |
| 347 | "create", |
| 348 | "--target-apk-path", invalid_target_apk_path, |
| 349 | "--overlay-apk-path", GetOverlayApkPath(), |
| 350 | "--idmap-path", GetIdmapPath()}); |
| 351 | // clang-format on |
| 352 | ASSERT_THAT(result, NotNull()); |
| 353 | ASSERT_NE(result->status, EXIT_SUCCESS); |
Mårten Kongstad | d10d06d | 2019-01-07 17:26:25 -0800 | [diff] [blame] | 354 | |
| 355 | // unknown policy |
| 356 | // clang-format off |
| 357 | result = ExecuteBinary({"idmap2", |
| 358 | "create", |
| 359 | "--target-apk-path", GetTargetApkPath(), |
| 360 | "--overlay-apk-path", GetOverlayApkPath(), |
| 361 | "--idmap-path", GetIdmapPath(), |
| 362 | "--policy", "this-does-not-exist"}); |
| 363 | // clang-format on |
| 364 | ASSERT_THAT(result, NotNull()); |
| 365 | ASSERT_NE(result->status, EXIT_SUCCESS); |
Mårten Kongstad | 0275123 | 2018-04-27 13:16:32 +0200 | [diff] [blame] | 366 | } |
| 367 | |
Mårten Kongstad | 0eba72a | 2018-11-29 08:23:14 +0100 | [diff] [blame] | 368 | } // namespace android::idmap2 |