summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Dombroski <cdombroski@google.com>2023-10-06 12:24:32 -0700
committerChristopher Dombroski <cdombroski@google.com>2023-10-10 09:44:26 -0700
commitb7773455fe548651f6ddb71f225c273d27eae46a (patch)
tree60d3d6a4e0c8330ef8b463d82baffa457c89d0d9
parent38e0936cc6fd58cc994dbb270148ba996ea00a0f (diff)
downloadplatform_testing-b7773455fe548651f6ddb71f225c273d27eae46a.tar.gz
Clean up malloc debug properties
Bug: 303635846 Test: atest com.android.sts.common.MallocDebugTest Change-Id: Ica2df3fe32e119b0a2c47e1e3ed9eb069ef0dd59
-rw-r--r--libraries/sts-common-util/host-side/tests/src/com/android/sts/common/MallocDebugTest.java30
1 files changed, 28 insertions, 2 deletions
diff --git a/libraries/sts-common-util/host-side/tests/src/com/android/sts/common/MallocDebugTest.java b/libraries/sts-common-util/host-side/tests/src/com/android/sts/common/MallocDebugTest.java
index 99faf82cd..f82a90756 100644
--- a/libraries/sts-common-util/host-side/tests/src/com/android/sts/common/MallocDebugTest.java
+++ b/libraries/sts-common-util/host-side/tests/src/com/android/sts/common/MallocDebugTest.java
@@ -24,6 +24,8 @@ import static org.junit.Assert.assertTrue;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+import org.junit.After;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -50,6 +52,26 @@ public class MallocDebugTest extends BaseHostJUnit4Test {
}
}
+ @Before
+ public void setUp() throws Exception {
+ assertWithMessage("libc.debug.malloc.options not empty before test")
+ .that(getDevice().getProperty("libc.debug.malloc.options"))
+ .isNull();
+ assertWithMessage("libc.debug.malloc.programs not empty before test")
+ .that(getDevice().getProperty("libc.debug.malloc.programs"))
+ .isNull();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ assertWithMessage("libc.debug.malloc.options not empty after test")
+ .that(getDevice().getProperty("libc.debug.malloc.options"))
+ .isNull();
+ assertWithMessage("libc.debug.malloc.programs not empty after test")
+ .that(getDevice().getProperty("libc.debug.malloc.programs"))
+ .isNull();
+ }
+
@Test(expected = Test.None.class /* no exception expected */)
public void testMallocDebugNoErrors() throws Exception {
MallocDebug.assertNoMallocDebugErrors(logcatWithoutErrors);
@@ -99,7 +121,7 @@ public class MallocDebugTest extends BaseHostJUnit4Test {
final String oldValue = "TEST_VALUE_OLD";
final String newValue = "TEST_VALUE_NEW";
assertTrue(
- "could not set property",
+ "could not set libc.debug.malloc.options",
getDevice().setProperty("libc.debug.malloc.options", oldValue));
assertWithMessage("test property was not properly set on device")
.that(getDevice().getProperty("libc.debug.malloc.options"))
@@ -110,8 +132,12 @@ public class MallocDebugTest extends BaseHostJUnit4Test {
.that(getDevice().getProperty("libc.debug.malloc.options"))
.isEqualTo(newValue);
}
+ String afterValue = getDevice().getProperty("libc.debug.malloc.options");
+ assertTrue(
+ "could not clear libc.debug.malloc.options",
+ getDevice().setProperty("libc.debug.malloc.options", ""));
assertWithMessage("prior property was not restored after test")
- .that(getDevice().getProperty("libc.debug.malloc.options"))
+ .that(afterValue)
.isEqualTo(oldValue);
}
}