Skip to content

Commit

Permalink
Merge pull request #148 from savonet/github_action_tests
Browse files Browse the repository at this point in the history
Move ssl version test to a github action specific target, execute this target in the CI.
  • Loading branch information
toots committed Jul 15, 2023
2 parents d61df8d + bc11626 commit d0150e4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Expand Up @@ -35,7 +35,10 @@ jobs:
run: opam install .
- name: Build and test
if: ${{ matrix.setup.runtest }}
run: opam install -t .
run: |
opam install -t .
eval $(opam env)
dune build @github_action_tests
nix-build:
runs-on: ${{ matrix.setup.os }}
Expand Down
15 changes: 15 additions & 0 deletions tests/dune
@@ -1,3 +1,8 @@
(alias
(name github_action_tests)
(deps
(alias_rec runtest)))

(library
(name util)
(modules util)
Expand All @@ -14,6 +19,16 @@
(modules ssl_comm)
(libraries ssl alcotest))

(executable
(name ssl_version)
(modules ssl_version)
(libraries ssl alcotest))

(rule
(alias github_action_tests)
(action
(run ./ssl_version.exe)))

(test
(name ssl_context)
(modules ssl_context)
Expand Down
12 changes: 0 additions & 12 deletions tests/ssl_comm.ml
Expand Up @@ -25,23 +25,11 @@ let test_error_queue () =
check string "Library string" "SSL routines" (Option.get err.lib);
check string "Reason string" "system lib" (Option.get err.reason)

let test_version () =
let ch = Unix.open_process_in "openssl version" in
let m, n, p =
Scanf.(bscanf (Scanning.from_channel ch)) "OpenSSL %d.%d.%d" (fun x y z ->
x, y, z)
in
Unix.close_process_in ch |> ignore;
check int "major" m Ssl.native_library_version.major;
check int "minor" n Ssl.native_library_version.minor;
check int "patch" p Ssl.native_library_version.patch

let () =
Alcotest.run
"Ssl communication"
[ ( "Communication"
, [ test_case "Test init" `Quick test_init
; test_case "Test version" `Quick test_version
; test_case "Test error queue" `Quick test_error_queue
] )
]
27 changes: 27 additions & 0 deletions tests/ssl_version.ml
@@ -0,0 +1,27 @@
open Alcotest
open Ssl

let test_init () = init () |> ignore

(* This test is not super robust b/c `openssl` might not be installed or
installed but linked to a different shared libary. For this reason, this test
is only run in our internal github action CI. *)
let test_version () =
let ch = Unix.open_process_in "openssl version" in
let m, n, p =
Scanf.(bscanf (Scanning.from_channel ch)) "OpenSSL %d.%d.%d" (fun x y z ->
x, y, z)
in
Unix.close_process_in ch |> ignore;
check int "major" m Ssl.native_library_version.major;
check int "minor" n Ssl.native_library_version.minor;
check int "patch" p Ssl.native_library_version.patch

let () =
Alcotest.run
"Ssl version"
[ ( "Version"
, [ test_case "Test init" `Quick test_init
; test_case "Test version" `Quick test_version
] )
]

0 comments on commit d0150e4

Please sign in to comment.