Skip to content

Commit

Permalink
tests: add test for shifting support
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Jul 18, 2018
1 parent 630ca28 commit 3a5c2c8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
3 changes: 3 additions & 0 deletions drivers/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,9 @@ func (d *Driver) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMapp

// SupportsShifting tells whether the driver support shifting of the UIDs/GIDs in an userNS
func (d *Driver) SupportsShifting() bool {
if os.Getenv("_TEST_FORCE_SUPPORT_SHIFTING") == "yes-please" {
return true
}
return d.options.mountProgram != ""
}

Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

STORAGE_BINARY=${STORAGE_BINARY:-$(dirname ${BASH_SOURCE})/../containers-storage}
TESTSDIR=${TESTSDIR:-$(dirname ${BASH_SOURCE})}
STORAGE_DRIVER=${STORAGE_DRIVER:-vfs}
STORAGE_DRIVER=${STORAGE_DRIVER:-overlay}
STORAGE_OPTION=${STORAGE_OPTION:-}
PATH=$(dirname ${BASH_SOURCE})/..:${PATH}

Expand Down
42 changes: 42 additions & 0 deletions tests/idmaps.bats
Original file line number Diff line number Diff line change
Expand Up @@ -753,3 +753,45 @@ load helpers
echo ntops:$ntops
[ $ntops -eq 1 ]
}

@test "idmaps-create-mapped-container-shifting" {
case "$STORAGE_DRIVER" in
overlay*)
;;
*)
skip "not supported by driver $STORAGE_DRIVER"
;;
esac

run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer="$output"
# Mount the layer.
run storage --debug=false mount $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
lowermount="$output"
# Put a file in the layer.
createrandom "$lowermount"/file
storage unmount $layer

imagename=idmappedimage-shifting
storage create-image --name=$imagename $layer

_TEST_FORCE_SUPPORT_SHIFTING=yes-please run storage --debug=false create-container --uidmap 0:1000:1000 --gidmap 0:1000:1000 $imagename
echo "$output"
[ "$status" -eq 0 ]
[ "$output" != "" ]

container="$output"

# Mount the container.
run storage --debug=false mount $container
echo "$output"
[ "$status" -eq 0 ]
dir="$output"
test -e "$(stat -c%u:%g $dir/file)" == "0:0"
run storage --debug=false unmount "$container"
[ "$status" -eq 0 ]
}

0 comments on commit 3a5c2c8

Please sign in to comment.