Skip to content

Commit fdf7a04

Browse files
fixup! [android] Run tests for libdispatch in x64 emulator (wip)
1 parent fe3d38c commit fdf7a04

File tree

2 files changed

+72
-65
lines changed

2 files changed

+72
-65
lines changed

utils/android/utils/ctest_mock.sh

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
1-
#!/system/bin/sh
2-
3-
if [ -z "$1" ]; then
4-
echo "Usage: $0 <sub-directory>"
5-
exit 1
6-
fi
7-
8-
SUB_DIR=$1
9-
if [ ! -d "$SUB_DIR" ]; then
10-
echo "Error: Directory $SUB_DIR does not exist"
11-
exit 1
12-
fi
13-
14-
CTEST_FILE="$SUB_DIR/CTestTestfile.cmake"
15-
if [ ! -f "$CTEST_FILE" ]; then
16-
echo "Error: $CTEST_FILE not found in $SUB_DIR"
17-
exit 1
18-
fi
19-
20-
# TODO: Parse them from CTEST_FILE
21-
TESTS="dispatch_apply dispatch_api dispatch_debug dispatch_queue_finalizer dispatch_overcommit dispatch_context_for_key dispatch_after dispatch_timer dispatch_timer_short dispatch_timer_timeout dispatch_sema dispatch_timer_bit31 dispatch_timer_bit63 dispatch_timer_set_time dispatch_data dispatch_io_muxed dispatch_io_net dispatch_io_pipe dispatch_io_pipe_close dispatch_select dispatch_c99 dispatch_plusplus"
22-
23-
COUNT=$(echo "$TESTS" | tr ' ' '\n' | wc -l)
24-
echo "Found $COUNT test-cases in $SUB_DIR"
25-
26-
UTILITY="$SUB_DIR/bsdtestharness"
27-
if [ ! -f "$UTILITY" ]; then
28-
echo "Utility not found: $UTILITY."
29-
exit 1
30-
fi
31-
32-
chmod +x "$UTILITY"
33-
34-
# We need libdispatch.so and libBlocksRuntime.so
35-
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SUB_DIR"
36-
37-
# TODO: Parse the timeout as well from CTestTestfile.cmake?
38-
TIMOUT=120
39-
FAILURE=0
40-
41-
for TEST in $TESTS; do
42-
chmod +x "$SUB_DIR/$TEST"
43-
OUTPUT=$(timeout "${TIMOUT}s" "$UTILITY" "$SUB_DIR/$TEST" 2>&1)
44-
EC=$?
45-
if [ $EC -eq 124 ]; then
46-
echo "Error: $TEST timed out after $TIMOUT seconds"
47-
echo "************\nOutput:\n$OUTPUT\n************"
48-
FAILURE=1
49-
elif [ $EC -ne 0 ]; then
50-
echo "Error: $TEST failed"
51-
echo "************\nOutput:\n$OUTPUT\n************"
52-
FAILURE=1
53-
else
54-
echo "$TEST passed"
55-
fi
56-
done
57-
58-
exit $FAILURE
1+
#!/system/bin/sh
2+
3+
if [ -z "$1" ]; then
4+
echo "Usage: $0 <sub-directory>"
5+
exit 1
6+
fi
7+
8+
SUB_DIR=$1
9+
if [ ! -d "$SUB_DIR" ]; then
10+
echo "Error: Directory $SUB_DIR does not exist"
11+
exit 1
12+
fi
13+
14+
CTEST_FILE="$SUB_DIR/CTestTestfile.cmake"
15+
if [ ! -f "$CTEST_FILE" ]; then
16+
echo "Error: $CTEST_FILE not found in $SUB_DIR"
17+
exit 1
18+
fi
19+
20+
# TODO: Parse them from CTEST_FILE
21+
TESTS="dispatch_apply dispatch_api dispatch_debug dispatch_queue_finalizer dispatch_overcommit dispatch_context_for_key dispatch_after dispatch_timer dispatch_timer_short dispatch_timer_timeout dispatch_sema dispatch_timer_bit31 dispatch_timer_bit63 dispatch_timer_set_time dispatch_data dispatch_io_muxed dispatch_io_net dispatch_io_pipe dispatch_io_pipe_close dispatch_select dispatch_c99 dispatch_plusplus"
22+
23+
COUNT=$(echo "$TESTS" | tr ' ' '\n' | wc -l)
24+
echo "Found $COUNT test-cases in $SUB_DIR"
25+
26+
UTILITY="$SUB_DIR/bsdtestharness"
27+
if [ ! -f "$UTILITY" ]; then
28+
echo "Utility not found: $UTILITY."
29+
exit 1
30+
fi
31+
32+
chmod +x "$UTILITY"
33+
34+
# We need libdispatch.so and libBlocksRuntime.so
35+
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SUB_DIR"
36+
37+
# TODO: Parse the timeout as well from CTestTestfile.cmake?
38+
TIMOUT=120
39+
FAILURE=0
40+
41+
for TEST in $TESTS; do
42+
chmod +x "$SUB_DIR/$TEST"
43+
OUTPUT=$(timeout "${TIMOUT}s" "$UTILITY" "$SUB_DIR/$TEST" 2>&1)
44+
EC=$?
45+
if [ $EC -eq 124 ]; then
46+
echo "Error: $TEST timed out after $TIMOUT seconds"
47+
echo "************\nOutput:\n$OUTPUT\n************"
48+
FAILURE=1
49+
elif [ $EC -ne 0 ]; then
50+
echo "Error: $TEST failed"
51+
echo "************\nOutput:\n$OUTPUT\n************"
52+
FAILURE=1
53+
else
54+
echo "$TEST passed"
55+
fi
56+
done
57+
58+
exit $FAILURE

utils/build.ps1

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,8 @@ function Fetch-Dependencies {
792792

793793
Extract-ZipFile -ZipFileName "android-ndk-$AndroidNDKVersion-windows.zip" -BinaryCache $BinaryCache -ExtractPath "android-ndk-$AndroidNDKVersion" -CreateExtractPath $false
794794

795+
$NDKDir = "$BinaryCache\android-ndk-r26b"
795796
if ($Test -and -not(Test-Path "$NDKDir\licenses")) {
796-
$NDKDir = "$BinaryCache\android-ndk-r26b"
797797
$CLToolsURL = "https://dl.google.com/android/repository/commandlinetools-win-11076708_latest.zip"
798798
$CLToolsHash = "4d6931209eebb1bfb7c7e8b240a6a3cb3ab24479ea294f3539429574b1eec862"
799799
DownloadAndVerify $CLToolsURL "$BinaryCache\android-cmdline-tools.zip" $CLToolsHash
@@ -1912,11 +1912,18 @@ function Test-Dispatch([Platform]$Platform) {
19121912

19131913
# TODO: On my local machine I have to grant network access once. How to do that in CI?
19141914
$adb = "$NDKDir\platform-tools\adb.exe"
1915-
Invoke-Program $adb "shell" "rm -rf $RemoteBin"
1916-
Invoke-Program $adb "shell" "mkdir $RemoteBin"
1917-
Invoke-Program $adb "push" "$LocalBin/." $RemoteBin
1918-
Invoke-Program $adb "push" "S:/ctest_mock.sh" "/data/local/tmp"
1919-
Invoke-Program $adb "shell" "sh /data/local/tmp/ctest_mock.sh $RemoteBin"
1915+
Write-Host "$adb shell rm -rf $RemoteBin"
1916+
Invoke-Program $adb shell "rm -rf $RemoteBin"
1917+
Write-Host "$adb shell mkdir $RemoteBin"
1918+
Invoke-Program $adb shell "mkdir $RemoteBin"
1919+
Write-Host "$adb push $LocalBin/. $RemoteBin"
1920+
Invoke-Program $adb push "$LocalBin/." $RemoteBin
1921+
Write-Host "$adb push $SourceCache/swift/utils/android/utils/ctest_mock.sh /data/local/tmp"
1922+
Invoke-Program $adb push "$SourceCache/swift/utils/android/utils/ctest_mock.sh" "/data/local/tmp"
1923+
Write-Host "$adb shell chmod +x /data/local/tmp/ctest_mock.sh"
1924+
Invoke-Program $adb shell "chmod +x /data/local/tmp/ctest_mock.sh"
1925+
Write-Host "$adb shell sh /data/local/tmp/ctest_mock.sh $RemoteBin"
1926+
Invoke-Program $adb shell "sh /data/local/tmp/ctest_mock.sh $RemoteBin"
19201927
}
19211928

19221929
function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
@@ -2975,7 +2982,7 @@ if (-not $IsCrossCompiling) {
29752982
if ($Test -contains "dispatch") {
29762983
Build-Dispatch Windows $HostArch -Test
29772984
# TODO: This is a hack. We need different devices for different arches.
2978-
if (AndroidSDKs -contains "x86_64") {
2985+
if ($AndroidSDKs -contains "x86_64") {
29792986
Test-Dispatch Android
29802987
}
29812988
}

0 commit comments

Comments
 (0)