Commit Graph

54 Commits

Author SHA1 Message Date
Adin Scannell f1a46c928f Support STAGED_BINARIES to run prebuilt binaries with the test pipeline.
In some cases, it may be desirable to prebuild binaries and run all tests,
for example to run benchmarks with various experiments. Allow the top-level
Makefile to support this by checking for a STAGED_BINARIES variable.

PiperOrigin-RevId: 410673120
2021-11-17 17:49:35 -08:00
Fabricio Voznika b928a241ef Enable VFS2 by default
This change enables VFS2 by default. VFS2 is much faster than the previous
implementation and it's also more compatible. VFS1 is no longer supported and
will be deleted from the code.

Use `--vfs2=false` if you need to disable it. Make sure to report a bug if you
have the need to disable VFS2 or something is not working for you.

Closes #1035

PiperOrigin-RevId: 404898135
2021-10-21 15:48:25 -07:00
gVisor bot 63b1c736b3 Internal change.
PiperOrigin-RevId: 396155387
2021-09-11 18:04:15 -07:00
Ghanan Gowripalan dfb3273f88 Support sending with packet sockets
...through the loopback interface, only.

This change only supports sending on packet sockets through the loopback
interface as the loopback interface is the only interface used in packet
socket syscall tests - the other link endpoints are not excercised with
the existing test infrastructure.

Support for sending on packet sockets through the other interfaces will
be added as needed.

BUG: https://fxbug.dev/81592
PiperOrigin-RevId: 394368899
2021-09-01 19:44:22 -07:00
Chong Cai d247938363 Add verity open benchmark test
PiperOrigin-RevId: 386533065
2021-07-23 14:35:42 -07:00
Ghanan Gowripalan aa26981700 Move socket_test_util to //test/util
...and rename the library to socket_util.

PiperOrigin-RevId: 386348306
2021-07-22 16:37:15 -07:00
Etienne Perot 4470caec4e Run `:socket_inet_loopback_isolated_test_linux` tests in a container.
This creates new user and network namespaces for all tests in
`:socket_inet_loopback_isolated_test_linux`.

PiperOrigin-RevId: 381374120
2021-06-24 17:49:09 -07:00
Nicolas Lacasse 3fb646ed10 Rename go files that contain "main" function to main.go.
This is a good Go convention that we should follow.

PiperOrigin-RevId: 378538679
2021-06-09 17:36:51 -07:00
Andrei Vagin f8d79e94e6 Add hash15 label for tests.
PiperOrigin-RevId: 373875071
2021-05-14 15:15:47 -07:00
Andrei Vagin 47d1b8b4b8 Automated rollback of changelist 361661726
PiperOrigin-RevId: 372221411
2021-05-05 15:36:02 -07:00
Adin Scannell 8192cccda6 Clean test tags.
PiperOrigin-RevId: 369505182
2021-04-20 13:11:25 -07:00
Dean Deng 0c3e8daf50 Allow runsc to generate coverage reports.
Add a coverage-report flag that will cause the sandbox to generate a coverage
report (with suffix .cov) in the debug log directory upon exiting. For the
report to be generated, runsc must have been built with the following Bazel
flags: `--collect_code_coverage --instrumentation_filter=...`.

With coverage reports, we should be able to aggregate results across all tests
to surface code coverage statistics for the project as a whole.

The report is simply a text file with each line representing a covered block
as `file:start_line.start_col,end_line.end_col`. Note that this is similar to
the format of coverage reports generated with `go test -coverprofile`,
although we omit the count and number of statements, which are not useful for
us.

Some simple ways of getting coverage reports:

bazel test <some_test> --collect_code_coverage \
  --instrumentation_filter=//pkg/...

bazel build //runsc --collect_code_coverage \
  --instrumentation_filter=//pkg/...
runsc -coverage-report=dir/ <other_flags> do ...

PiperOrigin-RevId: 368952911
2021-04-16 17:56:16 -07:00
Ting-Yu Wang 272d2e1168 Make the generated test binary name match the target name
PiperOrigin-RevId: 368495641
2021-04-14 13:25:17 -07:00
Fabricio Voznika e0e04814b4 Fix invalid interface conversion in runner
panic: interface conversion: interface {} is syscall.WaitStatus, not unix.WaitStatus

goroutine 1 [running]:
main.runTestCaseNative(0xc0001fc000, 0xe3, 0xc000119b60, 0x1, 0x1, 0x0, 0x0)
	test/runner/runner.go:185 +0xa94
main.main()
	test/runner/runner.go:118 +0x745

PiperOrigin-RevId: 361957796
2021-03-09 20:12:20 -08:00
Fabricio Voznika 1b9d45dbe8 Run shards in a single sandbox
Run all tests (or a given test partition) in a single sandbox.
Previously, each individual unit test executed in a new
sandbox, which takes much longer to execute.

                 Before       After
Syscall tests: 37m22.768s   14m5.272s

PiperOrigin-RevId: 361661726
2021-03-08 14:48:16 -08:00
Ayush Ranjan 0a909ba75a [op] Replace syscall package usage with golang.org/x/sys/unix in test/.
The syscall package has been deprecated in favor of golang.org/x/sys.

Note that syscall is still used in some places because the following don't seem
to have an equivalent in unix package:
- syscall.SysProcIDMap
- syscall.Credential

Updates #214

PiperOrigin-RevId: 361332034
2021-03-06 09:54:09 -08:00
Fabricio Voznika f03144d886 Support TEST_PREMATURE_EXIT_FILE in syscall tests
PiperOrigin-RevId: 352068182
2021-01-15 13:03:58 -08:00
Adin Scannell 4e03e87547 Fix simple mistakes identified by goreportcard.
These are primarily simplification and lint mistakes. However, minor
fixes are also included and tests added where appropriate.

PiperOrigin-RevId: 351425971
2021-01-12 12:38:22 -08:00
Adin Scannell 80552b936d Support partitions for other tests.
PiperOrigin-RevId: 345399936
2020-12-03 01:00:21 -08:00
Jamie Liu 7f2183df9c Internal change
PiperOrigin-RevId: 341732791
2020-11-10 17:39:31 -08:00
Andrei Vagin 73f980e97e Block external network for tests
And in this case, tests will run in separate network namespaces
and will not affect each other.

PiperOrigin-RevId: 340267734
2020-11-02 10:41:52 -08:00
Dean Deng 9ca66ec598 Rewrite reference leak checker without finalizers.
Our current reference leak checker uses finalizers to verify whether an object
has reached zero references before it is garbage collected. There are multiple
problems with this mechanism, so a rewrite is in order.

With finalizers, there is no way to guarantee that a finalizer will run before
the program exits. When an unreachable object with a finalizer is garbage
collected, its finalizer will be added to a queue and run asynchronously. The
best we can do is run garbage collection upon sandbox exit to make sure that
all finalizers are enqueued.

Furthermore, if there is a chain of finalized objects, e.g. A points to B
points to C, garbage collection needs to run multiple times before all of the
finalizers are enqueued. The first GC run will register the finalizer for A but
not free it. It takes another GC run to free A, at which point B's finalizer
can be registered. As a result, we need to run GC as many times as the length
of the longest such chain to have a somewhat reliable leak checker.

Finally, a cyclical chain of structs pointing to one another will never be
garbage collected if a finalizer is set. This is a well-known issue with Go
finalizers (https://github.com/golang/go/issues/7358). Using leak checking on
filesystem objects that produce cycles will not work and even result in memory
leaks.

The new leak checker stores reference counted objects in a global map when
leak check is enabled and removes them once they are destroyed. At sandbox
exit, any remaining objects in the map are considered as leaked. This provides
a deterministic way of detecting leaks without relying on the complexities of
finalizers and garbage collection.

This approach has several benefits over the former, including:
- Always detects leaks of objects that should be destroyed very close to
  sandbox exit. The old checker very rarely detected these leaks, because it
  relied on garbage collection to be run in a short window of time.
- Panics if we forgot to enable leak check on a ref-counted object (we will try
  to remove it from the map when it is destroyed, but it will never have been
  added).
- Can store extra logging information in the map values without adding to the
  size of the ref count struct itself. With the size of just an int64, the ref
  count object remains compact, meaning frequent operations like IncRef/DecRef
  are more cache-efficient.
- Can aggregate leak results in a single report after the sandbox exits.
  Instead of having warnings littered in the log, which were
  non-deterministically triggered by garbage collection, we can print all
  warning messages at once. Note that this could also be a limitation--the
  sandbox must exit properly for leaks to be detected.

Some basic benchmarking indicates that this change does not significantly
affect performance when leak checking is enabled, which is understandable
since registering/unregistering is only done once for each filesystem object.

Updates #1486.

PiperOrigin-RevId: 338685972
2020-10-23 09:17:02 -07:00
Tiwei Bie ca731934fe Disable strace+debug when explicitly requested
Currently strace+debug is always enabled as the setting from
the upper layer isn't passed to _syscall_test(). And it will
negatively affect the performance tests. This patch fixes this
issue.

The "debug" argument of _syscall_test() is also made mandatory
to prevent this happening again.

//test/perf:getpid_benchmark_runsc_kvm

-----------------------------------------------------
Benchmark           Time             CPU   Iterations
-----------------------------------------------------
Before:
BM_Getpid       28119 ns        28157 ns        25926

After:
BM_Getpid         947 ns          939 ns       777778

Fixes #4509

Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
2020-10-14 14:41:23 +08:00
Andrei Vagin 10ca12b3d0 gvisor/test: Set nogotsan for native tests
Tests are written in C++ and there is no reason to run them with gotsan without
gVisor.

PiperOrigin-RevId: 336783276
2020-10-12 17:57:37 -07:00
Fabricio Voznika 9e9fec3a09 Enable more VFS2 tests
Updates #1487

PiperOrigin-RevId: 335516732
2020-10-05 15:54:36 -07:00
Rahat Mahmood a3d189301d Run syscall tests in uts namespaces.
Some syscall tests, namely uname_test_* modify the host and domain
name, which modifies the execution environment and can have unintended
consequences on other tests. For example, modifying the hostname
causes some networking tests to fail DNS lookups. Run all syscall
tests in their own uts namespaces to isolate these changes.

PiperOrigin-RevId: 329348127
2020-08-31 11:58:45 -07:00
Fabricio Voznika e8a25a2834 Enable strace+debug in syscall tests
This is done to ease troubleshooting when tests fail. runsc
logs are not stored when tests passe, so this will only
affect failing tests and should not increase log storage
too badly.

PiperOrigin-RevId: 327717551
2020-08-20 16:19:10 -07:00
gVisor bot e6df6222ac Merge pull request #3250 from craig08:fuse-getattr
PiperOrigin-RevId: 326313858
2020-08-12 14:36:04 -07:00
Fabricio Voznika 00b684ea7f Limit the scope when deleting test log directory on success
The code was deleting logs for all tests when a single test
passed. Change it to delete only the logs relevant to the
test at hand.

Also fixed the benchmark lookup code, which was always generating
a single empty benchmark entry if there were not benchmarks.

PiperOrigin-RevId: 326311477
2020-08-12 14:23:29 -07:00
Craig Chi 51e64d2fc5 Implement FUSE_GETATTR
FUSE_GETATTR is called when a stat(2), fstat(2), or lstat(2) is issued
from VFS2 layer to a FUSE filesystem.

Fixes #3175
2020-08-10 18:15:32 -07:00
Ayush Ranjan a1af46c20a Enable VFS2 by default for all syscall tests.
Fixes #2923

PiperOrigin-RevId: 325904734
2020-08-10 15:50:22 -07:00
Adin Scannell 90021e775a Add bzl_library rules for .bzl files without one.
PiperOrigin-RevId: 325280924
2020-08-06 12:10:49 -07:00
Craig Chi 21d0334e7f Add FUSE integration test
This commit adds an integration test framework for FUSE support. Please
refer to the test example and test/fuse/README.md for further details.

Fixes #3098
2020-08-04 12:27:55 -07:00
gVisor bot 1876225fc8 Merge pull request #3377 from kevinGC:native-tags
PiperOrigin-RevId: 323398518
2020-07-27 11:10:24 -07:00
Andrei Vagin d6b676ae6a test/syscall: run each test case in a separate network namespace
... when it is possible.

The guitar gVisorKernel*Workflow-s runs test with the local execution_method.
In this case, blaze runs test cases locally without sandboxes. This means
that all tests run in the same network namespace. We have a few tests which
use hard-coded network ports and they can fail if one of these port will be
used by someone else or by another test cases.

PiperOrigin-RevId: 323137254
2020-07-25 01:04:45 -07:00
Kevin Krakauer 91a47a40a8 Bugfix: non-native tests were tagged as native
Copy the list of tags when passing it to _syscall_test.
2020-07-24 17:27:11 -07:00
gVisor bot 8939fae0af Merge pull request #3165 from ridwanmsharif:ridwanmsharif/fuse-off-by-default
PiperOrigin-RevId: 321411758
2020-07-15 12:14:42 -07:00
gVisor bot c81ac8ec3b Merge pull request #2672 from amscanne:shim-integrated
PiperOrigin-RevId: 321053634
2020-07-13 16:10:58 -07:00
Ridwan Sharif abffebde7b Gate FUSE behind a runsc flag
This change gates all FUSE commands (by gating /dev/fuse) behind a runsc
flag. In order to use FUSE commands, use the --fuse flag with the --vfs2
flag. Check if FUSE is enabled by running dmesg in the sandbox.
2020-07-09 02:01:29 -04:00
Nicolas Lacasse f0feada89c Use internal tmpfs in test runner, even when running with overlay.
PiperOrigin-RevId: 317377571
2020-06-19 14:14:21 -07:00
Michael Pratt 6d806ee719 Remove various uses of 'blacklist'
Updates #2972

PiperOrigin-RevId: 316942245
2020-06-17 12:34:33 -07:00
Rahat Mahmood f23f62c2c2 Correctly set the test VFS environment variable.
Also fix test bugs uncovered now that they aren't silently skipped on
VFS2.

Updates #1487.

PiperOrigin-RevId: 316415807
2020-06-15 01:09:38 -07:00
Adin Scannell 5a894e35a0 Remove generated logs when test succeeds.
PiperOrigin-RevId: 316022884
2020-06-11 19:05:18 -07:00
Andrei Vagin 9e66ac4c20 test/syscall: run hostnet tests in separate network namespaces
A few tests use hard coded port numbers, so we need to guruantee that
these ports will not be used for somthing else.
2020-06-04 18:23:45 -07:00
Fabricio Voznika 4b5eae39f2 Enable VFS2 to runsc syscall tests
Updates #1487

PiperOrigin-RevId: 314271995
2020-06-01 23:03:20 -07:00
Gaurav Singh a2b3b67b3f runner: fix goroutine leak
Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
2020-05-29 12:36:49 -04:00
Jamie Liu 198642df76 Fix IsRunningWithVFS1() on the runsc-based test runner.
Updates #1035

PiperOrigin-RevId: 312736450
2020-05-21 14:02:43 -07:00
Adin Scannell 1481499fe2 Simplify Docker test infrastructure.
This change adds a layer of abstraction around the internal Docker APIs,
and eliminates all direct dependencies on Dockerfiles in the infrastructure.

A subsequent change will automated the generation of local images (with
efficient caching). Note that this change drops the use of bazel container
rules, as that experiment does not seem to be viable.

PiperOrigin-RevId: 308095430
2020-04-23 11:33:30 -07:00
gVisor bot 8b72623e6a Internal change.
PiperOrigin-RevId: 307622320
2020-04-21 09:44:00 -07:00
Andrei Vagin d5fe1ce0c1 test: Create a separate /tmp mount only for tests with the shared tag
The root mount is not shared by default, but all other mounts are shared.

So if we create the /tmp mount, this means that we run tests on a shared mount
even if tests run without the --shared option.

PiperOrigin-RevId: 302130790
2020-03-20 17:20:24 -07:00