blob: 506fde776b3014cca30290c73bb995417b2fff4d [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
Nicolas Geoffray3ad2c2b2019-01-26 00:19:38 +000017#include <android-base/file.h>
18
Vladimir Marko1352f132017-04-28 15:28:29 +010019#include "oatdump_test.h"
Mathieu Chartier19510f02015-05-26 14:44:35 -070020
21namespace art {
22
Vladimir Marko7da31702016-03-29 18:42:21 +010023// Disable tests on arm and mips as they are taking too long to run. b/27824283.
Andreas Gampe38aa0b52018-07-10 23:26:55 -070024#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 Chartier19510f02015-05-26 14:44:35 -070030TEST_F(OatDumpTest, TestNoDumpVmap) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070031 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier19510f02015-05-26 14:44:35 -070032 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070033 ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--no-dump:vmap"}, kListAndCode));
Roland Levillain04147ef2016-09-06 11:09:41 +010034}
35TEST_F(OatDumpTest, TestNoDumpVmapStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070036 TEST_DISABLED_FOR_ARM_AND_MIPS();
Roland Levillain04147ef2016-09-06 11:09:41 +010037 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
38 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070039 ASSERT_TRUE(Exec(kStatic, kModeArt, {"--no-dump:vmap"}, kListAndCode));
Mathieu Chartier19510f02015-05-26 14:44:35 -070040}
41
42TEST_F(OatDumpTest, TestNoDisassemble) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070043 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier19510f02015-05-26 14:44:35 -070044 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070045 ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--no-disassemble"}, kListAndCode));
Roland Levillain04147ef2016-09-06 11:09:41 +010046}
47TEST_F(OatDumpTest, TestNoDisassembleStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070048 TEST_DISABLED_FOR_ARM_AND_MIPS();
Roland Levillain04147ef2016-09-06 11:09:41 +010049 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
50 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070051 ASSERT_TRUE(Exec(kStatic, kModeArt, {"--no-disassemble"}, kListAndCode));
Mathieu Chartier19510f02015-05-26 14:44:35 -070052}
53
54TEST_F(OatDumpTest, TestListClasses) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070055 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier19510f02015-05-26 14:44:35 -070056 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070057 ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--list-classes"}, kListOnly));
Roland Levillain04147ef2016-09-06 11:09:41 +010058}
59TEST_F(OatDumpTest, TestListClassesStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070060 TEST_DISABLED_FOR_ARM_AND_MIPS();
Roland Levillain04147ef2016-09-06 11:09:41 +010061 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
62 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070063 ASSERT_TRUE(Exec(kStatic, kModeArt, {"--list-classes"}, kListOnly));
Mathieu Chartier19510f02015-05-26 14:44:35 -070064}
65
66TEST_F(OatDumpTest, TestListMethods) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070067 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier19510f02015-05-26 14:44:35 -070068 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070069 ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--list-methods"}, kListOnly));
Roland Levillain04147ef2016-09-06 11:09:41 +010070}
71TEST_F(OatDumpTest, TestListMethodsStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070072 TEST_DISABLED_FOR_ARM_AND_MIPS();
Roland Levillain04147ef2016-09-06 11:09:41 +010073 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
74 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070075 ASSERT_TRUE(Exec(kStatic, kModeArt, {"--list-methods"}, kListOnly));
Mathieu Chartier19510f02015-05-26 14:44:35 -070076}
77
78TEST_F(OatDumpTest, TestSymbolize) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070079 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier19510f02015-05-26 14:44:35 -070080 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070081 ASSERT_TRUE(Exec(kDynamic, kModeSymbolize, {}, kListOnly));
Roland Levillain04147ef2016-09-06 11:09:41 +010082}
83TEST_F(OatDumpTest, TestSymbolizeStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070084 TEST_DISABLED_FOR_ARM_AND_MIPS();
Roland Levillain04147ef2016-09-06 11:09:41 +010085 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
86 std::string error_msg;
Andreas Gampe38aa0b52018-07-10 23:26:55 -070087 ASSERT_TRUE(Exec(kStatic, kModeSymbolize, {}, kListOnly));
Mathieu Chartier19510f02015-05-26 14:44:35 -070088}
Anestis Bechtsoudisa1f56a82017-10-08 23:37:10 +030089
90TEST_F(OatDumpTest, TestExportDex) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -070091 TEST_DISABLED_FOR_ARM_AND_MIPS();
Mathieu Chartier567dc6f2018-04-05 16:37:14 -070092 // Test is failing on target, b/77469384.
93 TEST_DISABLED_FOR_TARGET();
Anestis Bechtsoudisa1f56a82017-10-08 23:37:10 +030094 std::string error_msg;
Nicolas Geoffray1cb06b42019-01-30 08:51:31 +000095 ASSERT_TRUE(GenerateAppOdexFile(kDynamic, {"--runtime-arg", "-Xmx64M"}));
Andreas Gampe38aa0b52018-07-10 23:26:55 -070096 ASSERT_TRUE(Exec(kDynamic, kModeOat, {"--export-dex-to=" + tmp_dir_}, kListOnly));
Nicolas Geoffray3ad2c2b2019-01-26 00:19:38 +000097 const std::string dex_location =
98 tmp_dir_+ "/" + android::base::Basename(GetTestDexFileName(GetAppBaseName().c_str())) +
99 "_export.dex";
David Sehr4f215d12019-04-03 09:28:21 -0700100 const std::string dexdump = GetExecutableFilePath("dexdump",
101 /*is_debug=*/false,
102 /*is_static=*/false);
Andreas Gampe38aa0b52018-07-10 23:26:55 -0700103 std::string output;
104 auto post_fork_fn = []() { return true; };
David Sehr4f215d12019-04-03 09:28:21 -0700105 ForkAndExecResult res = ForkAndExec({dexdump, "-d", dex_location}, post_fork_fn, &output);
Andreas Gampe38aa0b52018-07-10 23:26:55 -0700106 ASSERT_TRUE(res.StandardSuccess());
Anestis Bechtsoudisa1f56a82017-10-08 23:37:10 +0300107}
108TEST_F(OatDumpTest, TestExportDexStatic) {
Andreas Gampe38aa0b52018-07-10 23:26:55 -0700109 TEST_DISABLED_FOR_ARM_AND_MIPS();
Anestis Bechtsoudisa1f56a82017-10-08 23:37:10 +0300110 TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
111 std::string error_msg;
Nicolas Geoffray1cb06b42019-01-30 08:51:31 +0000112 ASSERT_TRUE(GenerateAppOdexFile(kStatic, {"--runtime-arg", "-Xmx64M"}));
Andreas Gampe38aa0b52018-07-10 23:26:55 -0700113 ASSERT_TRUE(Exec(kStatic, kModeOat, {"--export-dex-to=" + tmp_dir_}, kListOnly));
Anestis Bechtsoudisa1f56a82017-10-08 23:37:10 +0300114}
Andreas Gampe38aa0b52018-07-10 23:26:55 -0700115
Mathieu Chartier19510f02015-05-26 14:44:35 -0700116} // namespace art