<commit_before>#!/bin/sh

. $testdir/utils.sh

VIDIU_ADDRESS="vidiu-01188.local"
STREAM_NAME=steam

case $1 in
    start)
        sed "s,@SCRATCH_DIR@,$scratch_dir,g" \
            $testdir/hardware/crtmpserver.lua.in >"crtmpserver.lua"
        crtmpserver "crtmpserver.lua" &
        # Wait for rtmp server to start up:
        while ! netstat -ln --tcp | grep -q ':1935'; do
            sleep 0.1
        done
        RTMPD_PID=$!
        echo "$RTMPD_PID" >"$scratch_dir/crtmpserver.pid"
        set_config global.source_pipeline \
            "rtmpsrc location=rtmp://localhost/live/$STREAM_NAME\ live=1 ! decodebin"
        ;;
    stop)
        kill $(<"$scratch_dir/crtmpserver.pid")
        ;;
esac<commit_msg>test_teradek_vidiu: Avoid infinite loop if crtmpserver fails to start<commit_after>#!/bin/sh

. $testdir/utils.sh

VIDIU_ADDRESS="vidiu-01188.local"
STREAM_NAME=steam

case $1 in
    start)
        sed "s,@SCRATCH_DIR@,$scratch_dir,g" \
            $testdir/hardware/crtmpserver.lua.in >"crtmpserver.lua"

        crtmpserver "crtmpserver.lua" &
        RTMPD_PID=$!

        # Wait for rtmp server to start up:
        started=false
        for i in $(seq 100); do
            netstat -ln --tcp | grep -q ':1935' && { started=true; break; }
            sleep 0.1
        done
        $started || fail "Failed to start crtmpserver"

        echo "$RTMPD_PID" >"$scratch_dir/crtmpserver.pid"
        set_config global.source_pipeline \
            "rtmpsrc location=rtmp://localhost/live/$STREAM_NAME\ live=1 ! decodebin"
        ;;
    stop)
        kill $(<"$scratch_dir/crtmpserver.pid")
        ;;
esac
{'fraction_non_alphanumeric': 0.12577065351418001, 'fraction_numerical': 0.017879161528976572, 'mean_word_length': 2.2721774193548385, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '645556', 'n_tokens_mistral': 611, 'n_tokens_neox': 598, 'n_words': 112}