Commit a7b63bdfd08202e961adddf136bb54cd7c6c7a57

Thomas de Grivel 2024-08-12T11:29:51

move test http 07_event_echo to http/misc/event_echo.kc3

diff --git a/http/misc/event_echo.kc3 b/http/misc/event_echo.kc3
new file mode 100644
index 0000000..5539563
--- /dev/null
+++ b/http/misc/event_echo.kc3
@@ -0,0 +1,40 @@
+timeout = %Time{tv_sec: (Sw) 30}
+event_base = HTTP.Event.base_new()
+socket = Socket.listen("0.0.0.0", "57000")
+echo_client = fn (socket, events, client_ev, client) do
+  puts("echo_client")
+  if List.has?(events, :read) do
+    s = Buf.read_until_str_into_str(client.buf_rw.r, "\n")
+    puts("read: #{s}")
+    if (s == "") do
+      puts("closing")
+      HTTP.Event.del(client_ev)
+      Socket.close(client.sockfd)
+      exit(0)
+    end
+    Buf.write_str(client.buf_rw.w, s)
+  end
+end
+acceptor = fn (server_socket, events, acceptor_ev, void) do
+  if List.has?(events, :read) do
+    puts("acceptor: read")
+    client = Socket.Buf.accept(%Socket{fd: server_socket})
+    puts("acceptor: got client")
+    client_ev = HTTP.Event.new(event_base, client.sockfd, [:read, :persist],
+      echo_client, client)
+    r = HTTP.Event.add(client_ev, timeout)
+    puts("HTTP.Event.add: #{r}")
+  end
+end
+puts("socket.fd: #{socket.fd}")
+puts("event_base: #{event_base}")
+acceptor_ev = HTTP.Event.new(event_base, socket.fd, [:read, :persist],
+                             acceptor, void)
+puts("acceptor_ev: #{acceptor_ev}")
+r = HTTP.Event.add(acceptor_ev, timeout)
+puts("HTTP.Event.add: #{r}")
+r = HTTP.Event.dispatch(event_base)
+if r do
+  e = errno()
+  puts("HTTP.Event.dispatch: #{r}: #{strerror(e)}")
+end
diff --git a/test/http/07_event_echo.kc3 b/test/http/07_event_echo.kc3
deleted file mode 100644
index c807f61..0000000
--- a/test/http/07_event_echo.kc3
+++ /dev/null
@@ -1,40 +0,0 @@
-timeout = %Time{tv_sec: (Sw) 30}
-event_base = HTTP.Event.base_new()
-socket = Socket.listen("0.0.0.0", "57000")
-echo_client = fn (socket, events, client_ev, client) do
-  puts("echo_client")
-  if List.has?(events, :read) do
-    s = Buf.read_until_str_into_str(client.buf_rw.r, "\n")
-    puts("read: #{s}")
-    if (s == "") do
-      puts("closing")
-      HTTP.Event.del(client_ev)
-      Socket.close(client.sockfd)
-      exit(0)
-    end
-    Buf.write_str(client.buf_rw.w, s)
-  end
-end
-acceptor = fn (server_socket, events, acceptor_ev, void) do
-  if List.has?(events, :read) do
-    puts("acceptor: read")
-    client = Socket.Buf.accept(%Socket{fd: server_socket})
-    puts("acceptor: got client")
-    client_ev = HTTP.Event.new(event_base, client.sockfd, [:read, :persist],
-      echo_client, client)
-    r = HTTP.Event.add(client_ev, timeout)
-    puts("HTTP.Event.add: #{r}")
-  end
-end
-puts("socket.fd: #{socket.fd}")
-puts("event_base: #{event_base}")
-acceptor_ev = HTTP.Event.new(event_base, socket.fd, [:read, :persist],
-                             acceptor, void)
-puts("acceptor_ev: #{acceptor_ev}")
-r = HTTP.Event.add(acceptor_ev, timeout)
-puts("HTTP.Event.add: #{r}")
-# r = HTTP.Event.dispatch(event_base)
-# if r do
-#  e = errno()
-#  puts("HTTP.Event.dispatch: #{r}: #{strerror(e)}")
-# end
diff --git a/test/http/07_event_echo.out.expected b/test/http/07_event_echo.out.expected
deleted file mode 100644
index e69de29..0000000
--- a/test/http/07_event_echo.out.expected
+++ /dev/null
diff --git a/test/http/07_event_echo.ret.expected b/test/http/07_event_echo.ret.expected
deleted file mode 100644
index 573541a..0000000
--- a/test/http/07_event_echo.ret.expected
+++ /dev/null
@@ -1 +0,0 @@
-0