Skip to content

refact mount_recursive test#3383

Merged
utam0k merged 1 commit intoyouki-dev:mainfrom
saku3:chore/refact-mounts_recursive-test
Feb 6, 2026
Merged

refact mount_recursive test#3383
utam0k merged 1 commit intoyouki-dev:mainfrom
saku3:chore/refact-mounts_recursive-test

Conversation

@saku3
Copy link
Copy Markdown
Member

@saku3 saku3 commented Feb 1, 2026

Description

I refactored the integration tests for mounts_recursive.

I consolidated the common setup, execution, and teardown into a single helper function—creating the base directory and subdirectory, setting up the mounts, running test_inside_container, and cleaning everything up—so the tests can reuse the same flow.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test updates
  • CI/CD related changes
  • Other (please describe):

Testing

  • Added new unit tests
  • Added new integration tests
  • Ran existing test suite
  • Tested manually (please provide steps)

Related Issues

Fixes #1698

Additional Context

@saku3 saku3 added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Feb 1, 2026
Copy link
Copy Markdown
Contributor

@nayuta723 nayuta723 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor nitpicks, but I've left a couple of comments.

Comment on lines +105 to +111
// Helper for mounts_recursive tests.
// - `mount_options`: OCI mount options (e.g. ["rbind", "rro"]).
// - `process_args`: If `None`, uses the default ["runtimetest", "mounts_recursive"].
// - `setup_extra(bundle, dir, subdir)`: Hook to perform additional host-side setup before starting the container.
// - `bundle_path`: Bundle root (e.g. used to copy files from bundle/bin).
// - `dir_path`: Host directory that will be mounted at /mnt.
// - `subdir_path`: Host directory that will be mounted /mnt/mount_subdir.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Helper for mounts_recursive tests.
// - `mount_options`: OCI mount options (e.g. ["rbind", "rro"]).
// - `process_args`: If `None`, uses the default ["runtimetest", "mounts_recursive"].
// - `setup_extra(bundle, dir, subdir)`: Hook to perform additional host-side setup before starting the container.
// - `bundle_path`: Bundle root (e.g. used to copy files from bundle/bin).
// - `dir_path`: Host directory that will be mounted at /mnt.
// - `subdir_path`: Host directory that will be mounted /mnt/mount_subdir.
// Helper for mounts_recursive tests.
// - `mount_options`: OCI mount options (e.g. ["rbind", "rro"]).
// - `process_args`: If `None`, uses the default ["runtimetest", "mounts_recursive"].
// - `setup_extra`: Hook to perform additional host-side setup before starting the container.
// It takes three parameters:
// - `bundle_path`: Bundle root (e.g. used to copy files from bundle/bin).
// - `dir_path`: Host directory that will be mounted at /mnt.
// - `subdir_path`: Host subdirectory that will be mounted at /mnt/mount_subdir.

Comment on lines +156 to +168
// Mount Recursive test
// Host:
// - <tmp>/<test>_dir is a mount point (tmpfs)
// - <tmp>/<test>_dir/<test>_subdir is a submount (tmpfs)
//
// rbind:
// - Bind-mount <tmp>/<test>_dir into the container at /mnt (rbind)
//
// In the container, we should observe:
// - mount at /mnt
// - submount at /mnt/<test>_subdir
//
// Key check: the mount options/attributes must be applied to SUBMOUNTS.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Mount Recursive test
// Host:
// - <tmp>/<test>_dir is a mount point (tmpfs)
// - <tmp>/<test>_dir/<test>_subdir is a submount (tmpfs)
//
// rbind:
// - Bind-mount <tmp>/<test>_dir into the container at /mnt (rbind)
//
// In the container, we should observe:
// - mount at /mnt
// - submount at /mnt/<test>_subdir
//
// Key check: the mount options/attributes must be applied to SUBMOUNTS.
// Mount Recursive test
// Host:
// - <tmp>/mount_dir is a mount point (tmpfs)
// - <tmp>/mount_dir/mount_subdir is a submount (tmpfs)
//
// rbind:
// - Bind-mount <tmp>/mount_dir into the container at /mnt (rbind)
//
// In the container, we should observe:
// - mount at /mnt
// - submount at /mnt/mount_subdir
//
// Key check: the mount options/attributes must be applied to SUBMOUNTS.

let rnosuid_dir_path = rnosuid_test_base_dir.path().join("rnosuid_dir");
let rnosuid_subdir_path = rnosuid_dir_path.join("rnosuid_subdir");
let mount_options = vec!["rbind".to_string(), "rnosuid".to_string()];
let mount_dest_path = PathBuf::from_str("/mnt").unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest defining /mnt as a constant, as it's currently redefined in both check_recursive and each test. This would help keep the code clean and consistent.

Comment thread tests/contest/runtimetest/src/tests.rs Outdated
}
"rdev" => {
let device_path = mount.destination().join("rdev_subdir/null");
let device_path = mount.destination().join("mount_subdir/null");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let device_path = mount.destination().join("mount_subdir/null");
let device_path = subdir_path.join("null");

@saku3 saku3 force-pushed the chore/refact-mounts_recursive-test branch from d6bba94 to 37c8d79 Compare February 1, 2026 22:19
Signed-off-by: Yusuke Sakurai <yusuke.sakurai@3-shake.com>
@saku3 saku3 force-pushed the chore/refact-mounts_recursive-test branch from 37c8d79 to 06b2d6f Compare February 1, 2026 22:23
@saku3 saku3 requested a review from nayuta723 February 1, 2026 22:30
@saku3
Copy link
Copy Markdown
Member Author

saku3 commented Feb 1, 2026

@nayuta723
Thanks for the review.

I’ve made the changes you suggested.

Copy link
Copy Markdown
Contributor

@nayuta723 nayuta723 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks!

@saku3
Copy link
Copy Markdown
Member Author

saku3 commented Feb 2, 2026

Since this is only a test refactor, I plan to merge it later this week unless anyone has further comments. @youki-dev/youki

Copy link
Copy Markdown
Member

@utam0k utam0k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@utam0k utam0k merged commit 9cb4692 into youki-dev:main Feb 6, 2026
28 checks passed
@github-actions github-actions bot mentioned this pull request Feb 6, 2026
sat0ken pushed a commit to sat0ken/youki that referenced this pull request Mar 17, 2026
Signed-off-by: Yusuke Sakurai <yusuke.sakurai@3-shake.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactoring test in the recursive mount

3 participants