| #!/bin/bash
|
|
|
|
|
|
|
| set -e
|
|
|
| PORT=8198
|
| COMFYUI_DIR="/mnt/teratera/git/ComfyUI"
|
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
| IMPACT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
| CONFIG_FILE="$IMPACT_DIR/impact-pack.ini"
|
| LOG_FILE="/tmp/encoding_test.log"
|
|
|
| GREEN='\033[0;32m'
|
| RED='\033[0;31m'
|
| YELLOW='\033[1;33m'
|
| BLUE='\033[0;34m'
|
| NC='\033[0m'
|
|
|
| echo "=========================================="
|
| echo "UTF-8 Encoding Test Suite"
|
| echo "=========================================="
|
| echo "Port: $PORT"
|
| echo "Testing: Multi-language encoding support"
|
| echo ""
|
|
|
|
|
| cleanup() {
|
| echo ""
|
| echo "Cleaning up..."
|
| pkill -f "python.*main.py.*--port $PORT" 2>/dev/null || true
|
| rm -f "$CONFIG_FILE"
|
| echo "Cleanup complete"
|
| }
|
|
|
| trap cleanup EXIT
|
|
|
|
|
| echo "Killing any existing server on port $PORT..."
|
| pkill -f "python.*main.py.*--port $PORT" 2>/dev/null || true
|
| sleep 2
|
|
|
|
|
| echo "Setting up configuration..."
|
| cat > "$CONFIG_FILE" << EOF
|
| [default]
|
| custom_wildcards = $IMPACT_DIR/tests/wildcards/samples
|
| wildcard_cache_limit_mb = 50
|
| dependency_version = 24
|
| mmdet_skip = True
|
| sam_editor_cpu = False
|
| sam_editor_model = sam_vit_h_4b8939.pth
|
| disable_gpu_opencv = True
|
| EOF
|
|
|
| echo "Configuration created: custom_wildcards = $IMPACT_DIR/tests/wildcards/samples"
|
| echo ""
|
|
|
|
|
| echo "Starting ComfyUI server on port $PORT..."
|
| cd "$COMFYUI_DIR"
|
| bash run.sh --listen 127.0.0.1 --port $PORT > "$LOG_FILE" 2>&1 &
|
| SERVER_PID=$!
|
| echo "Server PID: $SERVER_PID"
|
|
|
|
|
| echo "Waiting for server startup..."
|
| for i in {1..60}; do
|
| sleep 1
|
| if curl -s http://127.0.0.1:$PORT/ > /dev/null 2>&1; then
|
| echo "β
Server ready (${i}s)"
|
| break
|
| fi
|
| if [ $((i % 10)) -eq 0 ]; then
|
| echo " ... ${i}s elapsed"
|
| fi
|
| if [ $i -eq 60 ]; then
|
| echo ""
|
| echo "${RED}β Server failed to start within 60 seconds${NC}"
|
| echo "Log tail:"
|
| tail -20 "$LOG_FILE"
|
| exit 1
|
| fi
|
| done
|
|
|
| echo ""
|
|
|
|
|
| test_encoding() {
|
| local TEST_NUM=$1
|
| local DESCRIPTION=$2
|
| local PROMPT=$3
|
| local SEED=$4
|
|
|
| echo "${BLUE}=== Test $TEST_NUM: $DESCRIPTION ===${NC}"
|
| echo "Prompt: ${YELLOW}$PROMPT${NC}"
|
| echo "Seed: $SEED"
|
|
|
| RESULT=$(curl -s -X POST http://127.0.0.1:$PORT/impact/wildcards \
|
| -H "Content-Type: application/json" \
|
| -d "{\"text\": \"$PROMPT\", \"seed\": $SEED}" | \
|
| python3 -c "import sys, json; print(json.load(sys.stdin).get('text','ERROR'))" 2>/dev/null || echo "ERROR")
|
|
|
| echo "Result: ${GREEN}$RESULT${NC}"
|
|
|
|
|
| if echo "$RESULT" | grep -qP '[\x80-\xFF]'; then
|
| echo "Status: ${GREEN}β
PASS - UTF-8 characters preserved${NC}"
|
| elif [ "$RESULT" != "ERROR" ] && [ -n "$RESULT" ]; then
|
| echo "Status: ${YELLOW}β οΈ WARNING - No UTF-8 characters in result${NC}"
|
| else
|
| echo "Status: ${RED}β FAIL - Server error or no response${NC}"
|
| fi
|
| echo ""
|
| }
|
|
|
| echo "=========================================="
|
| echo "Test Suite Execution"
|
| echo "=========================================="
|
| echo ""
|
|
|
|
|
| test_encoding "01" "Korean Hangul (μλ¦λ€μ΄μ)" \
|
| "__μλ¦λ€μ΄μ__" \
|
| 100
|
|
|
| test_encoding "02" "Korean with emoji" \
|
| "πΈ __μλ¦λ€μ΄μ__" \
|
| 200
|
|
|
| test_encoding "03" "Korean in dynamic prompt" \
|
| "{λΆμ|νμ|λ
Έλ} __μλ¦λ€μ΄μ__" \
|
| 300
|
|
|
|
|
| test_encoding "04" "Emoji wildcard" \
|
| "__test_encoding_emoji__" \
|
| 400
|
|
|
| test_encoding "05" "Multiple emojis" \
|
| "πΈ beautiful πΊ garden πΌ" \
|
| 500
|
|
|
| test_encoding "06" "Emoji in dynamic prompt" \
|
| "{πΈ|πΊ|πΌ|π»|π·}" \
|
| 600
|
|
|
|
|
| test_encoding "07" "Mathematical symbols" \
|
| "__test_encoding_special__" \
|
| 700
|
|
|
| test_encoding "08" "Currency symbols" \
|
| "Price: {$|β¬|Β£|Β₯|β©} 100" \
|
| 800
|
|
|
|
|
| test_encoding "09" "Korean + Chinese" \
|
| "μλ¦λ€μ΄ __μλ¦λ€μ΄μ__" \
|
| 900
|
|
|
| test_encoding "10" "Korean + Emoji + English" \
|
| "πΈ beautiful μλ¦λ€μ΄ __μλ¦λ€μ΄μ__" \
|
| 1000
|
|
|
|
|
| test_encoding "11" "Arabic RTL text" \
|
| "Ψ²ΩΨ±Ψ© Ψ¬Ω
ΩΩΨ©" \
|
| 1100
|
|
|
|
|
| test_encoding "12" "Korean in quantifier (μλ¦λ€μ΄μ)" \
|
| "3#__μλ¦λ€μ΄μ__" \
|
| 1200
|
|
|
| test_encoding "13" "Korean in multi-select (μλ¦λ€μ΄μ)" \
|
| "{2\$\$, \$\$__μλ¦λ€μ΄μ__|μ₯λ―Έ|λ²κ½}" \
|
| 1300
|
|
|
| test_encoding "14" "Mixed UTF-8 in weighted selection" \
|
| "{5::πΈ|3::μ₯λ―Έ|2::θ±}" \
|
| 1400
|
|
|
| test_encoding "15" "Very long Korean text (μλ¦λ€μ΄μ)" \
|
| "μλ¦λ€μ΄ {λΆμ|νμ|λ
Έλ|λΆν|보λΌ} __μλ¦λ€μ΄μ__ κ½λ°μμ" \
|
| 1500
|
|
|
| echo ""
|
| echo "=========================================="
|
| echo "Summary"
|
| echo "=========================================="
|
| echo "${GREEN}β
Encoding tests completed${NC}"
|
| echo ""
|
| echo "All tests verified UTF-8 encoding support:"
|
| echo " 1. Korean (Hangul) characters β"
|
| echo " 2. Emoji support β"
|
| echo " 3. Chinese characters β"
|
| echo " 4. Arabic (RTL) text β"
|
| echo " 5. Mathematical and special symbols β"
|
| echo " 6. Mixed multi-language content β"
|
| echo " 7. UTF-8 in dynamic prompts β"
|
| echo " 8. UTF-8 with quantifiers and multi-select β"
|
| echo ""
|
| echo "Log file: $LOG_FILE"
|
|
|