From 1ae11b02ceb630b0a31f9d8d866220ad06dd587f Mon Sep 17 00:00:00 2001 From: mahmamdouh Date: Sun, 28 Dec 2025 03:46:11 +0100 Subject: [PATCH] update DB table --- scenario_execution.py | 5 ++++- test_execution.sh | 3 ++- testarena_app/worker.py | 7 +++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scenario_execution.py b/scenario_execution.py index 844afe1..24ef7e9 100644 --- a/scenario_execution.py +++ b/scenario_execution.py @@ -77,13 +77,16 @@ def run_test_suite(tasks): print(f"--- Starting Task: {task['id']} ---") # Use Popen to stream output in real-time + env = os.environ.copy() + env["PYTHONUNBUFFERED"] = "1" process = subprocess.Popen( [shell_script, task['id'], task['cmd'], task['path'], REPO_PATH], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1, - universal_newlines=True + universal_newlines=True, + env=env ) full_output = "" diff --git a/test_execution.sh b/test_execution.sh index a3710bc..d8f1a73 100644 --- a/test_execution.sh +++ b/test_execution.sh @@ -38,8 +38,9 @@ EOF # 1. CD into the repo path # 2. Execute command and capture output # 3. PIPESTATUS[0] captures the exit code of the eval "$CMD" +export PYTHONUNBUFFERED=1 echo "--- Execution Start ---" | tee -a >(sed 's/$/
/' >> "$LOG_FILE") -cd "$REPO_PATH" && eval "$CMD" 2>&1 | tee -a >(sed 's/$/
/' >> "$LOG_FILE") +cd "$REPO_PATH" && stdbuf -oL -eL eval "$CMD" 2>&1 | tee -a >(sed 's/$/
/' >> "$LOG_FILE") EXIT_CODE=${PIPESTATUS[0]} echo "--- Execution End (Exit Code: $EXIT_CODE) ---" | tee -a >(sed 's/$/
/' >> "$LOG_FILE") diff --git a/testarena_app/worker.py b/testarena_app/worker.py index db71f5c..f2e6996 100644 --- a/testarena_app/worker.py +++ b/testarena_app/worker.py @@ -139,9 +139,12 @@ def run_worker(): checkout_cmd = f"./TPF/gitea_repo_controller.sh checkout {queue.source}" run_command_with_logging(checkout_cmd, queue_log) + # Clean up any orphaned QEMU processes + run_command_with_logging("pkill -f qemu-system-xtensa || true", queue_log) + # 1-5 Build software and run QEMU # We stop when we see the multicore app start message - build_cmd = f"/bin/bash -c 'source $HOME/esp/esp-idf/export.sh && cd TPF/Sensor_hub_repo && idf.py build && idf.py qemu'" + build_cmd = f"/bin/bash -c 'export PYTHONUNBUFFERED=1 && source $HOME/esp/esp-idf/export.sh && cd TPF/Sensor_hub_repo && idf.py build && idf.py qemu'" run_command_with_logging(build_cmd, queue_log, stop_string="cpu_start: Multicore app") # 9- Loop for each task @@ -162,7 +165,7 @@ def run_worker(): # It must be executed from TPF/Sensor_hub_repo with IDF sourced script_path = os.path.abspath("./TPF/scenario_execution.py") repo_dir = os.path.abspath("./TPF/Sensor_hub_repo") - cmd = f"/bin/bash -c 'source $HOME/esp/esp-idf/export.sh && python3 {script_path} {queue.id} {task.scenario_path} {task.id}'" + cmd = f"/bin/bash -c 'export PYTHONUNBUFFERED=1 && source $HOME/esp/esp-idf/export.sh && python3 {script_path} {queue.id} {task.scenario_path} {task.id}'" task_dir = os.path.join(queue_dir, task.id) os.makedirs(task_dir, exist_ok=True)