diff options
-rw-r--r-- | Android.bp | 17 | ||||
-rw-r--r-- | TEST_MAPPING | 17 | ||||
-rw-r--r-- | core/common/src/test/kotlin/trebuchet/extractors/ZlibExtractorTest.kt | 72 | ||||
-rw-r--r-- | core/common/src/test/kotlin/trebuchet/io/StringStreamTest.kt | 24 | ||||
-rw-r--r-- | core/common/src/test/kotlin/trebuchet/task/ImportTaskTest.kt | 98 | ||||
-rw-r--r-- | core/common/src/test/kotlin/trebuchet/testutils/Annotations.kt | 23 |
6 files changed, 17 insertions, 234 deletions
@@ -12,6 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. +package { + default_applicable_licenses: ["tools_trebuchet_license"], +} + +// Added automatically by a large-scale-change +// http://go/android-license-faq +license { + name: "tools_trebuchet_license", + visibility: [":__subpackages__"], + license_kinds: [ + "SPDX-license-identifier-Apache-2.0", + ], + license_text: [ + "LICENSE", + ], +} + java_defaults { name: "trebuchet-defaults", javacflags: [ diff --git a/TEST_MAPPING b/TEST_MAPPING deleted file mode 100644 index 5be5baf..0000000 --- a/TEST_MAPPING +++ /dev/null @@ -1,17 +0,0 @@ -{ - "presubmit": [ - { - "name": "trebuchet-core-tests", - "host": true, - "options": [ - { - "exclude-annotation": "trebuchet.testutils.NeedsSampleData" - } - ] - }, - { - "name": "trebuchet-startup-common-tests", - "host": true - } - ] -} diff --git a/core/common/src/test/kotlin/trebuchet/extractors/ZlibExtractorTest.kt b/core/common/src/test/kotlin/trebuchet/extractors/ZlibExtractorTest.kt deleted file mode 100644 index 5f1e493..0000000 --- a/core/common/src/test/kotlin/trebuchet/extractors/ZlibExtractorTest.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2018 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package trebuchet.extractors - -import org.junit.Test -import trebuchet.extras.InputStreamAdapter -import trebuchet.extras.findSampleData -import trebuchet.importers.FatalImportFeedback -import trebuchet.io.BufferProducer -import trebuchet.io.StreamingReader -import trebuchet.testutils.NeedsSampleData -import java.io.File -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull -import kotlin.test.assertTrue - -class ZlibExtractorTest { - @Test @NeedsSampleData - fun testFactorySuccess() { - val reader = StreamingReader(openSample()) - reader.loadIndex(reader.keepLoadedSize.toLong()) - assertNotNull(ZlibExtractor.Factory.extractorFor(reader, FatalImportFeedback)) - } - - @Test @NeedsSampleData - fun testFactoryNotDeflated() { - val reader = StreamingReader(openSample("sample.ftrace")) - reader.loadIndex(reader.keepLoadedSize.toLong()) - assertNull(ZlibExtractor.Factory.extractorFor(reader, FatalImportFeedback)) - } - - @Test @NeedsSampleData - fun testFactoryNoHeader() { - val reader = StreamingReader(openSample("caltrace1.html")) - reader.loadIndex(reader.keepLoadedSize.toLong()) - assertNull(ZlibExtractor.Factory.extractorFor(reader, FatalImportFeedback)) - } - - @Test @NeedsSampleData - fun testExtractInitial() { - val expected = "# tracer: nop\n#\n# ent" - val extractor = ZlibExtractor(FatalImportFeedback) - extractor.extract(StreamingReader(openSample())) { - val first = it.next() - assertNotNull(first) - assertTrue(first.length > expected.length) - assertEquals(expected, first.slice(0, expected.length).toString()) - it.close() - } - } - - private fun openSample(name: String = "missed_traces.trace"): BufferProducer { - val file = File(findSampleData(), name) - assertTrue(file.exists(), "Unable to find '$name'") - return InputStreamAdapter(file) - } -}
\ No newline at end of file diff --git a/core/common/src/test/kotlin/trebuchet/io/StringStreamTest.kt b/core/common/src/test/kotlin/trebuchet/io/StringStreamTest.kt index ee149c9..7b71fd8 100644 --- a/core/common/src/test/kotlin/trebuchet/io/StringStreamTest.kt +++ b/core/common/src/test/kotlin/trebuchet/io/StringStreamTest.kt @@ -24,7 +24,6 @@ import trebuchet.importers.DummyImportFeedback import trebuchet.model.Model import trebuchet.task.ImportTask import trebuchet.testutils.makeReader -import trebuchet.testutils.NeedsSampleData import java.io.BufferedReader import java.io.File import java.io.FileReader @@ -39,17 +38,6 @@ class StringStreamTest { expect1_20_300("1\r\n20\r\n300") } - @Test @NeedsSampleData - fun testLineReaderOnFile() { - val file = File("${findSampleData()}/sample.ftrace") - Assert.assertTrue(file.exists()) - val expected = BufferedReader(FileReader(file)) - StreamingReader(readFile(file)).iterLines().forEach { - assertEquals(expected.readLine(), it.toString()) - } - assertNull(expected.readLine()) - } - @Test fun testLineReaderEmptyLines() { expect1_20_300("\n\n1\r\n\r\n20\n\n\n\n300\n\n\n") @@ -65,16 +53,4 @@ class StringStreamTest { assertEquals("20", lines[1]) assertEquals("300", lines[2]) } - - fun readFile(file: File): BufferProducer { - val inputStream = file.inputStream() - return object : BufferProducer { - override fun next(): DataSlice? { - val buffer = ByteArray(2 * 1024 * 1024) - val read = inputStream.read(buffer) - if (read == -1) return null - return buffer.asSlice(read) - } - } - } }
\ No newline at end of file diff --git a/core/common/src/test/kotlin/trebuchet/task/ImportTaskTest.kt b/core/common/src/test/kotlin/trebuchet/task/ImportTaskTest.kt deleted file mode 100644 index f51f3ca..0000000 --- a/core/common/src/test/kotlin/trebuchet/task/ImportTaskTest.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package trebuchet.task - -import org.junit.Assert.* -import org.junit.Test -import trebuchet.extras.findSampleData -import trebuchet.importers.DummyImportFeedback -import trebuchet.io.BufferProducer -import trebuchet.io.DataSlice -import trebuchet.io.asSlice -import trebuchet.model.Model -import trebuchet.model.fragments.AsyncSlice -import trebuchet.queries.slices.* -import trebuchet.testutils.NeedsSampleData -import java.io.File - -class ImportTaskTest { - @Test @NeedsSampleData - fun testImportCameraTrace() { - val model = import("hdr-0608-4-trace.html") - val slices = model.selectAll { it.name.startsWith("MergeShot")} - assertEquals(2, slices.size) - assertEquals(0.868, slices[0].duration, .001) - assertEquals(0.866, slices[1].duration, .001) - } - - @Test @NeedsSampleData - fun testImportCalTrace1() { - val model = import("caltrace1.html") - val counterName = "com.google.android.apps.nexuslauncher/com.google.android.apps.nexuslauncher.NexusLauncherActivity#1" - val process = model.processes.values.find { it.name == "surfaceflinger" }!! - val thread = process.threads.find { it.name == "surfaceflinger" }!! - val slices = thread.selectAll { it.name == "handleMessageRefresh" } - assertEquals(103, slices.size) - assertFalse(slices.any { it.duration <= 0.0 }) - val totalDuration = slices.map { it.duration }.reduce { a,b -> a+b } - assertEquals(.217984, totalDuration, .00001) - val counter = process.counters.find { it.name == counterName } - assertNotNull(counter) - counter!! - assertEquals(2, counter.events.filter { it.count == 2L }.size) - assertFalse(counter.events.any { it.count < 0 || it.count > 2}) - } - - @Test @NeedsSampleData - fun testImportSample() { - val model = import("sample.ftrace") - val process = model.processes[6381]!! - val thread = process.threads.find { it.name == "RenderThread" }!! - assertEquals(6506, thread.id) - - val inputEvent4 = process.asyncSlices.find { - it.name == "deliverInputEvent" && it.cookie == 4 - } - assertNotNull(inputEvent4) - inputEvent4!! - assertEquals(6381, inputEvent4.startThreadId) - assertEquals(6381, inputEvent4.endThreadId) - assertEquals(4493.665365, inputEvent4.startTime, 0.0) - assertEquals(4493.725982, inputEvent4.endTime, 0.0) - } - - private fun import(filename: String): Model { - val task = ImportTask(DummyImportFeedback) - val file = File(findSampleData(), filename) - assertTrue(file.exists()) - val model = task.import(readFile(file)) - assertFalse(model.isEmpty()) - return model - } - - fun readFile(file: File): BufferProducer { - val inputStream = file.inputStream() - return object : BufferProducer { - override fun next(): DataSlice? { - val buffer = ByteArray(2 * 1024 * 1024) - val read = inputStream.read(buffer) - if (read == -1) return null - return buffer.asSlice(read) - } - } - } -}
\ No newline at end of file diff --git a/core/common/src/test/kotlin/trebuchet/testutils/Annotations.kt b/core/common/src/test/kotlin/trebuchet/testutils/Annotations.kt deleted file mode 100644 index b9aeb0d..0000000 --- a/core/common/src/test/kotlin/trebuchet/testutils/Annotations.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2019 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package trebuchet.testutils - -/** - Indicates that a test needs access to sample data, which is not included in - the repository. This is used to skip these tests on presubmit checks. - */ -annotation class NeedsSampleData |