Skip to content
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

CP-47001 Introduce file descriptor testing framework #83

Closed

Commits on Dec 20, 2023

  1. [maintenance]: disable implicit transitive deps

    Helps catch missing dependencies in dune files.
    
    Signed-off-by: Edwin Török <[email protected]>
    edwintorok committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    956f52d View commit details
    Browse the repository at this point in the history
  2. CP-47001: [xapi-fdcaps]: dune plumbing for new library

    This will be a new library that will provide a more type-safe interface to file descriptor operations.
    Useful on its own, but also for testing stdext.
    
    Minimal dependencies, only Unix (and Alcotest for testing).
    
    Signed-off-by: Edwin Török <[email protected]>
    edwintorok committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    b0f9bae View commit details
    Browse the repository at this point in the history
  3. CP-47001: [xapi-fd-test]: dune plumbing for a new test framework

    This will be a test framework providing QCheck generators and properties for
    testing file descriptor operations.
    It will try to generate:
    * different kinds of file descriptors
    * actual data written/read on the other end of pipes and socket pairs
    * different speeds and delays on the other end to find buffering bugs
    * file descriptors that are >1024 to find bugs with select
    
    Signed-off-by: Edwin Török <[email protected]>
    edwintorok committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    96ab3f4 View commit details
    Browse the repository at this point in the history
  4. CP-47001: [xapi-fdcaps]: add -principal flag

    We are going to use type-level constraints a lot.
    Try to future proof it by using the recommended compiler flag.
    `ocamlc` says this about `-principal`:
    > When using labelled arguments and/or polymorphic methods, this flag is required to
    > ensure future versions of the compiler will be able to infer types correctly, even if internal algorithms change
    
    Signed-off-by: Edwin Török <[email protected]>
    edwintorok committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    2ca1c34 View commit details
    Browse the repository at this point in the history
  5. CP-47001: [xapi-fdcaps]: optional coverage support

    This is not enabled by default (but bisect-ppx is nevertheless a build-time dependency)
    Usage: `make coverage`
    
    Signed-off-by: Edwin Török <[email protected]>
    edwintorok committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    6a6a2ff View commit details
    Browse the repository at this point in the history
  6. CP-47001: [xapi-fdcaps]: add properties module and tests

    Lightweight wrapper using polymorphic variants to track read, write, and file kind properties on file descriptors.
    We only track the property at the time the file descriptor was opened.
    
    This prevents bugs like accidentally swapping the read and write ends of a pipe,
    or attempting to run an operation on a file descriptor that would alway s fail (e.g. setting a socket timeout on a pipe)
    
    Write tests using cram-style expect tests that the operations we expect to be forbidden by this type system
    are actually forbidden.
    The error messages may be compiler version dependent, so only run them on OCaml 4.14.1 for now.
    
    Signed-off-by: Edwin Török <[email protected]>
    edwintorok committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    872f5ed View commit details
    Browse the repository at this point in the history
  7. CP-47001: [xapi-fdcaps]: add operations module and tests

    Use the capabilities module to wrap most Unix operations needed in testing Unixext
    
    Add a testsuite that checks that whenever the type says "never" the underlying file descriptor operation
    would indeed raise an exception. This ensures that the type constraints we declare are actually correct.
    The checks use unsafe operations that bypass the type layer.
    
    Similarly check that operations that are accepted by the type system and marked as "always" in the type succeed.
    
    Signed-off-by: Edwin Török <[email protected]>
    edwintorok committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    8cfb5b4 View commit details
    Browse the repository at this point in the history

Commits on Dec 21, 2023

  1. Configuration menu
    Copy the full SHA
    270aea6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e54cde2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    831010f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d2fac79 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ab54dc4 View commit details
    Browse the repository at this point in the history

Commits on Dec 22, 2023

  1. Configuration menu
    Copy the full SHA
    7c3ce31 View commit details
    Browse the repository at this point in the history
  2. CP-47001: [xapi-fdcaps-test]: add observations module

    It can be used to wrap read or write operations andobserve the data that is transferred,
    and elapsed time.
    
    It also provides 2 functions that create a file of a given kind.
    
    We only test UNIX sockets, because socketpair doesn't support TCP sockets on Linux.
    
    Signed-off-by: Edwin Török <[email protected]>
    edwintorok committed Dec 22, 2023
    Configuration menu
    Copy the full SHA
    a7bb4e9 View commit details
    Browse the repository at this point in the history
  3. CP-47001: [xapi-fdcaps-test]: add generate module

    Signed-off-by: Edwin Török <[email protected]>
    edwintorok committed Dec 22, 2023
    Configuration menu
    Copy the full SHA
    20c69ea View commit details
    Browse the repository at this point in the history