File: run-on-many-lisps-and-openssls.lisp

package info (click to toggle)
acl2 8.6%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 1,111,420 kB
  • sloc: lisp: 17,818,294; java: 125,359; python: 28,122; javascript: 23,458; cpp: 18,851; ansic: 11,569; perl: 7,678; xml: 5,591; sh: 3,976; makefile: 3,833; ruby: 2,633; yacc: 1,126; ml: 763; awk: 295; csh: 233; lex: 197; php: 178; tcl: 49; asm: 23; haskell: 17
file content (106 lines) | stat: -rw-r--r-- 5,177 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
(ql:quickload :test-grid-agent)
(ql:quickload :test-grid-utils)
(ql:quickload :cl-fad)
(ql:quickload :alexandria)
(ql:quickload :log4cl)

(let ((*default-pathname-defaults*
        (or *load-truename*
            #P"/home/anton/my/prj/cl+ssl/cl-plus-ssl/test/run-on-many-lisps-and-openssls/")))
  (load "openssl-releases.lisp"))

(defpackage #:run-on-many-lisps-and-openssls
  (:use :common-lisp)
  (:export #:run
           #:clean-fasls))

(in-package :run-on-many-lisps-and-openssls)

(defun fasl-root (test-run-dir)
  (merge-pathnames "fasl/" test-run-dir))

(defun sanitize-as-path (str)
  ;; Substitute dots by hypens if our main process is CCL, it 
  ;; prepends the > symbol before dots;
  ;; for example: 1.1.0.36.mswinmt.1201-284e340 => 1>.1>.0>.36>.mswinmt.1201-284e340
  ;; When we pass such a pathname to other lisps, they can't handle it.
  (substitute #\- #\. str))

(defun log-name (lisp openssl-release)
  (sanitize-as-path
   (string-downcase (concatenate 'string
                                 (tg-agent::implementation-identifier lisp)
                                 "-"
                                 openssl-release))))

(defun fasl-dir (test-run-dir lisp)
  (merge-pathnames
   (format nil
           "~(~A~)/"
           (sanitize-as-path (tg-agent::implementation-identifier lisp)))
   (fasl-root test-run-dir)))

(defun run (&key test-run-description
              test-run-dir
              quicklisp-dir
              lisps
              openssl-releases
              (bitnesses '("64"))
              openssl-releases-dir
              cl+ssl-location
              verify-location)
  ;; (unless cl+ssl-location
  ;;   (error "cl+ssl-location parameter is not specified and *load-truename* was not available at the load time."))

  (ensure-directories-exist test-run-dir)
  
  (let ((lisp-exe:*temp-dir* test-run-dir))
    (flet ((run-lib-test (lisp openssl-release bitness)
             (tg-agent::proc-run-libtest
              lisp
              :cl+ssl
              (cons :lisp (cons (tg-agent::implementation-identifier lisp)
                                test-run-description))
              (merge-pathnames (log-name lisp openssl-release) test-run-dir)
              quicklisp-dir
              (fasl-dir test-run-dir lisp)
              :eval-before-test `(progn
                                   (set (read-from-string "asdf:*central-registry*")
                                        (cons ,cl+ssl-location
                                              (symbol-value (read-from-string "asdf:*central-registry*"))))
                                   ,(when cl+ssl-location
                                          `(cl-user::fncall "add-asdf-output-translation"
                                                            ,cl+ssl-location
                                                            ,(merge-pathnames "cl+ssl/" (fasl-dir test-run-dir lisp))))

                                   (cl-user::fncall "ql:quickload" :cl+ssl/config)
                                   (eval (list (read-from-string "cl+ssl/config:define-libcrypto-path")
                                               ,(my-openssl-releases:so-path openssl-releases-dir
                                                                             openssl-release
                                                                             bitness
                                                                             "libcrypto.so")))
                                   (eval (list (read-from-string "cl+ssl/config:define-libssl-path")
                                               ,(my-openssl-releases:so-path openssl-releases-dir
                                                                             openssl-release
                                                                             bitness
                                                                             "libssl.so")))

                                   ,@(when verify-location
                                       `((cl-user::fncall "ql:quickload" :cl+ssl)
                                         (cl-user::fncall "cl+ssl:ensure-initialized") ; needed to set the *ssl-global-context*
                                         (cl-user::fncall "cl+ssl::ssl-ctx-set-verify-location"
                                                          (symbol-value (read-from-string "cl+ssl::*ssl-global-context*"))
                                                          ,verify-location)))))))
      (tg-utils::write-to-file
       (alexandria:map-product (lambda (lisp openssl-release bitness)
                                 (list (tg-agent::implementation-identifier lisp)
                                       openssl-release
                                       (getf (run-lib-test lisp openssl-release bitness)
                                             :status)))
                               lisps
                               openssl-releases
                               bitnesses)
       (merge-pathnames "results.lisp" test-run-dir)))))

(defun clean-fasls (test-run-dir)
  (cl-fad:delete-directory-and-files (fasl-root test-run-dir)))