misc.lisp - clic - Clic is an command line interactive client for gopher written in Common LISP (HTM) git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/clic/ (DIR) Log (DIR) Files (DIR) Refs (DIR) Tags (DIR) README (DIR) LICENSE --- misc.lisp (4446B) --- 1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- 2 ;;; 3 ;;; misc.lisp --- Miscellaneous tests. 4 ;;; 5 ;;; Copyright (C) 2006, Luis Oliveira <loliveira@common-lisp.net> 6 ;;; 7 ;;; Permission is hereby granted, free of charge, to any person 8 ;;; obtaining a copy of this software and associated documentation 9 ;;; files (the "Software"), to deal in the Software without 10 ;;; restriction, including without limitation the rights to use, copy, 11 ;;; modify, merge, publish, distribute, sublicense, and/or sell copies 12 ;;; of the Software, and to permit persons to whom the Software is 13 ;;; furnished to do so, subject to the following conditions: 14 ;;; 15 ;;; The above copyright notice and this permission notice shall be 16 ;;; included in all copies or substantial portions of the Software. 17 ;;; 18 ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 ;;; DEALINGS IN THE SOFTWARE. 26 ;;; 27 28 (in-package #:cffi-tests) 29 30 ;;;# foreign-symbol-pointer tests 31 32 ;;; This might be useful for some libraries that compare function 33 ;;; pointers. http://thread.gmane.org/gmane.lisp.cffi.devel/694 34 (defcfun "compare_against_abs" :boolean (p :pointer)) 35 36 (deftest foreign-symbol-pointer.1 37 (compare-against-abs (foreign-symbol-pointer "abs")) 38 t) 39 40 (defcfun "compare_against_xpto_fun" :boolean (p :pointer)) 41 42 (deftest foreign-symbol-pointer.2 43 (compare-against-xpto-fun (foreign-symbol-pointer "xpto_fun")) 44 t) 45 46 ;;;# Library tests 47 ;;; 48 ;;; Need to figure out a way to test this. CLISP, for instance, will 49 ;;; automatically reopen the foreign-library when we call a foreign 50 ;;; function so we can't test CLOSE-FOREIGN-LIBRARY this way. 51 ;;; 52 ;;; IIRC, GCC has some extensions to have code run when a library is 53 ;;; loaded and stuff like that. That could work. 54 55 #|| 56 #-(and ecl (not dffi)) 57 (deftest library.close.2 58 (unwind-protect 59 (progn 60 (close-foreign-library 'libtest) 61 (ignore-errors (my-sqrtf 16.0))) 62 (load-test-libraries)) 63 nil) 64 65 #-(or (and ecl (not dffi)) 66 cffi-sys::flat-namespace 67 cffi-sys::no-foreign-funcall) 68 (deftest library.close.2 69 (unwind-protect 70 (values 71 (foreign-funcall ("ns_function" :library libtest) :boolean) 72 (close-foreign-library 'libtest) 73 (foreign-funcall "ns_function" :boolean) 74 (close-foreign-library 'libtest2) 75 (close-foreign-library 'libtest2) 76 (ignore-errors (foreign-funcall "ns_function" :boolean))) 77 (load-test-libraries)) 78 t t nil t nil nil) 79 ||# 80 81 (deftest library.error.1 82 (handler-case (load-foreign-library "libdoesnotexistimsure") 83 (load-foreign-library-error () 'error)) 84 error) 85 86 (define-foreign-library pseudo-library 87 (t pseudo-library-spec)) 88 89 ;;; RT: T clause was being handled as :T by FEATUREP. 90 ;;; 91 ;;; We might want to export (and clean up) the API used in this test 92 ;;; when the need arises. 93 (deftest library.t-clause 94 (eq (cffi::foreign-library-spec 95 (cffi::get-foreign-library 'pseudo-library)) 96 'pseudo-library-spec) 97 t) 98 99 (define-foreign-library library-with-pathname 100 (t #p"libdoesnotexistimsure")) 101 102 ;;; RT: we were mishandling pathnames within libraries. (lp#1720626) 103 (deftest library.error.2 104 (handler-case (load-foreign-library 'library-with-pathname) 105 (load-foreign-library-error () 'error)) 106 error) 107 108 (deftest library.error.3 109 (handler-case (load-foreign-library #p"libdoesnotexistimsure") 110 (load-foreign-library-error () 'error)) 111 error) 112 113 ;;;# Shareable Byte Vector Tests 114 115 #+ecl 116 (mapc (lambda (x) (pushnew x rt::*expected-failures*)) 117 '(shareable-vector.1 shareable-vector.2)) 118 119 (deftest shareable-vector.1 120 (let ((vector (cffi-sys::make-shareable-byte-vector 5))) 121 (cffi::with-pointer-to-vector-data (pointer vector) 122 (strcpy pointer "xpto")) 123 vector) 124 #(120 112 116 111 0)) 125 126 (deftest shareable-vector.2 127 (block nil 128 (let ((vector (cffi-sys::make-shareable-byte-vector 5))) 129 (cffi::with-pointer-to-vector-data (pointer vector) 130 (strcpy pointer "xpto") 131 (return vector)))) 132 #(120 112 116 111 0))