-
Notifications
You must be signed in to change notification settings - Fork 60
ch-test
: build and unpack image only
#1899
base: master
Are you sure you want to change the base?
Changes from 12 commits
c53afe2
869d959
b6fab91
ec10512
91dd4fd
a09280c
24fb9c5
34099db
3d65706
ea823c0
3853630
6617570
17ae0bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,8 @@ EOF | |
|
||
bats_vmin=1.2.0 # FIXME: get from configure somehow? | ||
|
||
ch_build_unpack_all="argenv quick copy almalinux_8ch debian_11ch hello multistage seccomp" | ||
|
||
|
||
### Functions | ||
|
||
|
@@ -197,6 +199,9 @@ dir_tar_check_file () { | |
for f in "$@"; do | ||
if [[ -f ${CH_TEST_TARDIR}/${f} ]]; then | ||
return 0 | ||
elif [[ "$f" == *"chtest"* ]] && [[ -n "$ch_build_unpack_list" ]]; then | ||
# chtest not needed for build-unpack phase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not true — why treat |
||
return 0 | ||
else | ||
missing+=("${CH_TEST_TARDIR}/${f}") | ||
fi | ||
|
@@ -398,7 +403,7 @@ test_make () { | |
local tag | ||
printf "finding tests compatible with %s phase settings ...\n" "$phase" | ||
case $phase in | ||
build|build-images) | ||
build|build-images|build-unpack) | ||
for i in $images $examples; do | ||
if test_make_check_image "$i"; then | ||
echo "found: $i" | ||
|
@@ -461,7 +466,7 @@ test_make () { | |
} | ||
|
||
test_make_auto () { | ||
local mode | ||
local mode # mode is the test phase | ||
mode=$1;shift | ||
if [[ $mode != tag ]]; then | ||
printf "# Do not edit this file; it's autogenerated\n\n" | ||
|
@@ -495,7 +500,7 @@ test_make_auto () { | |
fatal "test_make_auto: unknown build type" | ||
;; | ||
esac | ||
elif [[ $mode == run ]];then | ||
elif [[ $mode == run || $mode == build-unpack ]];then | ||
test_make_template_print 'unpack.bats.in' | ||
else | ||
fatal "test_make_auto: invalid mode '$mode'" | ||
|
@@ -669,6 +674,17 @@ test_one_file () { | |
bats "$one_file" | ||
} | ||
|
||
test_build_unpack () { | ||
case $phase in | ||
build) | ||
bats "${TMP_}/build_auto.bats" | ||
;; | ||
run) | ||
bats "${TMP_}/run_auto.bats" | ||
;; | ||
esac | ||
} | ||
|
||
test_rootemu () { | ||
if command -v ch-image > /dev/null 2>&1; then | ||
bats force-auto.bats | ||
|
@@ -816,10 +832,11 @@ fi | |
if [[ $# == 0 ]]; then | ||
usage 1 | ||
fi | ||
ch_build_unpack_list="" | ||
while [[ $# -gt 0 ]]; do | ||
opt=$1; shift | ||
case $opt in | ||
all|build|build-images|clean|examples|mk-perm-dirs|rm-perm-dirs|rootemu|run) | ||
all|build|build-images|build-unpack|clean|examples|mk-perm-dirs|rm-perm-dirs|rootemu|run) | ||
require_unset phase | ||
phase=$opt | ||
;; | ||
|
@@ -855,6 +872,11 @@ while [[ $# -gt 0 ]]; do | |
-h|--help) | ||
usage 0 | ||
;; | ||
-i) | ||
phase=build-unpack | ||
ch_build_unpack_list+=" $1" | ||
shift | ||
;; | ||
--img-dir) | ||
require_unset imgdir | ||
imgdir=$1; shift | ||
|
@@ -945,6 +967,8 @@ while [[ $# -gt 0 ]]; do | |
esac | ||
done | ||
|
||
export ch_build_unpack_list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Subprocesses won't need this; are you sure it needs to be exported? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's my understanding that the |
||
|
||
printf 'ch-run: %s (%s)\n' "${ch_bin}/ch-run" "$ch_libc" | ||
printf 'bats: %s (%s)\n' "$bats" "$bats_version" | ||
if [[ $(printf "%s\n%s" "$bats_version" "$bats_vmin" | sort -V | head -1) \ | ||
|
@@ -978,7 +1002,7 @@ if [[ $phase = one-file ]]; then | |
fi | ||
|
||
printf "%-21s %s" 'phase:' "$phase" | ||
if [[ $phase = one-file ]]; then | ||
if [[ $phase = one-file || $phase = build-unpack ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if there's a reasonable way to make one-file interact with build-unpack. That is, rather than listing images with |
||
printf ': %s (%s)' "$one_file" "$ch_one_test" | ||
fi | ||
if [[ -z $phase ]]; then | ||
|
@@ -1168,6 +1192,24 @@ case $phase in | |
test_build | ||
win | ||
;; | ||
build-unpack) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if rather than making build-unpack a phase, could it be a modifier on build and run? Or, perhaps there's a new phase |
||
if [[ -z "$ch_build_unpack_list" ]]; then | ||
# Assume “build-unpack” was specified without “-i” being called, | ||
# build and upack all images. | ||
ch_build_unpack_list="$ch_build_unpack_all" | ||
fi | ||
phase=build | ||
dir_tar_mk | ||
builder_check | ||
test_make | ||
test_build_unpack | ||
|
||
phase=run | ||
dir_img_mk | ||
dir_tar_check | ||
test_make | ||
test_build_unpack | ||
;; | ||
clean) | ||
dirs_unpriv_rm | ||
if [[ -d $TMP_ ]] && [[ -e $TMP_/build_auto.bats ]]; then | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should derive this list from the tests we actually have; it should also be responsive to
--scope
.