Skip to content
Snippets Groups Projects
Select Git revision
  • nougat-cts-dev
  • master default protected
  • android-7.1.2_r28_klist
  • pie-cts-release
  • pie-vts-release
  • pie-cts-dev
  • oreo-mr1-iot-release
  • sdk-release
  • oreo-m6-s4-release
  • oreo-m4-s12-release
  • pie-release
  • pie-r2-release
  • pie-r2-s1-release
  • oreo-vts-release
  • oreo-cts-release
  • oreo-dev
  • oreo-mr1-dev
  • pie-gsi
  • pie-platform-release
  • pie-dev
  • oreo-cts-dev
  • android-o-mr1-iot-release-1.0.4
  • android-9.0.0_r8
  • android-9.0.0_r7
  • android-9.0.0_r6
  • android-9.0.0_r5
  • android-8.1.0_r46
  • android-8.1.0_r45
  • android-n-iot-release-smart-display-r2
  • android-vts-8.1_r5
  • android-cts-8.1_r8
  • android-cts-8.0_r12
  • android-cts-7.1_r20
  • android-cts-7.0_r24
  • android-o-mr1-iot-release-1.0.3
  • android-cts-9.0_r1
  • android-8.1.0_r43
  • android-8.1.0_r42
  • android-n-iot-release-smart-display
  • android-p-preview-5
  • android-9.0.0_r3
41 results

gatekeeperd.te

Blame
  • run.sh 2.30 KiB
    #!/usr/bin/env bash
    set -e -u -x -o pipefail
    
    #
    # Run QIR, add results to logs.json, prune old log files
    #
    
    # the current start date
    QIR_CURRENT_RUN=$(date --rfc-3339=date)
    # the base directory for logs
    LOGS_BASE_DIR="./web/logs/"
    # the name of the logs directory we are using in this run
    LOGS_DIR_NAME="logs_sat_${QIR_CURRENT_RUN}"
    # the path of the logs directory we are using in this run
    LOGS_DIR="${LOGS_BASE_DIR}/${LOGS_DIR_NAME}/"
    # the path of the latest logs directory symlink
    LATEST_LOGS_DIR="${LOGS_BASE_DIR}/latest"
    # the temporary result json file
    RESULT_JSON_TMP="${LOGS_BASE_DIR}/result-${QIR_CURRENT_RUN}.json"
    # the final destination of the result json file of this run
    RESULT_JSON="${LOGS_DIR}/result.json"
    # the json file that includes a list of log directory names of the last runs
    LOGS_JSON="${LOGS_BASE_DIR}/logs.json"
    # amount of runs to keep
    KEEP_LAST=10
    
    # run test cases T,SAT,SATL with debug output
    # write result json to a file outside the log directory
    # (QIR in master does not support writing it directly to log directory)
    ./.venv/bin/python3 ./run.py \
        -d \
        -t terrestrial,sat,satloss \
        -l "${LOGS_DIR}" \
        -j "${RESULT_JSON_TMP}"
    
    # just to be safe
    mkdir -p "${LOGS_DIR}"
    
    # move the result.json to its target location inside the log directory
    mv "${RESULT_JSON_TMP}" "${RESULT_JSON}"
    
    # replace the log dir in result.json (this replacement makes no sense, but the official runner uses the basename, too)
    jq ".log_dir=\"${LOGS_DIR_NAME}\"" < "${RESULT_JSON}" | sponge "${RESULT_JSON}"
    
    # use last 10 entries and add current log dir
    if [[ -e "${LOGS_JSON}" ]]; then
        jq ".[-${KEEP_LAST}:] + [\"${LOGS_DIR_NAME}\"]" < "${LOGS_JSON}" | sponge "${LOGS_JSON}"
    else
        echo "[\"${LOGS_DIR_NAME}\"]" > "${LOGS_JSON}"
    fi
    
    # update latest symlink
    rm -f "${LATEST_LOGS_DIR}"
    ln -s "${LOGS_DIR_NAME}" "${LATEST_LOGS_DIR}"
    
    # prune log files
    while IFS= read -r -d '' dir
    do
        dir_name=$(basename "${dir}")
        if grep -q -F "\"${dir_name}\"" "${LOGS_JSON}"; then
            # $dir_name is in logs.json
            echo "keeping ${dir_name}"
        else
            # $dir_name is not in logs.json -> delete logs (but keep result.json)
            echo "pruning logs in ${dir_name}"
            find "${dir}" -mindepth 1 -maxdepth 1 -type d -delete
        fi
    done < <(find ./web/logs -maxdepth 1 -mindepth 1 -type d -print0)
    
    
    echo "Done"