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