Commit graph

10 commits

Author SHA1 Message Date
Daniel Verkamp
875a1d7d30 base: net: use tempfile::tempdir() in tests
Avoid the possibility of tests reusing the same socket path by using a
known unique directory from tempfile::tempdir().

BUG=b:274145919
TEST=tools/dev_container tools/presubmit

Change-Id: I883e223617fb465cdfbff5a45509098487b62b3b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4348699
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-03-17 20:02:44 +00:00
Daniel Verkamp
7e803c87ca base: use SafeDescriptor in unix socket wrappers
The SafeDescriptor type manages the lifetime of the file descriptor,
which simplifies the socket wrappers (each wrapper no longer needs to
manually implement Drop to close the descriptor, for example).

Also remove unneeded RawFd-related functions, replacing them with
RawDescriptor and SafeDescriptor equivalents.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I634a19922ec24d06071b21247c79761cfc21a79a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4322266
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2023-03-17 18:12:49 +00:00
Dennis Kempin
b67eaca468 Use custom test harness for tests using fork
forking a process with multiple threads will lead to
undefined behavior. Unfortunately, newer versions of
libtest will spawn multiple threads even when running
a with --test-threads=1.

This change implements a custom, test harness using
libtest-mimic. It mimics the libtest CLI but enforces
a single threaded test process.

BUG=b:270167741
BUG=b:268496046
TEST=tools/run_tests --dut=host

Change-Id: Icef6a1b65bab7f5cd5021c01fbd94487fa0ca5fb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4295157
Reviewed-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-03-01 21:46:16 +00:00
George Burgess IV
64c178e9b7 crosvm: skip single-threaded tests
The Rust uprev breaks some assumptions these make. Sounds best from
discussion on the CL to temporarily disable them.

BUG=b:266817148, b:268496046
TEST=emerge-nocturne crosvm-base

Change-Id: If86eb23200b5af4be8221bacc42954b3dfc25aeb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4218895
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: George Burgess <gbiv@chromium.org>
2023-02-09 20:21:23 +00:00
Daniel Verkamp
5c1f06dc81 Fix new Rust 1.65 clippy warnings
A few more needless_borrow and needless_return warnings slipped in since
the last round of Rust 1.65 clippy fixes.

BUG=b:260784028
TEST=tools/clippy # with Rust 1.65

Change-Id: Iefceab6f1ec1c460e92b49f9cd21cfb79569f04a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4133516
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-05 23:08:09 +00:00
Dennis Kempin
9a5dcbc68d base: Spawn separate process for executing process tests
These tests will use fork, which does not work in a multi-threaded
process. This is currently enforced by passing --test-threads 1 to
this test, but that won't work with cargo nextest.

To ensure that the test process is single-threaded, re-execute the
test binary as a child process.

BUG=b:261600801
TEST=presubmit

Change-Id: I1762ebbae66331895f84df9daa484468f1fe086d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4086902
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
2022-12-07 19:19:46 +00:00
Dennis Kempin
82315e0a20 base: Move newly added process tests into an integration test
The test needs to be run single threaded and is not suitable
to be a unit tests.
Integration tests are automatically run single threaded.

BUG=None
TEST=presubmit

Change-Id: Idd49af90c7c1858b28ba47a642a8a808319138c3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4018113
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-11-09 20:45:59 +00:00
Dennis Kempin
86034fd5fb base: Move clone_equality test to integration test
In non-privileged containers, comparing a file descriptor may not
work. So the test will not work in every runtime environment.

BUG=b:244623061
TEST=dev_container --podman --unprivileged tools/run_tests base:base

Change-Id: Ifa67e11db9694c36b47cd5ae88de9247284e1cdf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3999711
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-11-02 22:29:12 +00:00
Dennis Kempin
f8eb24052e Reformat all files with nightly
Run tools/fmt --nightly

BUG=None
TEST=None

Change-Id: Iaccfc5fe141c512f4b508c699f89686a4552bf96
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3988327
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-10-31 21:33:33 +00:00
Dennis Kempin
b896b869e4 base: Extract integration tests
The extracted tests rely on access to system devices
or global state that prevent them from being run in parallel
or in restricted environments.

As an integration test they will be executed separately and
single threaded.

Updates the test runner to ensure integration tests are actually
run single threaded as intended.

BUG=b:244623061
TEST=./tools/run_tests base:\* --repeat 100 -p x86_64/mingw64/aarch64

Change-Id: I4267b9f79055208aca86796d902da251816bcada
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3971025
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-10-24 22:49:29 +00:00