forked from isieo/adbFS
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from spion/feat/add-docker-testing
feat: add docker testing
- Loading branch information
Showing
4 changed files
with
257 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM ubuntu:latest as buildenv | ||
RUN apt update | ||
RUN apt install -y build-essential git pkg-config | ||
RUN apt install -y libfuse-dev fuse | ||
ADD ./* /src/ | ||
WORKDIR /src | ||
RUN make | ||
|
||
|
||
FROM us-docker.pkg.dev/android-emulator-268719/images/30-google-x64:30.1.2 | ||
# FROM docker.io/budtmo/docker-android:emulator_12.0 | ||
# RUN apt update | ||
|
||
# RUN apt install -y fuse libfuse-dev | ||
|
||
# ADD ./* /src/ | ||
ADD ./tests/* /src/tests/ | ||
ADD ./docker/* /src/docker/ | ||
|
||
RUN chmod +x /src/docker/*.sh | ||
|
||
COPY --from=buildenv /src/adbfs /usr/bin/adbfs | ||
RUN chmod +x /usr/bin/adbfs | ||
|
||
WORKDIR /src | ||
# CMD /src/docker/run-docker-test.sh | ||
ENTRYPOINT [ "sudo", "bash", "/src/docker/run-test.sh" ] | ||
# ENTRYPOINT [ "bash" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
export SCRIPT_PATH="docker-android" | ||
export WORK_PATH="/home/androidusr" | ||
export APP_PATH=${WORK_PATH}/${SCRIPT_PATH} | ||
export LOG_PATH=${WORK_PATH}/logs | ||
export SUPERVISORD_CONFIG_PATH="${APP_PATH}/mixins/configs/process" | ||
export DEVICE_TYPE=emulator | ||
|
||
/usr/bin/supervisord --configuration ${SUPERVISORD_CONFIG_PATH}/supervisord-port.conf & \ | ||
/usr/bin/supervisord --configuration ${SUPERVISORD_CONFIG_PATH}/supervisord-base.conf & \ | ||
|
||
bash $(dirname $0)/../tests/run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
#!/bin/bash | ||
|
||
# echo Running supervisord in the background | ||
# cd /root || exit | ||
|
||
# SUPERVISORD_CONFIG_PATH="${APP_PATH}/mixins/configs/process" | ||
# /usr/bin/supervisord --configuration ${SUPERVISORD_CONFIG_PATH}/supervisord-port.conf & \ | ||
# /usr/bin/supervisord --configuration ${SUPERVISORD_CONFIG_PATH}/supervisord-base.conf & \ | ||
|
||
WAIT_TIME=60 | ||
|
||
|
||
wait_available() { | ||
|
||
RETRIES=$WAIT_TIME | ||
WAIT_DIR="$1" | ||
|
||
while [ $RETRIES -gt 0 ]; | ||
do | ||
RETRIES=$((RETRIES - 1)) | ||
|
||
OUTPUT=$(adb shell ls -d "$WAIT_DIR" 2> /dev/null) | ||
|
||
if [ "$OUTPUT" == "$WAIT_DIR" ] | ||
then | ||
break; | ||
fi | ||
sleep 1 | ||
|
||
done | ||
|
||
if [ $RETRIES -le 0 ] | ||
then | ||
echo "Emulator directory $1 was not available for $WAIT_TIME seconds, exiting" | ||
echo "Last output was: $OUTPUT" | ||
echo "" | ||
# echo "Logs for docker-appium were (stdout)" | ||
# echo "" | ||
# cat /var/log/supervisor/docker-android.stdout.log | ||
# echo "" | ||
# echo "stderr" | ||
# echo "" | ||
# cat /var/log/supervisor/docker-android.stderr.log | ||
exit 1 | ||
fi | ||
|
||
} | ||
|
||
echo Checking readiness via adb shell ls -d /sdcard/Android | ||
adb devices | ||
wait_available / | ||
|
||
|
||
mkdir -p /adbfs | ||
adbfs /adbfs | ||
|
||
echo Ready to run adbfs tests | ||
|
||
BASE_DIR=/adbfs/sdcard/test | ||
|
||
test_mkdir() { | ||
|
||
local_timestamp=$(date "+%s") | ||
|
||
mkdir "$BASE_DIR/x" | ||
output=$(ls -lad --time-style="+%s" "$BASE_DIR/x") | ||
|
||
timestamp=$(echo $output | cut -d' ' -f 6) | ||
path=$(echo $output | cut -d' ' -f 7) | ||
|
||
timestamp_diff=$((local_timestamp - timestamp)) | ||
abs_diff=${timestamp_diff#-} | ||
|
||
if [ "$abs_diff" -gt 120 ]; | ||
then | ||
echo "FAIL test_mkdir: file timestamp difference exceeds 120s: $abs_diff" | ||
exit 1 | ||
fi | ||
|
||
if [ "$path" != "$BASE_DIR/x" ]; | ||
then | ||
echo "FAIL test_mkdir: unexpected path" | ||
exit 1 | ||
fi | ||
|
||
echo "PASS test_mkdir" | ||
} | ||
|
||
|
||
test_catfile() { | ||
|
||
local_timestamp=$(date "+%s") | ||
|
||
desired_content="Hello world" | ||
|
||
echo "$desired_content" > "$BASE_DIR/file.txt" | ||
|
||
output=$(ls -lad --time-style="+%s" "$BASE_DIR/file.txt") | ||
|
||
timestamp=$(echo $output | cut -d' ' -f 6) | ||
path=$(echo $output | cut -d' ' -f 7) | ||
|
||
timestamp_diff=$((local_timestamp - timestamp)) | ||
abs_diff=${timestamp_diff#-} | ||
|
||
if [ "$abs_diff" -gt 120 ]; | ||
then | ||
echo "FAIL test_catfile: file timestamp difference exceeds 120s: $abs_diff" | ||
exit 1 | ||
fi | ||
|
||
if [ "$path" != "$BASE_DIR/file.txt" ]; | ||
then | ||
echo "FAIL test_catfile: unexpected path" | ||
exit 1 | ||
fi | ||
|
||
file_contents=$(cat $BASE_DIR/file.txt) | ||
|
||
if [ "$file_contents" != "Hello world" ] | ||
then | ||
echo "FAIL test_catfile: unexpected content: $file_contents" | ||
echo "Expected: $desired_content" | ||
exit 1 | ||
fi | ||
|
||
echo "PASS test_catfile" | ||
} | ||
|
||
|
||
|
||
mkdir "$BASE_DIR" | ||
|
||
test_mkdir | ||
test_catfile | ||
|
||
# todo | ||
|
||
# copy file with cp -a (archive, preserve timestamps) | ||
|
||
# read a directory | ||
|
||
# touch to update time | ||
|
||
# copy preserving timestamps | ||
|
||
rm -rf "$BASE_DIR" | ||
|
||
|
||
|
||
# rsync, both directions (compared against rsync of the very same tree on a "pure local" FS). | ||
# ompared to adb push --sync as well maybe | ||
|