view mrjunejune/test/test.h @ 279:b3b547563ec7

Add Google connector service and agent wiki Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code. Co-authored-by: Copilot <[email protected]> Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 22:22:36 -0700
parents f3084bca7317
children
line wrap: on
line source

#include "seobeo/seobeo.h"
#include "seobeo/snapshot_creator.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>

#define TEST_PORT "6969"
#define TEST_HOST "127.0.0.1"
#define TEST_URL "http://127.0.0.1:6969"
#define MAX_RESPONSE_SIZE (1024 * 1024)
#ifndef SNAPSHOT_DIR
  #define SNAPSHOT_DIR "/home/june/zenbu/mrjunejune/test/snapshots"
#endif

pid_t start_test_server(const char *server_binary)
{
  pid_t server_pid = fork();

  if (server_pid < 0)
  {
    perror("fork");
    return -1;
  }

  if (server_pid == 0)
  {
    printf("Starting server on port %s...\n", TEST_PORT);
    execl(server_binary, server_binary, NULL);
    perror("execl failed");
    exit(1);
  }

  printf("Server started (PID: %d)\n", server_pid);

  usleep(100000);
  int status;
  pid_t result = waitpid(server_pid, &status, WNOHANG);
  if (result != 0)
  {
    if (WIFEXITED(status))
    {
      fprintf(stderr, "Server exited immediately with code: %d\n", WEXITSTATUS(status));
    }
    else if (WIFSIGNALED(status))
    {
      fprintf(stderr, "Server was killed by signal: %d\n", WTERMSIG(status));
    }
    return -1;
  }

  sleep(2);
  printf("Server ready\n\n");

  return server_pid;
}

void stop_test_server(pid_t server_pid)
{
  if (server_pid > 0)
  {
    printf("\nStopping server (PID: %d)...\n", server_pid);
    kill(server_pid, SIGTERM);
    waitpid(server_pid, NULL, 0);
    printf("Server stopped\n");
  }
}