from __future__ import annotations

import argparse
import json
import os
import signal
import time


def emit(event: str, test_id: str) -> None:
    print("TEST_HEARTBEAT " + json.dumps({"event": event, "test_id": test_id, "pid": os.getpid(), "epoch": time.time()}), flush=True)


parser = argparse.ArgumentParser()
parser.add_argument("mode", choices=("timeout", "stall", "signal"))
args = parser.parse_args()
emit("START", "negative." + args.mode)
while True:
    if args.mode in {"timeout", "signal"}:
        emit("PULSE", "negative." + args.mode)
    time.sleep(0.2)
