summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore8
-rw-r--r--Dockerfile60
-rw-r--r--PREUPLOAD.cfg2
-rwxr-xr-xacloud/linux-x86/acloudbin4200555 -> 4068662 bytes
-rwxr-xr-xaidegen/darwin-x86/aidegen6
-rwxr-xr-xaidegen/linux-x86/aidegenbin451899 -> 350140 bytes
-rwxr-xr-xaidegen/smoke_tests121
-rwxr-xr-xatest/linux-x86/atestbin428540 -> 380573 bytes
-rwxr-xr-xrelease_checker.py188
-rwxr-xr-xrelease_checker.sh47
10 files changed, 51 insertions, 381 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index d5e0e2e..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Below is the log of fetch_artifact and is always removed after a
-# successful run of presubmit_uploader.sh. However, it may not be
-# deleted if the user interrupts manually(Ctrl+C) until a
-# successful run next time.
-**/.fetch_artifact2.dat
-
-# Below records the timestamp of last time of running "repo sync".
-**/.repo_sync.log
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index d090de4..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright 2019, 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.
-
-FROM ubuntu:latest
-ARG UID
-ARG USER
-ARG SRCTOP
-ENV IS_CONTAINER=true
-ENV USER=${USER}
-
-# Installing AOSP essential packages and creating the local user.
-# The UID inside and outside must be the same.
-RUN useradd -mu ${UID} ${USER} && \
- sed -i 's/archive/tw.archive/' /etc/apt/sources.list && \
- export DEBIAN_FRONTEND=noninteractive && \
- apt-get update -qq && apt-get install -y \
- git-core \
- gnupg \
- flex \
- bison \
- gperf \
- build-essential \
- zip \
- unzip \
- curl \
- zlib1g-dev \
- gcc-multilib \
- g++-multilib \
- libc6-dev-i386 \
- lib32ncurses5-dev \
- x11proto-core-dev \
- libx11-dev \
- lib32z-dev \
- libgl1-mesa-dev \
- libxml2-utils \
- tzdata \
- python-dev \
- python3-dev \
- xsltproc
-
-# Configuring tzdata noninteractively
-RUN ln -fs /usr/share/zoneinfo/Asia/Taipei /etc/localtime && \
- dpkg-reconfigure -f noninteractive tzdata
-ENV LANG=C.UTF-8
-
-# Run smoke_tests by default unless overriding the startup command.
-USER ${USER}
-WORKDIR ${SRCTOP}
-CMD ["prebuilts/asuite/aidegen/smoke_tests"]
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index e371bd1..6606920 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -1,2 +1,2 @@
[Hook Scripts]
-release_checker = ${REPO_ROOT}/prebuilts/asuite/release_checker.py ${PREUPLOAD_FILES}
+release_checker = ${REPO_ROOT}/prebuilts/asuite/release_checker.sh
diff --git a/acloud/linux-x86/acloud b/acloud/linux-x86/acloud
index 1550b60..1bfb1a3 100755
--- a/acloud/linux-x86/acloud
+++ b/acloud/linux-x86/acloud
Binary files differ
diff --git a/aidegen/darwin-x86/aidegen b/aidegen/darwin-x86/aidegen
index 5e8b640..0bc7d56 100755
--- a/aidegen/darwin-x86/aidegen
+++ b/aidegen/darwin-x86/aidegen
@@ -14,14 +14,14 @@
# limitations under the License.
# Check python3 availability.
-desired_pyver=3.6.0
+desired_pyver=3.7.0
function helper() {
cat << END
To install Python $desired_pyver, you may want to follow either approach:
* homebrew: https://hackercodex.com/guide/python-development-environment-on-mac-osx/
* macports: https://www.macports.org/install.php
- and run "port -N install python36"
-* from package: https://www.python.org/downloads/release/python-360/
+ and run "port -N install python37"
+* from package: https://www.python.org/downloads/release/python-370/
download and install the appropriate one.
END
}
diff --git a/aidegen/linux-x86/aidegen b/aidegen/linux-x86/aidegen
index ec89bc6..06c5aa5 100755
--- a/aidegen/linux-x86/aidegen
+++ b/aidegen/linux-x86/aidegen
Binary files differ
diff --git a/aidegen/smoke_tests b/aidegen/smoke_tests
deleted file mode 100755
index bffa606..0000000
--- a/aidegen/smoke_tests
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env bash
-#
-# Copyright 2019, 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.
-
-# Variables that will be used inside of containers.
-SRCTOP="/home/$USER/aosp"
-TARGET="aosp_cf_x86_phone-userdebug"
-# Variables that will be used when creating docker image.
-IMAGE="aosp/asuite"
-DOCKERFILE_DIR=$(realpath $(dirname $0)/..)
-# Whenever amending Dockerfile, update the md5 checksum accordingly.
-DOCKERFILE_MD5SUM="40ffbf07477406a7cd6c709cb7ee6c3a"
-SLIENCE_FLAG='>/dev/null 2>&1'
-
-# The core functional tests for AIDEGen.
-function run_functiontests() {
- local target="aidegen_functional_test"
- if ! m $target; then
- echo -e "\n[Error] Fail to build $target.\n"
- exit 1
- fi
- if ! ${target}-dev -b; then
- echo -e "\n[Error] Fail to run ${target}-dev.\n"
- exit 1
- fi
-}
-
-# Initialize $ANDROID_BUILD_TOP in container and install m().
-function check_env() {
- if [[ -z "$ANDROID_BUILD_TOP" ]]; then
- if [[ "$IS_CONTAINER" = "true" ]]; then
- pushd "$SRCTOP"
- source build/envsetup.sh && lunch $TARGET
- popd
- else
- echo -ne "\n[Error] Missing \$ANDROID_BUILD_TOP variable. "
- echo -e "Please run 'lunch' first.\n"
- exit 1
- fi
- fi
- function m() {
- echo "[Info] m $@"
- ${ANDROID_BUILD_TOP}/build/soong/soong_ui.bash --make-mode "$@"
- }
- [[ $(uname -s) = "Darwin" ]] && export IS_CONTAINER=true
-}
-
-# TODO: Move this method to asuite.sh.
-function build_docker_image() {
- echo "[Info] Start building Docker image $IMAGE..."
- build_cmd="docker build --rm --force-rm --no-cache \
- --build-arg USER=$USER \
- --build-arg UID=$UID \
- --build-arg SRCTOP=$SRCTOP \
- -t $IMAGE $DOCKERFILE_DIR"
- if ! eval $build_cmd; then
- echo -e "\n[Error] Failed to build docker image."
- exit 1
- fi
-}
-
-# TODO: Move this method to asuite.sh.
-function run_docker_instance() {
- echo "[Info] Start a Docker container..."
- docker run --rm -v $ANDROID_BUILD_TOP:$SRCTOP $IMAGE
-}
-
-# TODO: Move this method to asuite.sh.
-function has_docker() {
- [[ "$IS_CONTAINER" = "true" ]] && return 1
- if ! systemctl is-active docker -q; then
- echo "[Error] Docker daemon not running."
- exit 1
- elif ! docker ps $SILENCE_FLAG; then
- echo "[Error] $USER not in docker group."
- exit 1
- fi
-}
-
-# TODO: Move this method to asuite.sh.
-function has_docker_image() {
- image_id=$(docker images --filter=reference=$IMAGE --format "{{.ID}}")
- if [[ -z $image_id ]]; then
- echo "[Info] Docker image $IMAGE not found."
- return 1
- fi
- checksum=$(md5sum $DOCKERFILE_DIR/Dockerfile | awk '{print $1}')
- if [[ $checksum != $DOCKERFILE_MD5SUM ]]; then
- echo "[Info] Docker image $IMAGE is outdated."
- return 1
- fi
-}
-
-# Run functional tests directly when in MacOS or in a container.
-# Pass IS_CONTAINER=true to run functional tests when Docker is installed on Linux.
-function main() {
- check_env
- if ! has_docker; then
- m clean
- run_functiontests
- else
- if ! has_docker_image; then
- build_docker_image
- fi
- run_docker_instance
- fi
-}
-
-main
diff --git a/atest/linux-x86/atest b/atest/linux-x86/atest
index 708ee9e..56d0e9a 100755
--- a/atest/linux-x86/atest
+++ b/atest/linux-x86/atest
Binary files differ
diff --git a/release_checker.py b/release_checker.py
deleted file mode 100755
index 042de31..0000000
--- a/release_checker.py
+++ /dev/null
@@ -1,188 +0,0 @@
-#!/usr/bin/env python3
-# Copyright 2019, 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 argparse
-import os
-import shlex
-import subprocess
-import sys
-
-
-PREBUILTS_DIR = os.path.dirname(__file__)
-PROJECTS = {'acloud', 'aidegen', 'atest'}
-ARCHS = {'linux-x86', 'darwin-x86'}
-SMOKE_TEST = 'smoke_tests'
-EXIT_TEST_PASS = 0
-EXIT_TEST_FAIL = 1
-EXIT_INVALID_BINS = 2
-
-
-def _get_prebuilt_bins():
- """Get asuite prebuilt binaries.
-
- Returns:
- A set of prebuilt binaries.
- """
- return {os.path.join(prj, arch, prj) for prj in PROJECTS for arch in ARCHS}
-
-
-def _get_prebuilt_dirs():
- """Get asuite prebuilt directories.
-
- Returns:
- A set of prebuilt paths of binaries.
- """
- return {os.path.dirname(bin) for bin in _get_prebuilt_bins()}
-
-
-def _get_smoke_tests_bins():
- """Get asuite smoke test scripts.
-
- Returns:
- A dict of project and smoke test script paths.
- """
- return {prj: os.path.join(prj, SMOKE_TEST) for prj in PROJECTS}
-
-
-def _is_executable(bin_path):
- """Check if the given file is executable.
-
- Args:
- bin_path: a string of a file path.
-
- Returns:
- True if it is executable, false otherwise.
- """
- return os.access(bin_path, os.X_OK)
-
-
-def check_uploaded_bins(preupload_files):
- """This method validates the uploaded files.
-
- If the uploaded file is in prebuilt_bins, ensure:
- - it is executable.
- - only one at a time.
- If the uploaded file is a smoke_test script, ensure:
- - it is executable.
- If the uploaded file is placed in prebuilt_dirs, ensure:
- - it is not executable.
- (It is to ensure PATH is not contaminated.
- e.g. atest/linux-x86/atest-dev will override $OUT/bin/atest-dev, or
- atest/linux-x86/rm does fraud/harmful things.)
-
- Args:
- preupload_files: A list of preuploaded files.
-
- Returns:
- True is the above criteria are all fulfilled, otherwise None.
- """
- prebuilt_bins = _get_prebuilt_bins()
- prebuilt_dirs = _get_prebuilt_dirs()
- smoke_tests_bins = _get_smoke_tests_bins().values()
- # Store valid executables.
- target_bins = set()
- # Unexpected executable files which may cause issues(they are in $PATH).
- illegal_bins = set()
- # Store prebuilts or smoke test script that are inexecutable.
- insufficient_perm_bins = set()
- for f in preupload_files:
- # Ensure target_bins are executable.
- if f in prebuilt_bins:
- if _is_executable(f):
- target_bins.add(f)
- else:
- insufficient_perm_bins.add(f)
- # Ensure smoke_tests scripts are executable.
- elif f in smoke_tests_bins and not _is_executable(f):
- insufficient_perm_bins.add(f)
- # Avoid fraud commands in $PATH. e.g. atest/linux-x86/rm.
- # must not be executable.
- elif os.path.dirname(f) in prebuilt_dirs and _is_executable(f):
- illegal_bins.add(f)
- if len(target_bins) > 1:
- print('\nYou\'re uploading multiple binaries: %s'
- % ' '.join(target_bins))
- print('\nPlease upload one prebuilt at a time.')
- return False
- if insufficient_perm_bins:
- print('\nInsufficient permission found: %s'
- % ' '.join(insufficient_perm_bins))
- print('\nPlease run:\n\tchmod 0755 %s\nand try again.'
- % ' '.join(insufficient_perm_bins))
- return False
- if illegal_bins:
- illegal_dirs = {os.path.dirname(bin) for bin in illegal_bins}
- print('\nIt is forbidden to upload executable file: %s'
- % '\n - %s\n' % '\n - '.join(illegal_bins))
- print('Because they are in the project paths: %s'
- % '\n - %s\n' % '\n - '.join(illegal_dirs))
- print('Please remove the binaries or make the files non-executable.')
- return False
- return True
-
-
-def run_smoke_tests_pass(files_to_check):
- """Run smoke tests.
-
- Args:
- files_to_check: A list of preuploaded files to check.
-
- Returns:
- True when test passed or no need to test.
- False when test failed.
- """
- for target in files_to_check:
- if target in _get_prebuilt_bins():
- project = os.path.basename(target)
- test_file = _get_smoke_tests_bins().get(project)
- if os.path.exists(test_file):
- try:
- subprocess.check_output(test_file, encoding='utf-8',
- stderr=subprocess.STDOUT)
- except subprocess.CalledProcessError as error:
- print('Smoke tests failed at:\n\n%s' % error.output)
- return False
- except OSError as oserror:
- print('%s: Missing the header of the script.' % oserror)
- print('Please define shebang like:\n')
- print('#!/usr/bin/env bash\nor')
- print('#!/usr/bin/env python3\n')
- return False
- return True
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument('--skip-smoke-test', '-s', action="store_true",
- help='Disable smoke testing.')
- parser.add_argument('preupload_files', nargs='*', help='Files to be uploaded.')
- args = parser.parse_args()
- files_to_check = args.preupload_files
- # Pre-process files_to_check(run directly by users.)
- if not files_to_check:
- # Only consider added(A), renamed(R) and modified(M) files.
- cmd = "git status --short | egrep ^[ARM] | awk '{print $NF}'"
- preupload_files = subprocess.check_output(cmd, shell=True,
- encoding='utf-8').splitlines()
- if preupload_files:
- print('validating: %s' % preupload_files)
- files_to_check = preupload_files
- # Validating uploaded files and run smoke test script(run by repohook).
- if not check_uploaded_bins(files_to_check):
- sys.exit(EXIT_INVALID_BINS)
- if not args.skip_smoke_test and not run_smoke_tests_pass(files_to_check):
- sys.exit(EXIT_TEST_FAIL)
- sys.exit(EXIT_TEST_PASS)
diff --git a/release_checker.sh b/release_checker.sh
new file mode 100755
index 0000000..9139ca6
--- /dev/null
+++ b/release_checker.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+# Copyright 2019, 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.
+
+# filenames that will be checked permissions.
+targets="atest|acloud|aidegen"
+
+function permission_checker() {
+ invalid_items=""
+ for item in "$@"; do
+ if [ -n "$(echo $(basename $item)|egrep "$targets")" -a ! -x "$item" ]; then
+ invalid_items="$item $invalid_items"
+ fi
+ done
+ if [ -n "$invalid_items" ]; then
+ echo -e "\nInsufficient permission detected:"
+ while read line; do
+ echo "- $line"
+ done < <(echo $invalid_items| sed 's/\ /\n/g')
+ echo "Please run the following command and try again:"
+ echo "chmod 0755 $invalid_items"
+ return 1
+ fi
+}
+
+function release_checker_main() {
+ # The main function is going to check:
+ # - permission of prebuilts.
+ # - integration tests.
+ # - other needed tests.
+ PREBUILTS_DIR=$ANDROID_BUILD_TOP/prebuilts/asuite
+ permission_checker $(find $PREBUILTS_DIR/{acloud,aidegen,atest}/{linux,darwin}-x86 -type f)
+ # TODO: do integration tests for asuite when they are available.
+}
+
+release_checker_main