move lunch specific tests to separate file

This is in preparation to add some more tests to this file.

Test: build/make/tests/envsetup_tests.sh
Change-Id: Ic32115d2a6073f3265b84846f489f3acb8bfad88
This commit is contained in:
Sam Delmerico 2022-09-02 17:00:33 -04:00
parent 59699234bc
commit 4f4d069efa
2 changed files with 66 additions and 33 deletions

View file

@ -1,37 +1,22 @@
#!/bin/bash -e #!/bin/bash -e
# Copyright (C) 2022 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.
source $(dirname $0)/../envsetup.sh tests=(
$(dirname $0)/lunch_tests.sh
unset TARGET_PRODUCT TARGET_BUILD_VARIANT TARGET_PLATFORM_VERSION
function check_lunch
(
echo lunch $1
set +e
lunch $1 > /dev/null 2> /dev/null
set -e
[ "$TARGET_PRODUCT" = "$2" ] || ( echo "lunch $1: expected TARGET_PRODUCT='$2', got '$TARGET_PRODUCT'" && exit 1 )
[ "$TARGET_BUILD_VARIANT" = "$3" ] || ( echo "lunch $1: expected TARGET_BUILD_VARIANT='$3', got '$TARGET_BUILD_VARIANT'" && exit 1 )
[ "$TARGET_PLATFORM_VERSION" = "$4" ] || ( echo "lunch $1: expected TARGET_PLATFORM_VERSION='$4', got '$TARGET_PLATFORM_VERSION'" && exit 1 )
) )
default_version=$(get_build_var DEFAULT_PLATFORM_VERSION) for test in $tests; do
valid_version=PPR1 bash -x $test
done
# lunch tests
check_lunch "aosp_arm64" "aosp_arm64" "eng" ""
check_lunch "aosp_arm64-userdebug" "aosp_arm64" "userdebug" ""
check_lunch "aosp_arm64-userdebug-$default_version" "aosp_arm64" "userdebug" "$default_version"
check_lunch "aosp_arm64-userdebug-$valid_version" "aosp_arm64" "userdebug" "$valid_version"
check_lunch "abc" "" "" ""
check_lunch "aosp_arm64-abc" "" "" ""
check_lunch "aosp_arm64-userdebug-abc" "" "" ""
check_lunch "aosp_arm64-abc-$valid_version" "" "" ""
check_lunch "abc-userdebug-$valid_version" "" "" ""
check_lunch "-" "" "" ""
check_lunch "--" "" "" ""
check_lunch "-userdebug" "" "" ""
check_lunch "-userdebug-" "" "" ""
check_lunch "-userdebug-$valid_version" "" "" ""
check_lunch "aosp_arm64-userdebug-$valid_version-" "" "" ""
check_lunch "aosp_arm64-userdebug-$valid_version-abc" "" "" ""

48
tests/lunch_tests.sh Executable file
View file

@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Copyright (C) 2022 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.
source $(dirname $0)/../envsetup.sh
unset TARGET_PRODUCT TARGET_BUILD_VARIANT TARGET_PLATFORM_VERSION
function check_lunch
(
echo lunch $1
set +e
lunch $1 > /dev/null 2> /dev/null
set -e
[ "$TARGET_PRODUCT" = "$2" ] || ( echo "lunch $1: expected TARGET_PRODUCT='$2', got '$TARGET_PRODUCT'" && exit 1 )
[ "$TARGET_BUILD_VARIANT" = "$3" ] || ( echo "lunch $1: expected TARGET_BUILD_VARIANT='$3', got '$TARGET_BUILD_VARIANT'" && exit 1 )
[ "$TARGET_PLATFORM_VERSION" = "$4" ] || ( echo "lunch $1: expected TARGET_PLATFORM_VERSION='$4', got '$TARGET_PLATFORM_VERSION'" && exit 1 )
)
default_version=$(get_build_var DEFAULT_PLATFORM_VERSION)
# lunch tests
check_lunch "aosp_arm64" "aosp_arm64" "eng" ""
check_lunch "aosp_arm64-userdebug" "aosp_arm64" "userdebug" ""
check_lunch "aosp_arm64-userdebug-$default_version" "aosp_arm64" "userdebug" "$default_version"
check_lunch "abc" "" "" ""
check_lunch "aosp_arm64-abc" "" "" ""
check_lunch "aosp_arm64-userdebug-abc" "" "" ""
check_lunch "aosp_arm64-abc-$default_version" "" "" ""
check_lunch "abc-userdebug-$default_version" "" "" ""
check_lunch "-" "" "" ""
check_lunch "--" "" "" ""
check_lunch "-userdebug" "" "" ""
check_lunch "-userdebug-" "" "" ""
check_lunch "-userdebug-$default_version" "" "" ""
check_lunch "aosp_arm64-userdebug-$default_version-" "" "" ""
check_lunch "aosp_arm64-userdebug-$default_version-abc" "" "" ""