Skip to content

Commit 778edf8

Browse files
committed
add simple test runner
1 parent d3f660b commit 778edf8

File tree

8 files changed

+48
-5
lines changed

8 files changed

+48
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
c-src/*.o
22
c-src/*.so
33
/main
4+
/coverage/

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
BORINGSSL_COMMIT=251b5169fd44345f455438312ec4e18ae07fd58c
2+
LISP ?= sbcl
3+
sbcl_TEST_OPTS=--noinform --disable-debugger --quit --load ./run-tests.lisp
24

35
.PHONY: lsquic build test
46

@@ -25,3 +27,6 @@ src/ffi-dns.lisp: dns.i Makefile c-src/libdns.so
2527

2628
src/ffi-udp.lisp: udp.i Makefile c-src/libudp.so
2729
swig -cffi -module ffi -outdir src/udp -I./c-src udp.i
30+
31+
test:
32+
@$(LISP) $($(LISP)_TEST_OPTS)

run-tests.lisp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(in-package #:cl-user)
2+
3+
(defmacro with-silence (&body body)
4+
`(let ((*standard-output* (make-broadcast-stream))
5+
(*error-output* (make-broadcast-stream))
6+
(*trace-output* (make-broadcast-stream)))
7+
,@body))
8+
9+
(with-silence
10+
(ql:quickload :fiveam))
11+
12+
(asdf:test-system :http3/test)

src/http3/http3.asd

+11
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,14 @@
1313
:static-vectors
1414
:weird-pointers
1515
:usocket))
16+
17+
(defsystem :http3/test
18+
:version "0.0.1"
19+
:description "HTTP3 Client tests"
20+
:licence "WTFPL"
21+
:components ((:module "test"
22+
:components
23+
((:file "tests"))))
24+
:depends-on (:http3 :fiveam)
25+
:perform (test-op :after (o s)
26+
(fiveam:run! :http3)))

src/http3/test/tests.lisp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(defpackage #:http3/test
2+
(:use :cl :http3 :fiveam))
3+
4+
(in-package #:http3/test)
5+
(def-suite :http3)
6+
(in-suite :http3)
7+
8+
(test can-create-request
9+
(let ((request (make-instance 'lsquic:request :authority "google.com")))
10+
(is (lsquic:lsxpack-headers request))))

src/lsquic/lsquic.lisp

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
(let ((client (weird-pointers:restore peer-ctx)))
6969
(let ((count (udp:send-packets-out dest-sa iov iovlen (sb-bsd-sockets:socket-file-descriptor (socket (socket client))))))
7070
(when (< count 0)
71-
(error)))
71+
(error "short write")))
7272
(incf n)
7373
(cffi:incf-pointer specs)))))
7474
(if (> n 0)

src/lsquic/package.lisp

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
(:export
44
#:engine
55

6+
#:request
7+
#:header
8+
#:lsxpack-headers
9+
610
#:set-context
711
#:process-conns
812
#:packets-in

src/lsquic/request.lisp

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
(value :initarg :value :accessor value)))
77

88
(defclass request ()
9-
((path :initarg :path :accessor path)
10-
(scheme :initarg :scheme :accessor scheme)
11-
(headers :initarg :headers :accessor headers)
9+
((path :initarg :path :initform "/" :accessor path)
10+
(scheme :initarg :scheme :initform "https" :accessor scheme)
11+
(headers :initarg :headers :initform nil :accessor headers)
1212
(authority :initarg :authority :accessor authority)
13-
(verb :initarg :verb :accessor verb)
13+
(verb :initarg :verb :initform "GET" :accessor verb)
1414
(body :initarg :body :accessor body)))
1515

1616
(defmethod make-lsxpack-header ((header header))

0 commit comments

Comments
 (0)