Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_packages_modules_Connectivity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid
platform_packages_modules_Connectivity
Commits
e9a5de9f
Commit
e9a5de9f
authored
1 year ago
by
Junyu Lai
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Make thread leak error message more readable" into main
parents
9a5252ba
c034c721
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
staticlibs/testutils/devicetests/com/android/testutils/DevSdkIgnoreRunner.kt
+17
-4
17 additions, 4 deletions
...s/devicetests/com/android/testutils/DevSdkIgnoreRunner.kt
with
17 additions
and
4 deletions
staticlibs/testutils/devicetests/com/android/testutils/DevSdkIgnoreRunner.kt
+
17
−
4
View file @
e9a5de9f
...
...
@@ -17,9 +17,9 @@
package
com.android.testutils
import
androidx.test.ext.junit.runners.AndroidJUnit4
import
com.android.net.module.util.LinkPropertiesUtils.CompareOrUpdateResult
import
com.android.testutils.DevSdkIgnoreRule.IgnoreAfter
import
com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo
import
java.lang.IllegalStateException
import
java.lang.reflect.Modifier
import
org.junit.runner.Description
import
org.junit.runner.Runner
...
...
@@ -110,10 +110,19 @@ class DevSdkIgnoreRunner(private val klass: Class<*>) : Runner(), Filterable, So
notifier
.
fireTestStarted
(
leakMonitorDesc
)
val
threadCountsAfterTest
=
getAllThreadNameCounts
()
if
(
threadCountsBeforeTest
!=
threadCountsAfterTest
)
{
// TODO : move CompareOrUpdateResult to its own util instead of LinkProperties.
val
threadsDiff
=
CompareOrUpdateResult
(
threadCountsBeforeTest
.
entries
,
threadCountsAfterTest
.
entries
)
{
it
.
key
}
// Ignore removed threads, which typically are generated by previous tests.
// Because this is in the threadsDiff.updated member, for sure there is a
// corresponding key in threadCountsBeforeTest.
val
increasedThreads
=
threadsDiff
.
updated
.
filter
{
threadCountsBeforeTest
[
it
.
key
]
!!
<
it
.
value
}
if
(
threadsDiff
.
added
.
isNotEmpty
()
||
increasedThreads
.
isNotEmpty
())
{
notifier
.
fireTestFailure
(
Failure
(
leakMonitorDesc
,
IllegalStateException
(
"Expected threads: $threadCountsBeforeTest "
+
"but got: $threadCountsAfterTest"
)))
IllegalStateException
(
"Unexpected thread changes: $threadsDiff"
)))
}
notifier
.
fireTestFinished
(
leakMonitorDesc
)
}
...
...
@@ -121,9 +130,13 @@ class DevSdkIgnoreRunner(private val klass: Class<*>) : Runner(), Filterable, So
private
fun
getAllThreadNameCounts
():
Map
<
String
,
Int
>
{
// Get the counts of threads in the group per name.
// Filter system thread groups.
// Also ignore threads with 1 count, this effectively filtered out threads created by the
// test runner or other system components. e.g. hwuiTask*, queued-work-looper,
// SurfaceSyncGroupTimer, RenderThread, Time-limited test, etc.
return
Thread
.
getAllStackTraces
().
keys
.
filter
{
it
.
threadGroup
?.
name
!=
"system"
}
.
groupingBy
{
it
.
name
}.
eachCount
()
.
filter
{
it
.
value
!=
1
}
}
override
fun
getDescription
():
Description
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment