Skip to content

Commit

Permalink
Add zstd to tester_linux (#198)
Browse files Browse the repository at this point in the history
* Add `--run-as-root` arg to `test_rootfs.jl`

This allows us to easily run as `root` within the testing harness, for
testing of `apt install` and such within the rootfs.

* Add `zstd` to `tester_linux`

I want to compress core dump files, so let's add `zstd` to our testing
rootfs images.
  • Loading branch information
staticfloat authored Jun 7, 2022
1 parent 85817eb commit bdaf127
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions linux/tester_linux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ packages = [
"make",
"procps",
"vim",
"zstd",
]

artifact_hash, tarball_path, = debootstrap(arch, image; archive, packages)
Expand Down
7 changes: 7 additions & 0 deletions src/test_img/args.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ function parse_test_args(args::AbstractVector, file::AbstractString)
required = false
default = ""
help = "Tree hash of the rootfs image."
"--run-as-root", "-r"
arg_type = Bool
required = false
default = false
help = "Run as root within sandbox."
"command"
required = false
default = Any[]
Expand All @@ -61,6 +66,7 @@ function parse_test_args(args::AbstractVector, file::AbstractString)

mount_julia = parsed_args["mount-julia"]::Bool
override_tmp_dir = parsed_args["override-tmp-dir"]::Bool
run_as_root = parsed_args["run-as-root"]::Bool

map_build_dir = _process_required_string_arg( parsed_args, "map-build-dir")
tmpfs_size = _process_required_string_arg( parsed_args, "tmpfs-size")
Expand Down Expand Up @@ -113,6 +119,7 @@ function parse_test_args(args::AbstractVector, file::AbstractString)
treehash,
url,
working_dir,
run_as_root,
)

return result
Expand Down
14 changes: 11 additions & 3 deletions test_rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tmpfs_size = args.tmpfs_size
treehash = args.treehash
url = args.url
working_dir = args.working_dir
run_as_root = args.run_as_root

# If the artifact is not locally existent, download it
ensure_artifact_exists_locally(; treehash, url)
Expand All @@ -34,6 +35,13 @@ environment_variables["PATH"] = join(path_list, ":")
environment_variables["HOME"] = "/home/juliaci"
environment_variables["USER"] = "juliaci"

uid = Sandbox.getuid()
gid = Sandbox.getgid()
if run_as_root
uid = 0
gid = 0
end

config = SandboxConfig(
read_only_maps,
read_write_maps,
Expand All @@ -43,9 +51,9 @@ config = SandboxConfig(
stderr,
multiarch,
tmpfs_size,
pwd = working_dir,
uid = Sandbox.getuid(),
gid = Sandbox.getgid(),
uid,
gid,
pwd = working_dir,
)

with_executor() do exe
Expand Down

0 comments on commit bdaf127

Please sign in to comment.