summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Duong <joshuaduong@google.com>2023-08-23 11:22:31 -0700
committerJoshua Duong <joshuaduong@google.com>2023-08-23 11:22:31 -0700
commit462ecd71fd8c40ff52210a35b368e25e0cf8aebb (patch)
tree9f537905676895189766ff3197f573fffafdaecb
parent571264ab35c8a13dfbdc85732eb815c5a33db681 (diff)
downloadadt-infra-462ecd71fd8c40ff52210a35b368e25e0cf8aebb.tar.gz
[mac] Abort running tests if no physical display.
Bug: 296110150 Test: pytest Change-Id: I2140917799501d8414fb50506c84be5fcc1f48a9
-rw-r--r--emu_test/utils/common.sh16
-rwxr-xr-xemu_test/utils/run_adb_test.sh1
-rwxr-xr-xemu_test/utils/run_emu_test.sh1
-rwxr-xr-xpytest/test_embedded/run_tests.sh2
-rw-r--r--pytest/test_embedded/shell/utils/common.sh16
5 files changed, 36 insertions, 0 deletions
diff --git a/emu_test/utils/common.sh b/emu_test/utils/common.sh
index 7a45b7e6..11e35d8c 100644
--- a/emu_test/utils/common.sh
+++ b/emu_test/utils/common.sh
@@ -692,3 +692,19 @@ aosp_find_python() {
$PYTHON --version >/dev/null || panic "Unable to get python version from $PYTHON"
printf "$PYTHON"
}
+
+check_physical_display() {
+ case $(get_build_os) in
+ darwin)
+ run system_profiler SPDisplaysDataType
+ display_type=$(system_profiler SPDisplaysDataType | grep "Display Type:")
+ if [ -z $display_type ]; then
+ panic "No physical display detected. Aborting tests."
+ else
+ printf "Display type found: $display_type"
+ fi
+ ;;
+ *)
+ ;;
+ esac
+} \ No newline at end of file
diff --git a/emu_test/utils/run_adb_test.sh b/emu_test/utils/run_adb_test.sh
index 08b6a8be..5fa75b00 100755
--- a/emu_test/utils/run_adb_test.sh
+++ b/emu_test/utils/run_adb_test.sh
@@ -48,6 +48,7 @@ aosp_find_python() {
printf "$PYTHON"
}
+check_physical_display
PYTHON=$(aosp_find_python)
export PYTEST_ADDOPTS="-m 'adb'"
run $PYTHON "$AOSP_DIR/external/adt-infra/pytest/test_embedded/run_tests.py" --build_dir out/prebuilt_cached/builds --logdir "$DISTRIB_DIR/testlogs" --build_target $build_target
diff --git a/emu_test/utils/run_emu_test.sh b/emu_test/utils/run_emu_test.sh
index af40621c..e0530f34 100755
--- a/emu_test/utils/run_emu_test.sh
+++ b/emu_test/utils/run_emu_test.sh
@@ -37,5 +37,6 @@ aosp_find_python() {
printf "$PYTHON"
}
+check_physical_display
PYTHON=$(aosp_find_python)
run $PYTHON $AOSP_DIR/external/adt-infra/pytest/test_embedded/run_tests.py --build_dir out/prebuilt_cached/builds --logdir $DISTRIB_DIR/testlogs --build_target $build_target \ No newline at end of file
diff --git a/pytest/test_embedded/run_tests.sh b/pytest/test_embedded/run_tests.sh
index 48a9f6c1..a0f64dd4 100755
--- a/pytest/test_embedded/run_tests.sh
+++ b/pytest/test_embedded/run_tests.sh
@@ -32,5 +32,7 @@ aosp_find_python() {
printf "$PYTHON"
}
+log "Checking physical display.."
+check_physical_display
PYTHON=$(aosp_find_python)
run $PYTHON $AOSP_DIR/external/adt-infra/pytest/test_embedded/run_tests.py "$@"
diff --git a/pytest/test_embedded/shell/utils/common.sh b/pytest/test_embedded/shell/utils/common.sh
index bf1d1379..abb06109 100644
--- a/pytest/test_embedded/shell/utils/common.sh
+++ b/pytest/test_embedded/shell/utils/common.sh
@@ -698,6 +698,22 @@ is_presubmit () {
printf "$retval"
}
+check_physical_display() {
+ case $(get_build_os) in
+ darwin)
+ run system_profiler SPDisplaysDataType
+ display_type=$(system_profiler SPDisplaysDataType | grep "Display Type:")
+ if [ -z $display_type ]; then
+ panic "No physical display detected. Aborting tests."
+ else
+ printf "Display type found: $display_type"
+ fi
+ ;;
+ *)
+ ;;
+ esac
+}
+
PYTHON="python3"
# Check that python is installed and working.