-
Notifications
You must be signed in to change notification settings - Fork 15
CP-47001 Introduce file descriptor testing framework #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
edwintorok
wants to merge
15
commits into
xapi-project:master
from
edwintorok:private/edvint/testing
Closed
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
956f52d
[maintenance]: disable implicit transitive deps
edwintorok b0f9bae
CP-47001: [xapi-fdcaps]: dune plumbing for new library
edwintorok 96ab3f4
CP-47001: [xapi-fd-test]: dune plumbing for a new test framework
edwintorok 2ca1c34
CP-47001: [xapi-fdcaps]: add -principal flag
edwintorok 6a6a2ff
CP-47001: [xapi-fdcaps]: optional coverage support
edwintorok 872f5ed
CP-47001: [xapi-fdcaps]: add properties module and tests
edwintorok 8cfb5b4
CP-47001: [xapi-fdcaps]: add operations module and tests
edwintorok 270aea6
CP-47001: [xapi-fdcaps] add sections to Operations documentation
edwintorok e54cde2
fixup! CP-47001: [xapi-fdcaps]: add properties module and tests
edwintorok 831010f
fixup! CP-47001: [xapi-fdcaps]: optional coverage support
edwintorok d2fac79
fixup! CP-47001: [xapi-fdcaps]: add operations module and tests
edwintorok ab54dc4
CP-47001: [xapi-fdcaps]: wrap more Unix operations
edwintorok 7c3ce31
CP-47001: [xapi-fdcaps] runtime tests for read-write properties
edwintorok a7bb4e9
CP-47001: [xapi-fdcaps-test]: add observations module
edwintorok 20c69ea
CP-47001: [xapi-fdcaps-test]: add generate module
edwintorok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
_build/ | ||
_coverage/ | ||
*.install | ||
.merlin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
; This will be used to test stdext itself, so do not depend on stdext here | ||
(library | ||
(public_name xapi-fd-test) | ||
(name xapi_fd_test) | ||
(libraries xapi-fdcaps unix qcheck-core logs fmt mtime mtime.clock.os) | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
; This is a test framework, but we still need to test it | ||
(test | ||
(package xapi-fd-test) | ||
(name test_xapi_fd_test) | ||
(libraries xapi_fd_test alcotest) | ||
) |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
; Keep dependencies minimal here, ideally just OCaml stdlib | ||
; This will be used to test other functions in stdext, so it should not itself rely on other stdext libs! | ||
(library | ||
(public_name xapi-fdcaps) | ||
(name xapi_fdcaps) | ||
(libraries fmt unix threads.posix) | ||
(flags (:standard -principal)) | ||
|
||
; off by default, enable with --instrument-with bisect_ppx | ||
(instrumentation (backend bisect_ppx)) | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
(* | ||
* Copyright (C) 2023 Cloud Software Group | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation; version 2.1 only. with the special | ||
* exception on linking described in file LICENSE. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
*) | ||
|
||
type (+!'a, +!'b) props = {rw: 'a; kind: 'b} | ||
|
||
type rdonly = [`rdonly] | ||
|
||
type wronly = [`wronly] | ||
|
||
type rdwr = [`rdwr] | ||
|
||
let pp_rw fmt = | ||
Fmt.of_to_string | ||
(function #rdonly -> "RDONLY" | #wronly -> "WRONLY" | #rdwr -> "RDWR") | ||
fmt | ||
|
||
type reg = [`reg] | ||
|
||
type blk = [`blk] | ||
|
||
type chr = [`chr] | ||
|
||
type dir = [`dir] | ||
|
||
type lnk = [`lnk] | ||
|
||
type fifo = [`fifo] | ||
|
||
type sock = [`sock] | ||
|
||
type kind = [reg | blk | chr | dir | lnk | fifo | sock] | ||
|
||
let to_unix_kind = | ||
let open Unix in | ||
function | ||
| #reg -> | ||
S_REG | ||
| #blk -> | ||
S_BLK | ||
| #chr -> | ||
S_CHR | ||
| #dir -> | ||
S_DIR | ||
| #lnk -> | ||
S_LNK | ||
| #fifo -> | ||
S_FIFO | ||
| #sock -> | ||
S_SOCK | ||
|
||
let pp_kind fmt = | ||
Fmt.using to_unix_kind Safefd.pp_kind fmt | ||
|
||
let pp fmt = | ||
Fmt.( | ||
record | ||
~sep:Fmt.(any ", ") | ||
[field "rw" (fun t -> t.rw) pp_rw; field "kind" (fun t -> t.kind) pp_kind] | ||
) | ||
fmt | ||
|
||
type readable = [rdonly | rdwr] | ||
|
||
type writable = [wronly | rdwr] | ||
|
||
type rw = [rdonly | wronly | rdwr] | ||
|
||
type (+!'a, +!'b) t = (([< rw] as 'a), ([< kind] as 'b)) props | ||
|
||
let as_readable ({rw= #readable; _} as t) = t | ||
|
||
let as_writable ({rw= #writable; _} as t) = t | ||
|
||
let as_readable_opt = function | ||
| {rw= #readable; _} as x -> | ||
Some x | ||
| {rw= #wronly; _} -> | ||
None | ||
|
||
let as_writable_opt = function | ||
| {rw= #writable; _} as x -> | ||
Some x | ||
| {rw= #rdonly; _} -> | ||
None | ||
|
||
type espipe = [fifo | sock] | ||
|
||
let as_kind_opt expected ({kind; _} as t) = | ||
(* we cannot compare the values directly because we want to keep the type parameters distinct *) | ||
match (kind, expected) with | ||
| #reg, #reg -> | ||
Some {t with kind= expected} | ||
| #blk, #blk -> | ||
Some {t with kind= expected} | ||
| #chr, #chr -> | ||
Some {t with kind= expected} | ||
| #dir, #dir -> | ||
Some {t with kind= expected} | ||
| #lnk, #lnk -> | ||
Some {t with kind= expected} | ||
| #fifo, #fifo -> | ||
Some {t with kind= expected} | ||
| #sock, #sock -> | ||
Some {t with kind= expected} | ||
| #kind, #kind -> | ||
None | ||
|
||
type seekable = [reg | blk] | ||
|
||
type truncatable = reg | ||
|
||
let make rw kind = {rw; kind} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.