blob: e6936f65e1bb5486c462c1639b41cd59c0cca455 [file] [log] [blame]
Mathieu Chartier19510f02015-05-26 14:44:35 -07001/*
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 Marko1352f132017-04-28 15:28:29 +010017#include "oatdump_test.h"
Mathieu Chartier19510f02015-05-26 14:44:35 -070018
19namespace art {
20
Vladimir Marko7da31702016-03-29 18:42:21 +010021// Disable tests on arm and mips as they are taking too long to run. b/27824283.
Andreas Gampe38aa0b52018-07-10 23:26:55 -070022#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 Chartier19510f02015-05-26 14:44:35 -070028TEST_F(OatDumpTest, TestNoDumpVmap) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070029 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier19510f02015-05-26 14:44:35 -070030 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070031 ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--no-dump:vmap"}, kListAndCode));
Roland Levillain04147ef2016-09-06 11:09:41 +010032}
33TEST_F(OatDumpTest, TestNoDumpVmapStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070034 TEST_DISABLED_FOR_ARM_AND_MIPS();
Roland Levillain04147ef2016-09-06 11:09:41 +010035 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
36 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070037 ASSERT_TRUE(Exec(kStatic, kModeArt, {"--no-dump:vmap"}, kListAndCode));
Mathieu Chartier19510f02015-05-26 14:44:35 -070038}
39
40TEST_F(OatDumpTest, TestNoDisassemble) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070041 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier19510f02015-05-26 14:44:35 -070042 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070043 ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--no-disassemble"}, kListAndCode));
Roland Levillain04147ef2016-09-06 11:09:41 +010044}
45TEST_F(OatDumpTest, TestNoDisassembleStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070046 TEST_DISABLED_FOR_ARM_AND_MIPS();
Roland Levillain04147ef2016-09-06 11:09:41 +010047 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
48 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070049 ASSERT_TRUE(Exec(kStatic, kModeArt, {"--no-disassemble"}, kListAndCode));
Mathieu Chartier19510f02015-05-26 14:44:35 -070050}
51
52TEST_F(OatDumpTest, TestListClasses) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070053 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier19510f02015-05-26 14:44:35 -070054 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070055 ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--list-classes"}, kListOnly));
Roland Levillain04147ef2016-09-06 11:09:41 +010056}
57TEST_F(OatDumpTest, TestListClassesStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070058 TEST_DISABLED_FOR_ARM_AND_MIPS();
Roland Levillain04147ef2016-09-06 11:09:41 +010059 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
60 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070061 ASSERT_TRUE(Exec(kStatic, kModeArt, {"--list-classes"}, kListOnly));
Mathieu Chartier19510f02015-05-26 14:44:35 -070062}
63
64TEST_F(OatDumpTest, TestListMethods) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070065 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier19510f02015-05-26 14:44:35 -070066 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070067 ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--list-methods"}, kListOnly));
Roland Levillain04147ef2016-09-06 11:09:41 +010068}
69TEST_F(OatDumpTest, TestListMethodsStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070070 TEST_DISABLED_FOR_ARM_AND_MIPS();
Roland Levillain04147ef2016-09-06 11:09:41 +010071 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
72 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070073 ASSERT_TRUE(Exec(kStatic, kModeArt, {"--list-methods"}, kListOnly));
Mathieu Chartier19510f02015-05-26 14:44:35 -070074}
75
76TEST_F(OatDumpTest, TestSymbolize) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070077 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier19510f02015-05-26 14:44:35 -070078 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070079 ASSERT_TRUE(Exec(kDynamic, kModeSymbolize, {}, kListOnly));
Roland Levillain04147ef2016-09-06 11:09:41 +010080}
81TEST_F(OatDumpTest, TestSymbolizeStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070082 TEST_DISABLED_FOR_ARM_AND_MIPS();
Roland Levillain04147ef2016-09-06 11:09:41 +010083 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
84 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070085 ASSERT_TRUE(Exec(kStatic, kModeSymbolize, {}, kListOnly));
Mathieu Chartier19510f02015-05-26 14:44:35 -070086}
Anestis Bechtsoudisa1f56a82017-10-08 23:37:10 +030087
88TEST_F(OatDumpTest, TestExportDex) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070089 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier567dc6f2018-04-05 16:37:14 -070090 // Test is failing on target, b/77469384.
91 TEST_DISABLED_FOR_TARGET();
Anestis Bechtsoudisa1f56a82017-10-08 23:37:10 +030092 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070093 ASSERT_TRUE(Exec(kDynamic, kModeOat, {"--export-dex-to=" + tmp_dir_}, kListOnly));
Mathieu Chartier567dc6f2018-04-05 16:37:14 -070094 const std::string dex_location = tmp_dir_+ "/core-oj-hostdex.jar_export.dex";
95 const std::string dexdump2 = GetExecutableFilePath("dexdump2",
Andreas Gampe9b031f72018-10-04 11:03:34 -070096 /*is_debug=*/false,
97 /*is_static=*/false);
Andreas Gampe38aa0b52018-07-10 23:26:55 -070098 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 Bechtsoudisa1f56a82017-10-08 23:37:10 +0300102}
103TEST_F(OatDumpTest, TestExportDexStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -0700104 TEST_DISABLED_FOR_ARM_AND_MIPS();
Anestis Bechtsoudisa1f56a82017-10-08 23:37:10 +0300105 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
106 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -0700107 ASSERT_TRUE(Exec(kStatic, kModeOat, {"--export-dex-to=" + tmp_dir_}, kListOnly));
Anestis Bechtsoudisa1f56a82017-10-08 23:37:10 +0300108}
Andreas Gampe38aa0b52018-07-10 23:26:55 -0700109
Mathieu Chartier19510f02015-05-26 14:44:35 -0700110} // namespace art