Merge "Empty merge of Android 24Q2 Release (ab/11526283) to aosp-main-future" into aosp-main-future
diff --git a/atest/linux-x86/atest-py3 b/atest/linux-x86/atest-py3
index fa12836..1b1599a 100755
--- a/atest/linux-x86/atest-py3
+++ b/atest/linux-x86/atest-py3
Binary files differ
diff --git a/atest/smoke_test_data/__init__.py b/atest/smoke_test_data/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/atest/smoke_test_data/__init__.py
+++ /dev/null
diff --git a/atest/smoke_test_data/include_subdirs.py b/atest/smoke_test_data/include_subdirs.py
deleted file mode 100644
index 3dfb284..0000000
--- a/atest/smoke_test_data/include_subdirs.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# Copyright 2020, The Android Open Source Project
-#
-# 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
-#
-# http://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.
-
-import inspect
-import os
-import subprocess
-import sys
-
-import utils
-
-# Must assign TITLE so that smoke_tests is able to print it.
-TITLE = "--include-subdirs"
-SMOKE_DIR = os.path.dirname(os.path.realpath(__file__))
-DEST_DIR = os.path.join(SMOKE_DIR, 'test_mappings', 'A')
-ATEST = ['atest']
-MSG = 'Failed testing {} in {}'
-EXPECTED_RC = 0
-PRE = ':presubmit'
-POST = ':postsubmit'
-ALL = ':all'
-
-
-class IncludeSubdirs():
- """Class of testing --include-subdirs argument."""
-
- def run_test(self, testgroup, expected_tests):
- """Method that accepts testgroup and return code to check
- if the test meets the passed criteria.
-
- The test result will be like running:
- $ atest --include-subdirs :presubmit /path/to/smoke/test_mappings/A
-
- Args:
- testgroup: A string of either ':presubmit', ':postsubmit'
- or ':all'
- expected_tests: An integer of tests in the TEST_MAPPING files.
- """
- print('test_include_subdirs_{}'.format(testgroup).replace(':', ''))
- args = [TITLE, testgroup, DEST_DIR]
- cmd = ATEST.copy()
- cmd.extend(args)
- print('Running: {}'.format(' '.join(cmd)))
-
- # 1. Search :presubmit by default, return code must be 0.
- if not utils.is_passed(EXPECTED_RC,
- subprocess.call(cmd),
- args,
- MSG.format(testgroup, DEST_DIR)):
- sys.exit(1)
- # 2. The actual running tests must be the same with expected.
- if not utils.is_identical(expected_tests,
- utils.get_test_counts(),
- 'Test numbers'):
- sys.exit(1)
-
-
-def main():
- utils.print_banner(TITLE)
- utils.init_test_mapping_files(action='create')
- tis = IncludeSubdirs()
-
- # There are 3 test arguments:
- # 1. ":presubmit", expect 2 tests.
- # 2. ":postsubmit", expect 3 tests.
- # 3. ":all", Since "HelloWorldATest" appears in both TEST_MAPPING files,
- # we expect running 4 tests after merging.
- test_args = [(PRE, 2), (POST, 3), (ALL, 4)]
- for i, _ in enumerate(test_args):
- print('\n[{}/{}] '.format(i+1, len(test_args)), end='')
- utils.func_wrapper(tis.run_test, test_args[i])
- utils.init_test_mapping_files(action='delete')
- utils.print_banner(TITLE, True)
diff --git a/atest/smoke_test_data/instrumentation/Android.bp b/atest/smoke_test_data/instrumentation/Android.bp
deleted file mode 100644
index dd96677..0000000
--- a/atest/smoke_test_data/instrumentation/Android.bp
+++ /dev/null
@@ -1,28 +0,0 @@
-//Copyright (C) 2020 The Android Open Source Project
-//
-// 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
-//
-// http://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 {
- default_team: "trendy_team_diagnostic_tool",
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-android_test {
- name: "HelloWorldATest",
-
- srcs: ["src/**/*.java"],
- sdk_version: "current",
-
- static_libs: ["androidx.test.rules"],
- certificate: "platform",
-}
diff --git a/atest/smoke_test_data/instrumentation/AndroidManifest.xml b/atest/smoke_test_data/instrumentation/AndroidManifest.xml
deleted file mode 100644
index 0661795..0000000
--- a/atest/smoke_test_data/instrumentation/AndroidManifest.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 The Android Open Source Project
-
- 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
-
- http://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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.test.example.helloworld" >
-
- <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.test.example.helloworld"
- android:label="Hello World ATest"/>
-
-</manifest>
diff --git a/atest/smoke_test_data/instrumentation/AndroidTest.xml b/atest/smoke_test_data/instrumentation/AndroidTest.xml
deleted file mode 100644
index 76f5804..0000000
--- a/atest/smoke_test_data/instrumentation/AndroidTest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 The Android Open Source Project
-
- 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
-
- http://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.
--->
-<configuration description="Runs Atest example instrumentation test.">
- <option name="test-suite-tag" value="apct" />
- <option name="test-suite-tag" value="apct-instrumentation" />
- <target_preparer class="com.android.tradefed.targetprep.TestFilePushSetup" />
- <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
- <option name="test-file-name" value="HelloWorldATest.apk" />
- </target_preparer>
- <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer" />
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer" />
-
- <option name="test-tag" value="ExampleInstrumentationTest" />
- <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
- <option name="package" value="android.test.example.helloworld" />
- <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
- </test>
-</configuration>
diff --git a/atest/smoke_test_data/instrumentation/src/android/test/example/helloworld/HelloWorldATest.java b/atest/smoke_test_data/instrumentation/src/android/test/example/helloworld/HelloWorldATest.java
deleted file mode 100644
index e362eb2..0000000
--- a/atest/smoke_test_data/instrumentation/src/android/test/example/helloworld/HelloWorldATest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * 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
- *
- * http://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 android.test.example.helloworld;
-
-import androidx.test.filters.SmallTest;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class HelloWorldATest {
-
- @Test
- @SmallTest
- public void testHelloWorld() {
- Assert.assertNotEquals("Hello", "world");
- }
-
- @Test
- @SmallTest
- public void atestHalloWelt() {
- Assert.assertNotEquals("Hallo", "Welt");
- }
-}
diff --git a/atest/smoke_test_data/iterations.py b/atest/smoke_test_data/iterations.py
deleted file mode 100644
index 8b63e92..0000000
--- a/atest/smoke_test_data/iterations.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright 2020, The Android Open Source Project
-#
-# 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
-#
-# http://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.
-
-import inspect
-import os
-import subprocess
-import sys
-
-import utils
-
-# Must assign TITLE so that smoke_tests is able to print it.
-TITLE = "Iteration Runs"
-ATEST = "atest"
-ARGS = "-c {}={} {}"
-ITERS = "--iterations"
-RERUN = "--rerun-until-failure"
-RETRY = "--retry-any-failure"
-RUNS = 5
-PASS_TEST_NAME = "atest_will_pass_tests"
-FAIL_TEST_NAME = "atest_will_fail_tests"
-
-
-class Iterations():
- """Class of testing --iterations, --rerun-until-failure,
- --retry-any-failure arguments."""
-
- def run_test(self, test_arg, expected_pass):
- """Define pass_tests/fail_tests from expect_pass.
-
- The test result will be like running:
- $ atest -c --retry-any-failure=5 atest_will_fail_tests
-
- Args:
- test_arg: A string of "--iterations", etc.
- expected_pass: A boolean of expected test result.
- """
- if expected_pass:
- args = ARGS.format(test_arg, RUNS, PASS_TEST_NAME)
- pass_tests = 3
- fail_tests = 0
- else:
- args = ARGS.format(test_arg, RUNS, FAIL_TEST_NAME)
- pass_tests = 1
- fail_tests = 2
- # Define expected_threads from the argument.
- if test_arg == ITERS:
- expected_threads = (pass_tests+fail_tests) * RUNS
- elif test_arg == RERUN:
- expected_threads = (pass_tests+fail_tests) * 1
- elif test_arg == RETRY:
- expected_threads = pass_tests + (fail_tests*RUNS)
-
- print('test{}'.format(test_arg).replace('-', '_'))
- cmd = '{} {}'.format(ATEST, args)
- print('Running: {}'.format(cmd))
- # 1. Check return code
- if expected_pass:
- if subprocess.call(cmd, shell=True) != 0:
- print('Failed testing:\n {}'.format(cmd))
- sys.exit(1)
- else:
- if subprocess.call(cmd, shell=True) == 0:
- print('Testing:\n{}\nis expected failure,'
- ' but it passed.'.format(cmd))
- sys.exit(1)
-
- # 2. Should observe same threads in host_log.
- if not utils.is_identical(expected_threads,
- utils.get_test_threads(),
- "Test threads"):
- sys.exit(1)
-
- # 3. Should observe same amount of passed/failed test in end_host_log.
- if not utils.has_correct_passed_failed_counts(pass_tests, fail_tests):
- sys.exit(1)
-
-
-def main():
- utils.print_banner(TITLE)
- iters = Iterations()
- # There are 3 test arguments:
- # "--iterations": runs atest_will_pass_test and expect pass.
- # "--rerun-until-failure": runs atest_will_fail_test and expect fail.
- # "--retry-any-failure": runs atest_will_fail_test and expect fail.
- test_args = [(ITERS, True), (RERUN, False), (RETRY, False)]
- for i, _ in enumerate(test_args):
- print('\n[{}/{}] '.format(i+1, len(test_args)), end='')
- utils.func_wrapper(iters.run_test, test_args[i])
- utils.print_banner(TITLE, True)
diff --git a/atest/smoke_test_data/lookup_tests.py b/atest/smoke_test_data/lookup_tests.py
deleted file mode 100644
index 4c45023..0000000
--- a/atest/smoke_test_data/lookup_tests.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2020, The Android Open Source Project
-#
-# 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
-#
-# http://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.
-
-import os
-import subprocess
-import sys
-
-import utils
-
-
-# Must assign TITLE so that smoke_tests is able to print it.
-TITLE = "Lookup Test Types"
-
-def main():
- """Test looking up all test types via atest_integration_tests.py."""
- args = " --clear-cache --verify-cmd-mapping"
- atest_dir = os.path.join(os.getenv(utils.TOP), 'tools/asuite/atest')
- integration = os.path.join(atest_dir, 'atest_integration_tests.py')
- cmd = integration + args
- utils.print_banner(TITLE)
- try:
- os.chdir(os.getenv(utils.TOP))
- subprocess.check_output(cmd, shell=True)
- except subprocess.CalledProcessError as cpe:
- print(cpe)
- sys.exit(1)
- utils.print_banner(TITLE, True)
diff --git a/atest/smoke_test_data/native/Android.bp b/atest/smoke_test_data/native/Android.bp
deleted file mode 100644
index 7cf43d2..0000000
--- a/atest/smoke_test_data/native/Android.bp
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2020 The Android Open Source Project
-//
-// 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
-//
-// http://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.
-
-// Native test module which contains 3 will-pass tests.
-package {
- default_team: "trendy_team_diagnostic_tool",
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_test {
- name: "atest_will_pass_tests",
- srcs: ["atest_will_pass_tests.cpp"],
-
- cflags: [
- "-Wall",
- "-Werror",
- ],
-
- host_supported: true,
- test_options: {
- unit_test: false,
- },
-}
-
-// Native test module which contains 1 will-pass test and 2 will-fail tests.
-cc_test {
- name: "atest_will_fail_tests",
- srcs: ["atest_will_fail_tests.cpp"],
-
- cflags: [
- "-Wall",
- "-Werror",
- ],
-
- host_supported: true,
- test_options: {
- unit_test: false,
- },
-}
diff --git a/atest/smoke_test_data/native/atest_will_fail_tests.cpp b/atest/smoke_test_data/native/atest_will_fail_tests.cpp
deleted file mode 100644
index ebacbaa..0000000
--- a/atest/smoke_test_data/native/atest_will_fail_tests.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * 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
- *
- * http://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.
- */
-
-#include <gtest/gtest.h>
-
-#include <stdio.h>
-
-TEST(atest_will_fail_tests, PrintAtestFail) {
- printf("Hello, Atest Fail!");
-}
-
-TEST(atest_will_fail_tests, FailEqual) {
- EXPECT_EQ(25.9, 25.99999);
-}
-
-TEST(atest_will_fail_tests, FailFloatEqual) {
- ASSERT_FLOAT_EQ (2.10001, 2.000011);
-}
diff --git a/atest/smoke_test_data/native/atest_will_pass_tests.cpp b/atest/smoke_test_data/native/atest_will_pass_tests.cpp
deleted file mode 100644
index 8e01c47..0000000
--- a/atest/smoke_test_data/native/atest_will_pass_tests.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * 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
- *
- * http://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.
- */
-
-#include <gtest/gtest.h>
-
-#include <stdio.h>
-
-TEST(atest_will_pass_tests, PrintAtestPass) {
- printf("Hello, Atest Pass!");
-}
-
-TEST(atest_will_pass_tests, PassEqual) {
- EXPECT_EQ(25.4, 25.4);
-}
-
-TEST(atest_will_pass_tests, PassFloatEqual) {
- ASSERT_FLOAT_EQ (2.00001, 2.000011);
-}
diff --git a/atest/smoke_test_data/test_mappings.py b/atest/smoke_test_data/test_mappings.py
deleted file mode 100644
index 0d85fa3..0000000
--- a/atest/smoke_test_data/test_mappings.py
+++ /dev/null
@@ -1,101 +0,0 @@
-# Copyright 2020, The Android Open Source Project
-#
-# 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
-#
-# http://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.
-
-import inspect
-import os
-import subprocess
-import sys
-
-import utils
-
-# Must assign TITLE so that smoke_tests is able to print it.
-SMOKE_DIR = os.path.dirname(os.path.realpath(__file__))
-TITLE = "--test-mapping"
-
-
-def test_TEST_MAPPING_in_CWD(exec):
- """Test the atest default behaviour: find TEST_MAPPING in cwd.
-
- Args:
- exec: the atest command.
-
- The test result will be like running:
- $ cd prebuilts/asuite/atest/smoke_test_data/test_mappings
- $ atest
- """
- print(inspect.currentframe().f_code.co_name)
- os.chdir(os.path.join(SMOKE_DIR, 'test_mappings', 'A'))
- expected_rc = 0
- actual_rc = subprocess.call(exec)
- error_msg = 'Failed testing TEST_MAPPING in {}'.format(os.getcwd())
- if not utils.is_passed(expected_rc, actual_rc, '', error_msg):
- utils.init_test_mapping_files(action='delete')
- sys.exit(1)
-
-
-def test_TEST_MAPPING_in_path(exec):
- """Test finding TEST_MAPPING in a specific path.
-
- Args:
- exec: the atest command.
-
- The test result will be like running:
- $ atest -p prebuilts/asuite/atest/smoke_test_data/test_mappings
- """
- print(inspect.currentframe().f_code.co_name)
- dest_dir = os.path.join(SMOKE_DIR, 'test_mappings', 'A')
- args = '{} {}'.format(TITLE, dest_dir)
- cmd = exec + args.split()
- expected_rc = 0
- actual_rc = subprocess.call(cmd)
- error_msg = 'Failed testing TEST_MAPPING in path {}'.format(dest_dir)
- if not utils.is_passed(expected_rc, actual_rc, '', error_msg):
- utils.init_test_mapping_files(action='delete')
- sys.exit(1)
-
-
-def test_no_TEST_MAPPING(exec):
- """Test cannot find TEST_MAPPING from cwd to ANDROID_BUILD_TOP.
-
- Args:
- exec: the atest command.
-
- The test result will be like running:
- $ cd prebuilts/asuite/atest/smoke_test_data
- $ atest
- """
- print(inspect.currentframe().f_code.co_name)
- os.chdir(SMOKE_DIR)
- expected_rc = 4
- actual_rc = subprocess.call(exec)
- error_msg = ('Mismatch exit code: The EXIT_CODE_TEST_NOT_FOUND '
- 'should be {}, but {} found'.format(actual_rc, expected_rc))
- if actual_rc != expected_rc:
- print(error_msg)
- utils.init_test_mapping_files(action='delete')
- sys.exit(1)
-
-
-def main():
- utils.print_banner(TITLE)
- tests = [test_TEST_MAPPING_in_CWD,
- test_TEST_MAPPING_in_path,
- test_no_TEST_MAPPING]
- utils.init_test_mapping_files(action='create')
- for i, test in enumerate(tests):
- ATEST = ['atest'] if utils.has_devices() else ['atest', '--start-avd']
- print('\n[{}/{}] '.format(i+1, len(tests)), end='')
- tests[i](ATEST)
- utils.init_test_mapping_files(action='delete')
- utils.print_banner(TITLE, True)
diff --git a/atest/smoke_test_data/test_mappings/A/B/test_mapping.json b/atest/smoke_test_data/test_mappings/A/B/test_mapping.json
deleted file mode 100644
index 341460b..0000000
--- a/atest/smoke_test_data/test_mappings/A/B/test_mapping.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "postsubmit": [
- {
- "name": "asuite_metrics_lib_tests",
- "host": true
- },
- {
- "name": "asuite_cc_lib_tests",
- "host": true
- },
- {
- "name": "HelloWorldATest"
- }
- ]
-}
diff --git a/atest/smoke_test_data/test_mappings/A/test_mapping.json b/atest/smoke_test_data/test_mappings/A/test_mapping.json
deleted file mode 100644
index af6ace1..0000000
--- a/atest/smoke_test_data/test_mappings/A/test_mapping.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "presubmit": [
- {
- "name": "atest_will_pass_tests"
- },
- {
- "name": "HelloWorldATest"
- }
- ]
-}
diff --git a/atest/smoke_test_data/utils.py b/atest/smoke_test_data/utils.py
deleted file mode 100644
index 23e1432..0000000
--- a/atest/smoke_test_data/utils.py
+++ /dev/null
@@ -1,208 +0,0 @@
-# Copyright 2020, The Android Open Source Project
-#
-# 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
-#
-# http://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.
-
-import json
-import os
-import shutil
-import subprocess
-
-SMOKE_DIR = os.path.dirname(os.path.realpath(__file__))
-TOP = 'ANDROID_BUILD_TOP'
-TEST_RESULT = '/tmp/atest_result/LATEST/test_result'
-
-
-def print_banner(title, passed=False):
- """Simple banner printer.
-
- Args:
- title: string of content that will be printed.
- passed: boolean that control the type of banner.
- True: ========================================
- Running: --test-mapping Passed!
- ========================================
- False:########################################
- Running: --test-mapping
- ########################################
- """
- banner = '#'
- content = '\nRunning: ' + title
- if passed:
- content += ' Passed!'
- banner = '='
- content += '\n'
- print('\n' + 40*banner + content + 40*banner + '\n')
-
-
-def is_identical(desired, actual, target):
- """Tell whether two values are indentical or not.
-
- Args:
- desired: can be any type.
- actual: can be any type.
- target: A string to print before returning False.
-
- Returns:
- Boolean: True when they are the same, otherwise False.
- """
- if str(desired) != str(actual):
- print('{} should be {} instead of {}.'.format(target, desired, actual))
- return False
- return True
-
-
-def is_passed(expected_rc, actual_rc, args, message):
- """Ensure test is passed by checking return code and test_result.
-
- Args:
- args: A string that passed to atest. e.g. '--test-mapping'
- expected_rc: An integer that we expected atest to return.
- actual_rc: An integer that returned by atest.
- message: A string to print before returning False.
- Returns:
- True if ['FAILED'] == 0 and the expected rc is equal to the actual rc,
- otherwise False.
- """
- # 1. Return code must be identical.
- if not is_identical(expected_rc, actual_rc, message):
- return False
- # 2. No FAILED in test_result.
- if os.path.exists(TEST_RESULT):
- with open(TEST_RESULT, 'r') as cache:
- result = json.load(cache)
- if (result['args'] == args and result['total_summary']['FAILED'] != 0):
- print("\nThe test passed but failures found in {}".format(TEST_RESULT))
- return False
- return True
-
-
-def init_test_mapping_files(action='delete'):
- """Method that create or delete TEST_MAPPING while running smoke testing.
-
- Args:
- action: A string to decide the action: 'delete' is to remove TEST_MAPPING
- while 'create' is copying from test_mapping.json to TEST_MAPPING.
- """
- tma = [os.path.join(SMOKE_DIR, 'test_mappings/A/test_mapping.json'),
- os.path.join(SMOKE_DIR, 'test_mappings/A/TEST_MAPPING')]
- tmb = [os.path.join(SMOKE_DIR, 'test_mappings/A/B/test_mapping.json'),
- os.path.join(SMOKE_DIR, 'test_mappings/A/B/TEST_MAPPING')]
- if action == 'create':
- for tm in (tma, tmb):
- shutil.copy2(tm[0], tm[1])
- elif action == 'delete':
- cmd = 'find {} -name TEST_MAPPING -exec rm -f {{}} \;'.format(SMOKE_DIR)
- subprocess.call(cmd, shell=True)
-
-
-def get_test_counts():
- """Get the number of testing targets are as expected from test_result.
-
- E.g. atest targetA targetB, running get_test_counts() should return 2.
-
- Returns:
- An integer that AtestTradefedTestRunner appears in test_result.
- """
- if os.path.exists(TEST_RESULT):
- with open(TEST_RESULT, 'r') as cache:
- result = json.load(cache)
- return len(result['test_runner']['AtestTradefedTestRunner'].keys())
- return 0
-
-
-def func_wrapper(func, args):
- """This method is for the convenience of invoking the function by passing
- argument as a list.
-
- Args:
- func: A method name.
- args: A list of argument.
- """
- func(*args)
-
-
-def get_test_threads():
- """Get the number of running threads.
-
- If 3 tests within the testable module, and the iteration number is 5,
- the ModuleListener will appear 15 times.
-
- Returns:
- An integer that ModuleListener appears in host_log.
- """
- # Example of a host log:
- # D/ModuleListener: ModuleListener.testRunStarted(atest_will_pass_tests, 3, 0)
- # D/ModuleListener: ModuleListener.testStarted(atest_will_pass_tests#PrintAtestPass)
- # I/ModuleListener: [1/3] atest_will_pass_tests#PrintAtestPass PASSED
- # D/ModuleListener: ModuleListener.testStarted(atest_will_pass_tests#PassEqual)
- # I/ModuleListener: [2/3] atest_will_pass_tests#PassEqual PASSED
- # D/ModuleListener: ModuleListener.testStarted(atest_will_pass_tests#PassFloatEqual)
- # I/ModuleListener: [3/3] atest_will_pass_tests#PassFloatEqual PASSED
- #
- # Grab pattern 'ModuleListener: [3/3]' to decide how many testing threads.
- cmd = ('zcat /tmp/atest_result/LATEST/log/in*/host_log*.zip'
- '| egrep "ModuleListener:\s+\[[[:digit:]]/[[:digit:]]\]" | wc -l')
- return subprocess.check_output(cmd, shell=True).decode().strip()
-
-
-def get_passed_counts():
- """Get the number of PASSED in end_host_log.
-
- Returns:
- An integer that shows PASSED in end_host_log.
- """
- cmd = ('zcat /tmp/atest_result/LATEST/log/in*/end_host_log*.zip'
- '| grep PASSED | awk -F": " \'{{print $2}}\'')
- return subprocess.check_output(cmd, shell=True).decode().strip()
-
-
-def get_failed_counts():
- """Get the number of FAILED in end_host_log.
-
- Returns:
- An integer that shows PASSED in end_host_log.
- """
- cmd = ('zcat /tmp/atest_result/LATEST/log/in*/end_host_log*.zip'
- '| grep FAILED | awk -F": " \'{{print $2}}\'')
- return subprocess.check_output(cmd, shell=True).decode().strip()
-
-
-def has_correct_passed_failed_counts(passes, failures):
- """Given desired passed and failed numbers, and return if they are the same
- as expectation.
-
- Args:
- passes: An integer of desired passed number.
- failures: An integer of desired failed number.
-
- Returns:
- A boolean: True if both passed/failed numbers match the result,
- otherwise False.
- """
- if not is_identical(passes, get_passed_counts(), "PASSED number"):
- return False
- if not is_identical(failures, get_failed_counts(), "FAILED number"):
- return False
- return True
-
-
-def has_devices():
- """Method that probes attached devices.
-
- Returns:
- True: when there are either physical/virtual devices.
- False: when no devices or no adb command; acloud will build adb
- automatically.
- """
- cmd = 'adb devices | egrep -v "^List|^$"'
- return not bool(subprocess.call(cmd, shell=True))