tests: pass the subiquity commands directly without sh -c ''

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2022-04-19 14:27:11 +02:00
parent 3f07ca1b1b
commit 5d3e0b4675
1 changed files with 37 additions and 13 deletions

View File

@ -148,12 +148,20 @@ for answers in examples/answers*.yaml; do
config=examples/simple.json config=examples/simple.json
fi fi
serial=$(sed -n 's/^#serial/x/p' $answers || true) serial=$(sed -n 's/^#serial/x/p' $answers || true)
opts='' opts=()
if [ -n "$serial" ]; then if [ -n "$serial" ]; then
opts='--serial' opts+=(--serial)
fi fi
# The --foreground is important to avoid subiquity getting SIGTTOU-ed. # The --foreground is important to avoid subiquity getting SIGTTOU-ed.
timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m subiquity.cmd.tui --bootloader uefi --answers $answers --dry-run --snaps-from-examples --machine-config $config --output-base $tmpdir $opts" < $tty LANG=C.UTF-8 timeout --foreground 60 \
python3 -m subiquity.cmd.tui < "$tty" \
--bootloader uefi \
--answers "$answers" \
--dry-run \
--snaps-from-examples \
--machine-config "$config" \
--output-base "$tmpdir" \
"${opts[@]}"
validate validate
grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log
else else
@ -166,18 +174,26 @@ for answers in examples/answers*.yaml; do
reconf_settings="true" reconf_settings="true"
validate_subtype="answers-reconf" validate_subtype="answers-reconf"
fi fi
timeout --foreground 60 sh -c "DRYRUN_RECONFIG=$reconf_settings LANG=C.UTF-8 python3 -m system_setup.cmd.tui --answers $answers --output-base $tmpdir --dry-run " < $tty DRYRUN_RECONFIG="$reconf_settings" LANG=C.UTF-8 timeout --foreground 60 \
python3 -m system_setup.cmd.tui < "$tty" \
--answers "$answers" \
--output-base "$tmpdir" \
--dry-run
validate "system_setup" "$validate_subtype" validate "system_setup" "$validate_subtype"
fi fi
fi fi
clean clean
done done
timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m subiquity.cmd.tui --autoinstall examples/autoinstall.yaml \ LANG=C.UTF-8 timeout --foreground 60 \
--dry-run --machine-config examples/existing-partitions.json --bootloader bios \ python3 -m subiquity.cmd.tui \
--kernel-cmdline 'autoinstall' \ --autoinstall examples/autoinstall.yaml \
--output-base $tmpdir \ --dry-run \
--source-catalog=examples/install-sources.yaml" --machine-config examples/existing-partitions.json \
--bootloader bios \
--kernel-cmdline autoinstall \
--output-base "$tmpdir" \
--source-catalog=examples/install-sources.yaml
validate validate
python3 scripts/check-yaml-fields.py $tmpdir/var/log/installer/subiquity-curtin-apt.conf \ python3 scripts/check-yaml-fields.py $tmpdir/var/log/installer/subiquity-curtin-apt.conf \
apt.disable_components='[non-free, restricted]' \ apt.disable_components='[non-free, restricted]' \
@ -202,9 +218,13 @@ grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades:
$tmpdir/subiquity-server-debug.log $tmpdir/subiquity-server-debug.log
clean clean
timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m subiquity.cmd.tui --autoinstall examples/autoinstall-user-data.yaml \ LANG=C.UTF-8 timeout --foreground 60 \
--output-base $tmpdir \ python3 -m subiquity.cmd.tui \
--dry-run --machine-config examples/simple.json --kernel-cmdline 'autoinstall'" --autoinstall examples/autoinstall-user-data.yaml \
--output-base "$tmpdir" \
--dry-run \
--machine-config examples/simple.json \
--kernel-cmdline autoinstall
validate validate
grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log
@ -212,7 +232,11 @@ grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades:
if [ "${RELEASE%.*}" -ge 20 ]; then if [ "${RELEASE%.*}" -ge 20 ]; then
for mode in "" "-full" "-no-shutdown"; do for mode in "" "-full" "-no-shutdown"; do
clean clean
timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m system_setup.cmd.tui --autoinstall examples/autoinstall-system-setup${mode}.yaml --output-base $tmpdir --dry-run" LANG=C.UTF-8 timeout --foreground 60 \
python3 -m system_setup.cmd.tui \
--autoinstall "examples/autoinstall-system-setup${mode}.yaml" \
--output-base "$tmpdir" \
--dry-run
validate "system_setup" "autoinstall${mode}" validate "system_setup" "autoinstall${mode}"
done done