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 
17 #include "oatdump_test.h"
18 
19 namespace art {
20 
21 // Disable tests on arm and mips as they are taking too long to run. b/27824283.
22 #if !defined(__arm__) && !defined(__mips__)
TEST_F(OatDumpTest,TestNoDumpVmap)23 TEST_F(OatDumpTest, TestNoDumpVmap) {
24   std::string error_msg;
25   ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--no-dump:vmap"}, kListAndCode, &error_msg)) << error_msg;
26 }
TEST_F(OatDumpTest,TestNoDumpVmapStatic)27 TEST_F(OatDumpTest, TestNoDumpVmapStatic) {
28   TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
29   std::string error_msg;
30   ASSERT_TRUE(Exec(kStatic, kModeArt, {"--no-dump:vmap"}, kListAndCode, &error_msg)) << error_msg;
31 }
32 
TEST_F(OatDumpTest,TestNoDisassemble)33 TEST_F(OatDumpTest, TestNoDisassemble) {
34   std::string error_msg;
35   ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--no-disassemble"}, kListAndCode, &error_msg))
36       << error_msg;
37 }
TEST_F(OatDumpTest,TestNoDisassembleStatic)38 TEST_F(OatDumpTest, TestNoDisassembleStatic) {
39   TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
40   std::string error_msg;
41   ASSERT_TRUE(Exec(kStatic, kModeArt, {"--no-disassemble"}, kListAndCode, &error_msg)) << error_msg;
42 }
43 
TEST_F(OatDumpTest,TestListClasses)44 TEST_F(OatDumpTest, TestListClasses) {
45   std::string error_msg;
46   ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--list-classes"}, kListOnly, &error_msg)) << error_msg;
47 }
TEST_F(OatDumpTest,TestListClassesStatic)48 TEST_F(OatDumpTest, TestListClassesStatic) {
49   TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
50   std::string error_msg;
51   ASSERT_TRUE(Exec(kStatic, kModeArt, {"--list-classes"}, kListOnly, &error_msg)) << error_msg;
52 }
53 
TEST_F(OatDumpTest,TestListMethods)54 TEST_F(OatDumpTest, TestListMethods) {
55   std::string error_msg;
56   ASSERT_TRUE(Exec(kDynamic, kModeArt, {"--list-methods"}, kListOnly, &error_msg)) << error_msg;
57 }
TEST_F(OatDumpTest,TestListMethodsStatic)58 TEST_F(OatDumpTest, TestListMethodsStatic) {
59   TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
60   std::string error_msg;
61   ASSERT_TRUE(Exec(kStatic, kModeArt, {"--list-methods"}, kListOnly, &error_msg)) << error_msg;
62 }
63 
TEST_F(OatDumpTest,TestSymbolize)64 TEST_F(OatDumpTest, TestSymbolize) {
65   std::string error_msg;
66   ASSERT_TRUE(Exec(kDynamic, kModeSymbolize, {}, kListOnly, &error_msg)) << error_msg;
67 }
TEST_F(OatDumpTest,TestSymbolizeStatic)68 TEST_F(OatDumpTest, TestSymbolizeStatic) {
69   TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
70   std::string error_msg;
71   ASSERT_TRUE(Exec(kStatic, kModeSymbolize, {}, kListOnly, &error_msg)) << error_msg;
72 }
73 
TEST_F(OatDumpTest,TestExportDex)74 TEST_F(OatDumpTest, TestExportDex) {
75   // Test is failing on target, b/77469384.
76   TEST_DISABLED_FOR_TARGET();
77   std::string error_msg;
78   ASSERT_TRUE(Exec(kDynamic, kModeOat, {"--export-dex-to=" + tmp_dir_}, kListOnly, &error_msg))
79       << error_msg;
80   const std::string dex_location = tmp_dir_+ "/core-oj-hostdex.jar_export.dex";
81   const std::string dexdump2 = GetExecutableFilePath("dexdump2",
82                                                      /*is_debug*/false,
83                                                      /*is_static*/false);
84   ASSERT_TRUE(ForkAndExecAndWait({dexdump2, "-d", dex_location}, &error_msg)) << error_msg;
85 }
TEST_F(OatDumpTest,TestExportDexStatic)86 TEST_F(OatDumpTest, TestExportDexStatic) {
87   TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
88   std::string error_msg;
89   ASSERT_TRUE(Exec(kStatic, kModeOat, {"--export-dex-to=" + tmp_dir_}, kListOnly, &error_msg))
90       << error_msg;
91 }
92 #endif
93 }  // namespace art
94