189 Commits

Author SHA1 Message Date
Giuseppe Scrivano
6c98db0b63 tests: add tests for crun custom annotations
Add comprehensive tests for crun-specific OCI annotations that were
previously untested:

- run.oci.hooks.stdout/stderr: Test hook output redirection to files
- run.oci.seccomp_fail_unknown_syscall: Test failure on unknown syscalls
- run.oci.systemd.subgroup: Test custom systemd subgroup naming
- run.oci.delegate-cgroup: Test cgroup delegation (cgroup v2 only)
- run.oci.systemd.force_cgroup_v1: Test forcing cgroup v1 on v2 systems
- run.oci.mount_context_type: Test SELinux mount context types
- run.oci.pidfd_receiver: Test pidfd transmission to UNIX socket

All tests include proper skip detection for:
- Nested namespace environments
- Missing root privileges
- Unavailable features (SELinux, systemd, cgroup v2, etc.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 07:22:13 +00:00
Giuseppe Scrivano
29a39ebf06 tests: add cgroup unit tests for coverage
Add unit tests for cgroup-related functions:
- test_read_proc_cgroup_v2: Test parsing cgroup v2 content
- test_read_proc_cgroup_v1: Test parsing cgroup v1 content with multiple controllers
- test_read_proc_cgroup_empty: Test with empty content
- test_read_proc_cgroup_named: Test named cgroup controller (name=systemd)
- test_convert_shares_to_weight: Test CPU shares to weight conversion
- test_convert_shares_boundary: Test boundary conditions for conversion
- test_read_proc_cgroup_null_params: Test with NULL output parameters
- test_read_proc_cgroup_selective: Test with selective parameter retrieval

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 07:22:13 +00:00
Giuseppe Scrivano
87997df077 tests: add seccomp_notify unit tests for coverage
Add unit tests for seccomp_notify.c to improve code coverage:
- test_cleanup_null: Test cleanup handler with NULL
- test_free_null_context: Test freeing NULL context
- test_load_invalid_path: Test loading plugin with invalid relative path
- test_load_nonexistent_plugin: Test loading non-existent plugin
- test_notify_no_seccomp: Test notify function without seccomp support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 07:22:13 +00:00
Giuseppe Scrivano
890fff109e tests: add chroot_realpath unit tests for coverage
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 07:22:13 +00:00
Giuseppe Scrivano
440e3b097d tests: add mount_flags.perf unit tests for coverage
Add unit tests for libcrun_str2mount_flags() and
get_mount_flags_from_wordlist() functions using the gperf-generated
perfect hash table from mount_flags.perf. Tests cover all 59 mount
flags including:
- Basic flags (bind, rbind, ro, rw)
- Permission flags (nosuid, nodev, noexec)
- Propagation flags (shared, slave, private, unbindable)
- Recursive variants (rro, rrw, rnosuid, etc.)
- Time flags (noatime, relatime, strictatime)
- Special OCI options (tmpcopyup, idmap, copy-symlink)
- Invalid inputs and error handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 07:22:13 +00:00
Giuseppe Scrivano
869343fbcc tests: add signals.perf unit tests for coverage
Add unit tests for str2sig() function that uses the gperf-generated
perfect hash table from signals.perf. Tests cover:
- All 62 standard and real-time signals
- Signal names with and without SIG prefix
- Numeric signal strings
- Real-time signals (RTMIN+N, RTMAX-N)
- Invalid inputs and error handling
- Case sensitivity

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 07:22:13 +00:00
Giuseppe Scrivano
1407bb39bc tests: add linux.c unit tests for coverage
Add unit tests for src/libcrun/linux.c functions including:
- libcrun_find_namespace()
- path_is_slash_dev()
- libcrun_reopen_dev_null()

Many functions in linux.c are static and cannot be tested directly
from unit tests. Integration tests in test_namespaces.py and
test_error_handling.py provide additional coverage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 07:19:08 +00:00
Giuseppe Scrivano
8a26d6ba1f tests: add comprehensive tests for custom-handler.c
Add both unit tests and Python integration tests to improve coverage
for src/libcrun/custom-handler.c which is currently at 28.2% coverage.

Unit tests (tests_libcrun_custom_handler.c):
- Test handler manager creation and cleanup
- Test handler lookup by name
- Test feature tag printing
- Test handler configuration with various scenarios
- Test error paths and edge cases

Python tests (test_custom_handler.py):
- Test sandbox annotation handling
- Test non-existent handler requests
- Test --handler command line option
- Test annotation and context handler conflicts
- Test feature tag output in --version
- Test empty and invalid handler annotations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 07:19:08 +00:00
Giuseppe Scrivano
07d6400b05 tests: add error handling tests for coverage
Add comprehensive tests for error handling paths including:
- Invalid JSON config handling
- Missing rootfs directory
- Non-existent binary in process args
- Invalid UID mappings
- Duplicate container IDs
- Operations on non-existent containers (state, delete, kill)
- Exec on stopped containers
- Invalid signal names
- Empty args array
- Readonly rootfs
- Non-existent working directory

These tests improve coverage of error paths in container lifecycle
management and validation code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 07:19:08 +00:00
Giuseppe Scrivano
f5e6c3300d tests: add Linux features tests
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 07:19:08 +00:00
Giuseppe Scrivano
58e00a5215 tests: add I/O priority tests
Add test_io_priority.py to test I/O priority handling in
src/libcrun/io_priority.c.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:56 +01:00
Giuseppe Scrivano
ae06b46cc0 tests: add create command tests
Add test_create.py to test the create command in src/create.c.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:56 +01:00
Giuseppe Scrivano
1e5f7ec56c tests: add cgroup setup tests
Add test_cgroup_setup.py to test cgroup setup code in
src/libcrun/cgroup-setup.c.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:56 +01:00
Giuseppe Scrivano
89b124e0b3 tests: add namespace isolation tests
Add test_namespaces.py to test namespace handling in
src/libcrun/linux.c.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:56 +01:00
Giuseppe Scrivano
14dcfea1d6 tests: add scheduler policy tests
Add test_scheduler.py to test process scheduler configuration in
src/libcrun/scheduler.c.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:56 +01:00
Giuseppe Scrivano
1404ccaa83 tests: add terminal tests for coverage
Add tests for src/libcrun/terminal.c:

C unit tests (tests_libcrun_terminal.c) using isolated pty:
- test_cleanup_terminalp_null: NULL cleanup should not crash
- test_terminal_setup_size_invalid_fd: Invalid fd error handling
- test_terminal_setup_size_pty: Set size on isolated pty
- test_set_raw_invalid_fd: Invalid fd error handling
- test_set_raw_pty: Set raw mode on isolated pty
- test_set_raw_no_status: Set raw without saving status
- test_new_terminal: Verify pty creation

Add test_terminal.py to test terminal allocation code in
src/libcrun/terminal.c.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:55 +01:00
Giuseppe Scrivano
6a3fdc16dc tests: add command tests for pause, unpause, kill, list, ps, spec
Add test_commands.py with tests targeting CLI commands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:55 +01:00
Giuseppe Scrivano
ec0f5cf84f tests: add network device tests for coverage
Add test_net_device.py with tests targeting net_device.c.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:55 +01:00
Giuseppe Scrivano
360406d749 tests: add cgroup resources tests for coverage
Add test_cgroup_resources.py with tests targeting cgroup-resources.c.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:55 +01:00
Giuseppe Scrivano
06541b6997 tests: add multi-environment coverage script
Add run_coverage_multi_env.sh that runs the test suite in multiple
environments to maximize code coverage:

1. Root with cgroupfs cgroup manager
2. Root with systemd cgroup manager (if available)
3. User namespace via unshare --user --map-root-user
4. Non-root user via unshare --user --map-user=1000

Coverage data accumulates across all runs since lcov merges .gcda
files automatically. This helps exercise code paths that are only
reachable under specific conditions (rootless, systemd, etc.).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:55 +01:00
Giuseppe Scrivano
f9385a6cd5 tests: remove unused Makefile
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-22 08:10:55 +01:00
Giuseppe Scrivano
4798015e7b build: add tests coverage
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-12-12 14:31:18 +01:00
Giuseppe Scrivano
2e86c95ab5 src: move syscall wrappers to new file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-11-18 12:54:31 +01:00
Fabio M. Di Nitto
6ead513009 linux: add support for numa set_mempolicy(2)
Closes: https://github.com/containers/crun/issues/1844

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2025-09-09 11:16:25 +02:00
Giuseppe Scrivano
13d4770d88 contrib: format contrib files
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-08-29 09:42:27 +02:00
Fabio M. Di Nitto
eb9912e06e build: add check for static builds
tests/init needs glibc-static (or equivalent) available to run
the test suite.

update configure.ac to check for libtool ability to link statically

update Makefile.am to build tests only if static linking is available

update rpm/crun.spec to BuildRequires glibc-static

update tests/*/Dockerfile to include glibc-static

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2025-08-06 11:16:19 +02:00
Kir Kolyshkin
ad9f90b7df tests: add test_bpf_devices
This is a basic test for the functionality added by a few previous
commits. It does not test that device bpf program work as it should,
merely that it is installed.

Co-authored-by: Claude Sonnet 4
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-07-09 10:55:22 -07:00
Erik Sjölund
cfcb839a2a run, create: deduplicate code
Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2025-06-03 18:13:26 +02:00
Giuseppe Scrivano
ba0ec5a7a9 linux: add support for network devices
https://github.com/opencontainers/runtime-spec/pull/1271 added support
for moving existing network devices to the container network
namespace.

Closes: https://github.com/containers/crun/issues/1712

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-05-21 12:34:03 +02:00
Kir Kolyshkin
739a2bffa1 build-aux/release.sh: fix shellcheck warnings
Too many to mention, but most are:

> SC2086 (info): Double quote to prevent globbing and word splitting

Use bash arrays where it make sense, and move the repeated stuff into
the BUILD_CMD.

PS I tried to make it more readable, but in some places with all the
added quotes it might actually become worse, so feel free to drop this
commit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-24 16:46:36 -07:00
Kir Kolyshkin
5c14c0dc1b make shellcheck: add more files
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-24 16:46:36 -07:00
Giuseppe Scrivano
b5a566bf01 crun: expose mounts command
add a new CLI command "crun mounts add|remove $CTR $FILE" to alter the
mounts of a running container.

The "crun mounts add" command adds the mounts specified in the $FILE
file to the mount namespace of the container process.

Differently, "crun mounts remove" can be used to remove a set of
mounts from the container mount namespace.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-04-02 14:20:02 +02:00
Giuseppe Scrivano
51fa411b0b libcrun: move annotations handling to a separate struct
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-02-13 11:27:55 +01:00
Giuseppe Scrivano
e50e47ca90 libcrun: add ring buffer implementation
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-12-16 13:58:26 +01:00
Giuseppe Scrivano
ca39d7c43b Merge pull request #1619 from jpalus/no-tests-normal-build
build: don't compile tests during normal build
2024-12-09 14:42:47 +01:00
Jan Palus
6b2e6193a9 build: use libtool to create libcrun_testing
static library is supposed to be archive of object files. if libtool is
not used libcrun_testing.a includes raw libocispec.la file instead of
its object files.

Signed-off-by: Jan Palus <jpalus@fastmail.com>
2024-12-08 16:43:13 +01:00
Jan Palus
3c5292b270 build: don't compile tests during normal build
Signed-off-by: Jan Palus <jpalus@fastmail.com>
2024-12-08 16:42:29 +01:00
Giuseppe Scrivano
b243185136 Merge pull request #1610 from usiegl00/wamr_support
wasm: add support for wamr (wasm-micro-runtime)
2024-12-06 10:40:50 +01:00
Maciej
b366a78574 wamr: revitalize wamr handler
Signed-off-by: usiegl00 <50933431+usiegl00@users.noreply.github.com>
2024-12-06 11:08:31 +09:00
Derzsi Dániel
5d66b30967 build: Don't build cloned_binary as part of crun
Signed-off-by: Derzsi Dániel <daniel@tohka.us>
2024-11-28 12:45:52 +02:00
Giuseppe Scrivano
3b40d77322 build: specify --extra-experimental-features to nix
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-10-07 16:08:08 +02:00
Giuseppe Scrivano
0f556b7c31 build: force install symlinks
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-09-05 15:42:03 +05:30
Giuseppe Scrivano
fd745e0965 dist: install symlinks as part of make install
Closes: https://github.com/containers/crun/issues/1468

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-05-29 16:08:26 +02:00
Giuseppe Scrivano
3873541e18 build: embed blake3 hashing function
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-19 16:43:55 +01:00
Sven Pfennig
616aea7255 feat: add spin handler
Signed-off-by: Sven Pfennig <s.pfennig@reply.de>
2023-11-14 14:07:53 +01:00
Giuseppe Scrivano
52d5faa7b0 libcrun: add Intel RDT support functions
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-11 11:02:31 +02:00
Sascha Grunert
64105d96f7 Use overlay and single nix derivation
Deduplicate code and cleanup the nix derivation based on the input.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2023-09-29 12:32:16 +02:00
Giuseppe Scrivano
fe4e15d384 build: install krun.1 only if krun is enabled
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-26 19:00:22 +02:00
Daniel J Walsh
c9a1a127d7 Add man page for krun
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-09-09 04:05:13 -04:00
Rubicon Rowe
46ef792a4c lua: fixed luarocks package directory structure
Signed-off-by: Rubicon Rowe <l1589002388@gmail.com>
2023-08-30 21:34:59 +08:00