Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | |
Vladimir Marko | 1352f13 | 2017-04-28 15:28:29 +0100 | [diff] [blame] | 17 | #include "oatdump_test.h" |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 18 | |
| 19 | namespace art { |
| 20 | |
Vladimir Marko | 7da3170 | 2016-03-29 18:42:21 +0100 | [diff] [blame] | 21 | // Disable tests on arm and mips as they are taking too long to run. b/27824283. |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 22 | #define TEST_DISABLED_FOR_ARM_AND_MIPS() \ |
| 23 | TEST_DISABLED_FOR_ARM(); \ |
| 24 | TEST_DISABLED_FOR_ARM64(); \ |
| 25 | TEST_DISABLED_FOR_MIPS(); \ |
| 26 | TEST_DISABLED_FOR_MIPS64(); \ |
| 27 | |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 28 | TEST_F(OatDumpTest, TestNoDumpVmap) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 29 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 30 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 31 | ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--no-dump:vmap"}, kListAndCode)); |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 32 | } |
| 33 | TEST_F(OatDumpTest, TestNoDumpVmapStatic) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 34 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 35 | TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS(); |
| 36 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 37 | ASSERT_TRUE(Exec(kStatic, kModeArt, {"--no-dump:vmap"}, kListAndCode)); |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | TEST_F(OatDumpTest, TestNoDisassemble) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 41 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 42 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 43 | ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--no-disassemble"}, kListAndCode)); |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 44 | } |
| 45 | TEST_F(OatDumpTest, TestNoDisassembleStatic) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 46 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 47 | TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS(); |
| 48 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 49 | ASSERT_TRUE(Exec(kStatic, kModeArt, {"--no-disassemble"}, kListAndCode)); |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | TEST_F(OatDumpTest, TestListClasses) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 53 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 54 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 55 | ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--list-classes"}, kListOnly)); |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 56 | } |
| 57 | TEST_F(OatDumpTest, TestListClassesStatic) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 58 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 59 | TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS(); |
| 60 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 61 | ASSERT_TRUE(Exec(kStatic, kModeArt, {"--list-classes"}, kListOnly)); |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | TEST_F(OatDumpTest, TestListMethods) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 65 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 66 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 67 | ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--list-methods"}, kListOnly)); |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 68 | } |
| 69 | TEST_F(OatDumpTest, TestListMethodsStatic) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 70 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 71 | TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS(); |
| 72 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 73 | ASSERT_TRUE(Exec(kStatic, kModeArt, {"--list-methods"}, kListOnly)); |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | TEST_F(OatDumpTest, TestSymbolize) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 77 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 78 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 79 | ASSERT_TRUE(Exec(kDynamic, kModeSymbolize, {}, kListOnly)); |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 80 | } |
| 81 | TEST_F(OatDumpTest, TestSymbolizeStatic) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 82 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 83 | TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS(); |
| 84 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 85 | ASSERT_TRUE(Exec(kStatic, kModeSymbolize, {}, kListOnly)); |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 86 | } |
Anestis Bechtsoudis | a1f56a8 | 2017-10-08 23:37:10 +0300 | [diff] [blame] | 87 | |
| 88 | TEST_F(OatDumpTest, TestExportDex) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 89 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Mathieu Chartier | 567dc6f | 2018-04-05 16:37:14 -0700 | [diff] [blame] | 90 | // Test is failing on target, b/77469384. |
| 91 | TEST_DISABLED_FOR_TARGET(); |
Anestis Bechtsoudis | a1f56a8 | 2017-10-08 23:37:10 +0300 | [diff] [blame] | 92 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 93 | ASSERT_TRUE(Exec(kDynamic, kModeOat, {"--export-dex-to=" + tmp_dir_}, kListOnly)); |
Mathieu Chartier | 567dc6f | 2018-04-05 16:37:14 -0700 | [diff] [blame] | 94 | const std::string dex_location = tmp_dir_+ "/core-oj-hostdex.jar_export.dex"; |
| 95 | const std::string dexdump2 = GetExecutableFilePath("dexdump2", |
Andreas Gampe | 9b031f7 | 2018-10-04 11:03:34 -0700 | [diff] [blame] | 96 | /*is_debug=*/false, |
| 97 | /*is_static=*/false); |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 98 | std::string output; |
| 99 | auto post_fork_fn = []() { return true; }; |
| 100 | ForkAndExecResult res = ForkAndExec({dexdump2, "-d", dex_location}, post_fork_fn, &output); |
| 101 | ASSERT_TRUE(res.StandardSuccess()); |
Anestis Bechtsoudis | a1f56a8 | 2017-10-08 23:37:10 +0300 | [diff] [blame] | 102 | } |
| 103 | TEST_F(OatDumpTest, TestExportDexStatic) { |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 104 | TEST_DISABLED_FOR_ARM_AND_MIPS(); |
Anestis Bechtsoudis | a1f56a8 | 2017-10-08 23:37:10 +0300 | [diff] [blame] | 105 | TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS(); |
| 106 | std::string error_msg; |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 107 | ASSERT_TRUE(Exec(kStatic, kModeOat, {"--export-dex-to=" + tmp_dir_}, kListOnly)); |
Anestis Bechtsoudis | a1f56a8 | 2017-10-08 23:37:10 +0300 | [diff] [blame] | 108 | } |
Andreas Gampe | 38aa0b5 | 2018-07-10 23:26:55 -0700 | [diff] [blame] | 109 | |
Mathieu Chartier | 19510f0 | 2015-05-26 14:44:35 -0700 | [diff] [blame] | 110 | } // namespace art |