Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib_eio_linux/tests/test.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
exception Skip_test of string
let skip _stdenv =
raise (Skip_test "io_uring not available in Docker")

open Eio.Std

module Trace = Eio.Private.Trace
Expand All @@ -19,7 +23,7 @@ let read_one_byte ~sw r =
)

let test_poll_add () =
Eio_linux.run @@ fun _stdenv ->
Eio_linux.run ~fallback:skip (fun _stdenv ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still no need to make the change from @@ to (

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @patricoferris -- I have gone through the documentation, To get it correct, I used Alcotest.skip. Something like this

let skip_io_uring () = 
    Alcotest.skip "Skipping test: io_uring not available in Docker";;

However, when i use this, i encounter this error: Alcotest.skip "Skipping test: io_uring not available in Docker";; Error: This expression has type string but an expression was expected of type unit

Is there something i am doing wrong? I would appreciate help.

Copy link
Collaborator

@patricoferris patricoferris Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@create2000 the type of skip is

val skip : unit -> 'a 

It doesn't expect a string as the first argument but a value of type unit (i.e ()). You could perhaps log something with Eio.traceln and then Alcotest.skip (). Note that this is only for the Alcotest-based Linux tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patricoferris Thank you for the clarification. I have modified it and logged a message using the Eio.tracein which was displayed in the generated file after running the file.

This is the new modification:

let skip_io_uring () =
  Eio.traceln "Skipping test: io_uring not available in Docker";
  Alcotest.skip ()
let test_poll_add () =
  Eio_linux.run ~fallback:(skip_io_uring()) 

Switch.run @@ fun sw ->
let r, w = Eio_unix.pipe sw in
let thread = read_one_byte ~sw r in
Expand All @@ -32,10 +36,10 @@ let test_poll_add () =
assert (sent = 1);
let result = Promise.await_exn thread in
Alcotest.(check string) "Received data" "!" result

)
let test_poll_add_busy () =
Eio_linux.run ~queue_depth:2 @@ fun _stdenv ->
Switch.run @@ fun sw ->
Eio_linux.run ~queue_depth:2 ~fallback:skip (fun _stdenv ->
Switch.run @@ fun sw ->
let r, w = Eio_unix.pipe sw in
let a = read_one_byte ~sw r in
let b = read_one_byte ~sw r in
Expand All @@ -50,7 +54,7 @@ let test_poll_add_busy () =
Alcotest.(check string) "Received data" "!" a;
let b = Promise.await_exn b in
Alcotest.(check string) "Received data" "!" b

)
(* Write a string to a pipe and read it out again. *)
let test_copy () =
Eio_linux.run ~queue_depth:3 @@ fun _stdenv ->
Expand Down Expand Up @@ -259,4 +263,4 @@ let () =
test_case "signal_race" `Quick test_signal_race;
test_case "alloc-fixed-or-wait" `Quick test_alloc_fixed_or_wait;
];
]
]
Loading