Repository Public
1#!/bin/bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : KA Maps Engine8# File : sdk/ios/Scripts/test-store-index.sh9# Module : sdk10# Repository : https://git.spboucher.ai/ka-maps-engine11# Created : 2026-12-0112# Last Modified : 2026-12-0113#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# Régression de l'index persistant du stock de tuiles (défaut relevé le 2026-12-01).41# À chaque tour : (1) l'application télécharge une région, la supprime, puis est tuée par `kill -9` sans42# passer par l'arrière-plan (aucune écriture de l'instantané de l'index) ; (2) relancée, elle retélécharge43# la même région et doit la dessiner réseau coupé puis se mettre au repos (scénario `offline`).44# Avant le correctif du moteur, l'étape 2 échouait une fois sur deux (région « complète » avec des tuiles45# absentes, demandes en boucle).46#47# Usage : test-store-index.sh <udid> <dossier-de-sortie> [tours, défaut 5]48set -uo pipefail49UDID="$1"; OUT="$2"; N="${3:-5}"50HERE="$(cd "$(dirname "$0")" && pwd)"51BUNDLE=com.spboucher.kamaps.example52APP="${KAMAPS_APP:-/tmp/kamaps-dd/Build/Products/Debug-iphonesimulator/KAMapsExample.app}"53mkdir -p "$OUT"54xcrun simctl terminate "$UDID" "$BUNDLE" >/dev/null 2>&1 || true55xcrun simctl install "$UDID" "$APP"56DATA="$(xcrun simctl get_app_container "$UDID" "$BUNDLE" data)"57fail=058for i in $(seq 1 "$N"); do59 # Une réinstallation (faite par run-scenarios.sh) peut changer le chemin du conteneur de données.60 DATA="$(xcrun simctl get_app_container "$UDID" "$BUNDLE" data)"61 rm -f "$DATA/Documents/idx-ready.txt" "$DATA/Documents/done.txt"62 sleep 263 xcrun simctl launch --terminate-running-process "$UDID" "$BUNDLE" -scenario idxkill >/dev/null64 for _ in $(seq 1 600); do [ -f "$DATA/Documents/idx-ready.txt" ] && break; [ -f "$DATA/Documents/done.txt" ] && break; sleep 0.2; done65 if [ ! -f "$DATA/Documents/idx-ready.txt" ]; then66 echo "tour $i : la préparation a échoué ($(cat "$DATA/Documents/done.txt" 2>/dev/null))"; fail=$((fail + 1))67 xcrun simctl terminate "$UDID" "$BUNDLE" >/dev/null 2>&1 || true68 continue69 fi70 PID="$(xcrun simctl spawn "$UDID" launchctl list | awk -v b="$BUNDLE" '$3 ~ b {print $1}' | head -1)"71 kill -9 "$PID"72 sleep 173 ls -la "$DATA/Library/Application Support/KAMaps/tiles/" 2>/dev/null | grep -E "_index" | awk '{print " ", $5, $9}'74 if KAMAPS_APP="$APP" "$HERE/run-scenarios.sh" "$UDID" "$OUT/tour-$i" offline >"$OUT/tour-$i.log" 2>&1; then75 echo "tour $i : OK ($(grep '^OK' "$OUT/tour-$i.log" | head -1))"76 else77 echo "tour $i : ÉCHEC ($(grep -E '^FAIL|^==' "$OUT/tour-$i.log" | tail -1 | cut -c1-300))"; fail=$((fail + 1))78 fi79done80echo "== $((N - fail)) / $N tours réussis"81[ "$fail" = 0 ]82