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

[meta] Add testing for syscalls #961

Closed
15 of 31 tasks
lkatalin opened this issue Sep 4, 2020 · 1 comment
Closed
15 of 31 tasks

[meta] Add testing for syscalls #961

lkatalin opened this issue Sep 4, 2020 · 1 comment
Assignees

Comments

@lkatalin
Copy link
Contributor

lkatalin commented Sep 4, 2020

If you decide to work on this meta-issue, please create a separate issue with its own PR for each syscall you test or implement and then link that separate issue with your PR.

Integration test overview

An integration test for a syscall runs a minimal binary in the Keep and checks the results. Writing an integration test involves creating the binary itself (at least one per each syscall to test) and updating the test harness to run this binary in the Keep during cargo test. Some syscalls have more than one binary for different variations of parameters, ex. exit or write each have several varieties to test different exit codes or to test writing to different file descriptors.

Each syscall test is implemented in C inline assembly in our libc.h file. The corresponding C binary file for each syscall then refers to this implementation by including our libc.h and calling the correct function. The test harness is written in Rust and actually runs the binary in a Keep. See the run_test() function for more on how to pass inputs and receive outputs from the test.

Example: syscall test for write()

  1. Create a C inline assembly implementation for write in libc.h
  2. Create a C binary that uses your implementation
  3. Add a Rust test to run this binary in a Keep and check that the outputs and return status code are expected

Syscalls to test

Choose a syscall that is not checked off to test. Edit this list to indicate you are working on it so that someone else does not duplicate the work, ex. by writing "current WIP" next to the syscall on the list.

  • read(),
  • readv(),
  • write(),
  • writev(),
  • exit(),
  • getuid(),
  • arch_prctl(),
  • exit_group(),
  • set_tid_address(),
  • brk(),
  • uname(),
  • mprotect(),
  • mmap(),
  • munmap(),
  • rt_sigaction(),
  • rt_sigprocmask(),
  • sigaltstack(),
  • getrandom(),
  • clock_gettime(),
  • madvise(),
  • close()
  • pipe
  • fcntl with F_GETFD, F_SETFD, F_GETFL, F_SETFL
  • ioctl with FIONBIO
  • getsockname
  • sendto
  • setsockopt
  • epoll_create1
  • epoll_ctl
  • epoll_wait
  • getpid

Extra info about syscall implementations

Syscalls are implemented internally here (these are handled in the Keep or if necessary are proxied out to the host). Each architecture can also override these definitions in its own handler: see the handlers for SGX and SEV. In SGX, syscalls are passed to the handler from the event file. In SEV, syscalls are passed to the handler from here.

Here is a master list of syscalls required by wasmtime, for reference. Which of these syscalls we will implement from this list is TBD.

@ambaxter ambaxter self-assigned this Sep 7, 2020
@mbestavros mbestavros assigned ambaxter and unassigned ambaxter Dec 2, 2020
@lkatalin lkatalin changed the title [meta] Implement and test syscalls in SGX [meta] Test syscalls Dec 17, 2020
@lkatalin lkatalin changed the title [meta] Test syscalls [meta] Add testing for syscalls Dec 17, 2020
@nickvidal nickvidal transferred this issue from enarx-archive/enarx-keepldr Sep 29, 2021
@platten
Copy link
Contributor

platten commented Jan 11, 2022

Since we are focusing on testing user experience vs. syscalls, marking this as closed.

@platten platten closed this as completed Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants