Mercurial
view seobeo/tests/seobeo_server_stop_test.c @ 266:efaf4c63cc94
fix clean production bundle staging
Recreate deployment staging before copying the Bazel bundle and verify required inference runtime paths before promoting it.
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Fri, 07 Aug 2026 12:52:30 -0700 |
| parents | 1f9877b637e9 |
| children |
line wrap: on
line source
#include "seobeo/seobeo.h" #include <assert.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <unistd.h> typedef struct { char port[16]; int result; } Server_Context; static int Reserve_Port(void) { int socket_fd = socket(AF_INET, SOCK_STREAM, 0); assert(socket_fd >= 0); struct sockaddr_in address = { .sin_family = AF_INET, .sin_addr.s_addr = htonl(INADDR_LOOPBACK), .sin_port = 0, }; assert(bind( socket_fd, (struct sockaddr *)&address, sizeof(address)) == 0); socklen_t length = sizeof(address); assert(getsockname( socket_fd, (struct sockaddr *)&address, &length) == 0); int port = ntohs(address.sin_port); close(socket_fd); return port; } static void *Run_Server(void *p_context) { Server_Context *p_server = p_context; p_server->result = Seobeo_Web_Server_Start_On( "127.0.0.1", "seobeo/tests", p_server->port, SEOBEO_MODE_EDGE, 1); return NULL; } int main(void) { Server_Context context = {0}; snprintf(context.port, sizeof(context.port), "%d", Reserve_Port()); pthread_t thread; assert(pthread_create(&thread, NULL, Run_Server, &context) == 0); usleep(200000); Seobeo_Web_Server_Stop(); assert(pthread_join(thread, NULL) == 0); assert(context.result == 0); printf("Seobeo server stop test passed\n"); return 0; }