Revert "ART: Add dex2oat swap usage test"
The test doesn't correctly exclude the target, as it will only work
on the host.
This reverts commit ab2a54093386c85756fe78daedd11ff4408a5988.
Bug: 29259363
Change-Id: Ie50df2e6f0c63cb10359c3862ad44ee3c03d4e3b
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 7f8fa8e..cc96cf0 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -71,7 +71,7 @@
ART_GTEST_compiler_driver_test_DEX_DEPS := AbstractMethod StaticLeafMethods ProfileTestMultiDex
ART_GTEST_dex_cache_test_DEX_DEPS := Main
ART_GTEST_dex_file_test_DEX_DEPS := GetMethodSignature Main Nested
-ART_GTEST_dex2oat_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) Statics
+ART_GTEST_dex2oat_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
ART_GTEST_exception_test_DEX_DEPS := ExceptionHandle
ART_GTEST_instrumentation_test_DEX_DEPS := Instrumentation
ART_GTEST_jni_compiler_test_DEX_DEPS := MyClassNatives
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index a8f15d0..93351e9 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-#include <regex>
-#include <sstream>
#include <string>
#include <vector>
+#include <sstream>
#include "common_runtime_test.h"
@@ -208,7 +207,7 @@
std::string dex_location = GetScratchDir() + "/Dex2OatSwapTest.jar";
std::string odex_location = GetOdexDir() + "/Dex2OatSwapTest.odex";
- Copy(GetTestDexFileName(), dex_location);
+ Copy(GetDexSrc1(), dex_location);
std::vector<std::string> copy(extra_args);
@@ -227,11 +226,7 @@
CheckResult(expect_use);
}
- virtual std::string GetTestDexFileName() {
- return GetDexSrc1();
- }
-
- virtual void CheckResult(bool expect_use) {
+ void CheckResult(bool expect_use) {
if (kIsTargetBuild) {
CheckTargetResult(expect_use);
} else {
@@ -239,13 +234,13 @@
}
}
- virtual void CheckTargetResult(bool expect_use ATTRIBUTE_UNUSED) {
+ void CheckTargetResult(bool expect_use ATTRIBUTE_UNUSED) {
// TODO: Ignore for now, as we won't capture any output (it goes to the logcat). We may do
// something for variants with file descriptor where we can control the lifetime of
// the swap file and thus take a look at it.
}
- virtual void CheckHostResult(bool expect_use) {
+ void CheckHostResult(bool expect_use) {
if (!kIsTargetBuild) {
if (expect_use) {
EXPECT_NE(output_.find("Large app, accepted running with swap."), std::string::npos)
@@ -258,7 +253,7 @@
}
// Check whether the dex2oat run was really successful.
- virtual void CheckValidity() {
+ void CheckValidity() {
if (kIsTargetBuild) {
CheckTargetValidity();
} else {
@@ -266,14 +261,14 @@
}
}
- virtual void CheckTargetValidity() {
+ void CheckTargetValidity() {
// TODO: Ignore for now, as we won't capture any output (it goes to the logcat). We may do
// something for variants with file descriptor where we can control the lifetime of
// the swap file and thus take a look at it.
}
// On the host, we can get the dex2oat output. Here, look for "dex2oat took."
- virtual void CheckHostValidity() {
+ void CheckHostValidity() {
EXPECT_NE(output_.find("dex2oat took"), std::string::npos) << output_;
}
};
@@ -302,96 +297,6 @@
{ "--swap-dex-size-threshold=0", "--swap-dex-count-threshold=0" });
}
-class Dex2oatSwapUseTest : public Dex2oatSwapTest {
- protected:
- void CheckHostResult(bool expect_use) OVERRIDE {
- if (!kIsTargetBuild) {
- if (expect_use) {
- EXPECT_NE(output_.find("Large app, accepted running with swap."), std::string::npos)
- << output_;
- } else {
- EXPECT_EQ(output_.find("Large app, accepted running with swap."), std::string::npos)
- << output_;
- }
- }
- }
-
- std::string GetTestDexFileName() OVERRIDE {
- // Use Statics as it has a handful of functions.
- return CommonRuntimeTest::GetTestDexFileName("Statics");
- }
-
- size_t ParseNativeAlloc() {
- std::regex native_alloc_regex("dex2oat took.*native alloc=[^ ]+ \\(([0-9]+)B\\)");
- std::smatch native_alloc_match;
- bool found = std::regex_search(output_, native_alloc_match, native_alloc_regex);
- if (!found) {
- EXPECT_TRUE(found);
- return 0;
- }
- if (native_alloc_match.size() != 2U) {
- EXPECT_EQ(native_alloc_match.size(), 2U);
- return 0;
- }
-
- std::istringstream stream(native_alloc_match[1].str());
- size_t value;
- stream >> value;
-
- return value;
- }
-
- size_t ParseSwap(bool expected) {
- std::regex swap_regex("dex2oat took[^\\n]+swap=[^ ]+ \\(([0-9]+)B\\)");
- std::smatch swap_match;
- bool found = std::regex_search(output_, swap_match, swap_regex);
- if (found != expected) {
- EXPECT_EQ(expected, found);
- return 0;
- }
-
- if (!found) {
- return 0;
- }
-
- if (swap_match.size() != 2U) {
- EXPECT_EQ(swap_match.size(), 2U);
- return 0;
- }
-
- std::istringstream stream(swap_match[1].str());
- size_t value;
- stream >> value;
-
- return value;
- }
-};
-
-TEST_F(Dex2oatSwapUseTest, CheckSwapUsage) {
- RunTest(false /* use_fd */,
- false /* expect_use */);
- size_t native_without = ParseNativeAlloc();
- size_t swap_without = ParseSwap(false /* expected */);
- std::string output_without = output_;
-
- output_ = "";
-
- RunTest(false /* use_fd */,
- true /* expect_use */,
- { "--swap-dex-size-threshold=0", "--swap-dex-count-threshold=0" });
- size_t native_with = ParseNativeAlloc();
- size_t swap_with = ParseSwap(true /* expected */);
- std::string output_with = output_;
-
- if (native_with >= native_without || swap_without >= swap_with) {
- EXPECT_LT(native_with, native_without);
- EXPECT_LT(swap_without, swap_with);
-
- LOG(ERROR) << output_without;
- LOG(ERROR) << output_with;
- }
-}
-
class Dex2oatVeryLargeTest : public Dex2oatTest {
protected:
void CheckFilter(CompilerFilter::Filter input ATTRIBUTE_UNUSED,