blob: fa049e7516cfbcaf689638fce991f2f5e52caab9 [file] [log] [blame]
Max-Gerd Retzlaff04057ac2022-08-23 17:38:34 +02001(in-package #:cl-user)
2
3;;;; Licensed under the Apache License, Version 2.0 (the "License");
4;;;; you may not use this file except in compliance with the License.
5;;;; You may obtain a copy of the License at
6;;;;
7;;;; http://www.apache.org/licenses/LICENSE-2.0
8;;;;
9;;;; Unless required by applicable law or agreed to in writing, software
10;;;; distributed under the License is distributed on an "AS IS" BASIS,
11;;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12;;;; See the License for the specific language governing permissions and
13;;;; limitations under the License.
14
15#+(or) (when (not (boundp 'sb-impl::default-external-format)
16 (setf sb-impl::default-external-format :UTF-8)))
17
18(require "asdf")
19(load (merge-pathnames "../../lib/cl/load-locally.lisp" *load-truename*))
Max-Gerd Retzlaff75bdba52022-08-23 19:03:48 +020020(require "sb-grovel") ;; necessary for :net.didierverna.clon.termio
21(asdf:load-asd (first (directory (merge-pathnames "../../lib/cl/externals/software/clon-*/termio/net.didierverna.clon.termio.asd"
22 *load-truename*))))
Max-Gerd Retzlaff04057ac2022-08-23 17:38:34 +020023(asdf:load-system :net.didierverna.clon)
24(asdf:load-system :fiasco)
25(asdf:load-asd (merge-pathnames "gen-cl/ThriftTest/thrift-gen-ThriftTest.asd" *load-truename*))
26(asdf:load-system :thrift-gen-thrifttest)
27
28(net.didierverna.clon:nickname-package)
29
30(defpackage #:thrift-cross
31 (:use #:common-lisp #:fiasco)
32 (:export #:cross-test))
33
34(in-package #:thrift-cross)
35
36(defparameter *prot* nil)
37
38(load (merge-pathnames "tests.lisp" *load-truename*) :external-format :UTF-8)
39
40(clon:defsynopsis ()
41 (text :contents "The Common Lisp client for Thrift's cross-language test suite.")
42 (group (:header "Allowed options:")
43 (flag :short-name "h" :long-name "help"
44 :description "Print this help and exit.")
45 (stropt :long-name "host"
46 :description "The host to connect to."
47 :default-value "localhost"
48 :argument-name "ARG")
49 (stropt :long-name "port"
50 :description "Number of the port to listen for connections on."
51 :default-value "9090"
52 :argument-name "ARG"
53 :argument-type :optional)
54 (stropt :long-name "transport"
55 :description "Transport: transport to use (\"buffered\", \"framed\")"
56 :default-value "buffered"
57 :argument-name "ARG")
58 (stropt :long-name "protocol"
59 :description "Protocol: protocol to use (\"binary\", \"multi\")"
60 :default-value "binary"
61 :argument-name "ARG")))
62
63(defun main ()
64 "Entry point for our standalone application."
65 (clon:make-context)
66 (when (clon:getopt :short-name "h")
67 (clon:help)
68 (clon:exit))
69 (let ((port "9090")
70 (host "localhost")
71 (framed nil)
72 (multiplexed nil))
73 (clon:do-cmdline-options (option name value source)
74 (print (list option name value source))
75 (if (string= name "host")
76 (setf host value))
77 (if (string= name "port")
78 (setf port value))
79 (if (string= name "transport")
80 (cond ((string= value "buffered") (setf framed nil))
81 ((string= value "framed") (setf framed t))
82 (t (error "Unsupported transport."))))
83 (if (string= name "protocol")
84 (cond ((string= value "binary") (setf multiplexed nil))
85 ((string= value "multi") (setf multiplexed t))
86 (t (error "Unsupported protocol.")))))
87 (terpri)
88 (setf *prot* (thrift.implementation::client (puri:parse-uri
89 (concatenate 'string "thrift://" host ":" port))
90 :framed framed
91 :multiplexed multiplexed))
92 (let ((result (cross-test :multiplexed multiplexed)))
93 (thrift.implementation::close *prot*)
94 (clon:exit result))))
95
96(clon:dump "TestClient" main)