Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/8.0.1xx-xcode15.1] [devops] Attempt to fix simulator runtimes disappearing. #20573

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions tools/devops/automation/scripts/bash/clean-simulator-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ IFS=$'\n\t'
xcrun simctl runtime list -j > simruntime.json
cat simruntime.json

grep -e '"identifier" : ' -e '"runtimeIdentifier" : ' simruntime.json | tr '\n' ' ' | sed -e 's/,//g' -e 's/"//g' -e 's/runtimeIdentifier : //g' -e $'s/identifier : /@/g' | tr '@' '\n' | awk NF | sed 's/^[[:blank:]]*//' > simruntime-lines.txt
cat simruntime-lines.txt
if grep -e '"identifier" : ' -e '"runtimeIdentifier" : ' simruntime.json | tr '\n' ' ' | sed -e 's/,//g' -e 's/"//g' -e 's/runtimeIdentifier : //g' -e $'s/identifier : /@/g' | tr '@' '\n' | awk NF | sed 's/^[[:blank:]]*//' > simruntime-lines.txt; then
cat simruntime-lines.txt
fi

sed -e 's/.*com.apple/com.apple/g' simruntime-lines.txt > simruntime-runtimes.txt
cat simruntime-runtimes.txt
if sed -e 's/.*com.apple/com.apple/g' simruntime-lines.txt > simruntime-runtimes.txt; then
cat simruntime-runtimes.txt
fi

sort simruntime-runtimes.txt | uniq -c | sort -n | sed 's/^[[:blank:]]*//' > simruntime-runtimes-by-count.txt
cat simruntime-runtimes-by-count.txt
if sort simruntime-runtimes.txt | uniq -c | sort -n | sed 's/^[[:blank:]]*//' > simruntime-runtimes-by-count.txt; then
cat simruntime-runtimes-by-count.txt
fi

grep -v '^1 ' simruntime-runtimes-by-count.txt | sed 's/^[0-9 ]*//' > simruntime-duplicated-runtimes.txt
cat simruntime-duplicated-runtimes.txt
if grep -v '^1 ' simruntime-runtimes-by-count.txt | sed 's/^[0-9 ]*//' > simruntime-duplicated-runtimes.txt; then
cat simruntime-duplicated-runtimes.txt
fi

while IFS= read -r simruntime
do
Expand All @@ -32,6 +36,20 @@ do
echo " deleted runtime $id"
fi
done
done < simruntime-duplicated-runtimes.txt

xcrun simctl runtime list -v
done < simruntime-duplicated-runtimes.txt || true

xcrun simctl runtime list -v || true
xcrun simctl runtime match list -v || true

# try to detach all simulator runtimes
for dir in /Library/Developer/CoreSimulator/Volumes/*; do
sudo diskutil eject "$dir" || true
done
# kill the com.apple.CoreSimulator.simdiskimaged service
sudo launchctl kill 9 system/com.apple.CoreSimulator.simdiskimaged || true
# kill the com.apple.CoreSimulator.CoreSimulatorService service
# it seems this service starts the simdiskimaged service if it's not running.
sudo pkill -9 com.apple.CoreSimulator.CoreSimulatorService || true
# the disk image service should now restart when needed, and reload the re-attach all the simulator runtimes.

xcrun simctl runtime match list -v
Loading