tree: 03fa528f35f466b0bcec6388996499960624eb5e
  1. testdata/
  2. bootstrap-get-images.sh
  3. capabilities.bats
  4. cgroup_delegation.bats
  5. cgroups.bats
  6. checkpoint.bats
  7. cpu_affinity.bats
  8. create.bats
  9. cwd.bats
  10. debug.bats
  11. delete.bats
  12. dev.bats
  13. events.bats
  14. exec.bats
  15. get-images.sh
  16. help.bats
  17. helpers.bash
  18. hooks.bats
  19. hooks_so.bats
  20. host-mntns.bats
  21. idmap.bats
  22. ioprio.bats
  23. kill.bats
  24. list.bats
  25. mask.bats
  26. mounts.bats
  27. mounts_propagation.bats
  28. mounts_recursive.bats
  29. mounts_sshfs.bats
  30. no_pivot.bats
  31. pause.bats
  32. personality.bats
  33. pidfd-socket.bats
  34. ps.bats
  35. README.md
  36. rlimits.bats
  37. root.bats
  38. run.bats
  39. scheduler.bats
  40. seccomp-notify-compat.bats
  41. seccomp-notify.bats
  42. seccomp.bats
  43. selinux.bats
  44. spec.bats
  45. start.bats
  46. start_detached.bats
  47. start_hello.bats
  48. state.bats
  49. timens.bats
  50. tty.bats
  51. umask.bats
  52. update.bats
  53. userns.bats
  54. version.bats
tests/integration/README.md

runc Integration Tests

Integration tests provide end-to-end testing of runc.

Note that integration tests do not replace unit tests.

As a rule of thumb, code should be tested thoroughly with unit tests. Integration tests on the other hand are meant to test a specific feature end to end.

Integration tests are written in bash using the bats (Bash Automated Testing System) framework.

Running integration tests

The easiest way to run integration tests is with Docker:

make integration

Alternatively, you can run integration tests directly on your host through make:

sudo make localintegration

Or you can just run them directly using bats

sudo bats tests/integration

To run a single test bucket:

make integration TESTPATH="/checkpoint.bats"

To run them on your host, you need to set up a development environment plus bats (Bash Automated Testing System).

For example:

cd ~/go/src/github.com
git clone https://github.com/bats-core/bats-core.git
cd bats-core
./install.sh /usr/local

Note: There are known issues running the integration tests using devicemapper as a storage driver, make sure that your docker daemon is using aufs if you want to successfully run the integration tests.

Writing integration tests

helper functions are provided in order to facilitate writing tests.

#!/usr/bin/env bats

# This will load the helpers.
load helpers

# setup is called at the beginning of every test.
function setup() {
  setup_busybox
}

# teardown is called at the end of every test.
function teardown() {
  teardown_bundle
}

@test "this is a simple test" {
  runc run containerid
  # "The runc macro" automatically populates $status, $output and $lines.
  # Please refer to bats documentation to find out more.
  [ "$status" -eq 0 ]

  # check expected output
  [[ "${output}" == *"Hello"* ]]
}