From 95e3bb815c79b0296097c56e34b27905f98f8472 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 27 Jul 2023 10:23:33 +0200 Subject: [PATCH] bin: cover more tmpfile failure when running as root * tests/core/ltlcross5.test: reorganize to test missing directory before permission issues, as the latter cannot be run as root. --- tests/core/ltlcross5.test | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/core/ltlcross5.test b/tests/core/ltlcross5.test index 82e9fdc89..c89a7bd0b 100644 --- a/tests/core/ltlcross5.test +++ b/tests/core/ltlcross5.test @@ -1,6 +1,6 @@ #!/bin/sh # -*- coding: utf-8 -*- -# Copyright (C) 2019 Laboratoire de Recherche et Développement de +# Copyright (C) 2019, 2023 Laboratoire de Recherche et Développement de # l'Epita (LRDE). # # This file is part of Spot, a model checking library. @@ -24,10 +24,22 @@ set -e unset TMPDIR unset SPOT_TMPDIR +err=0 + +SPOT_TMPDIR=bar ltlcross ltl2tgba -f GFa 2>err && err=1 +cat err +grep 'failed to create temporary file' err +grep 'Note that the directory.*SPOT_TMPDIR ' err + +TMPDIR=bar ltlcross ltl2tgba -f GFa 2>err && err=2 +cat err +grep 'failed to create temporary file' err +grep 'Note that the directory.* TMPDIR ' err + + mkdir foo chmod a-w foo cd foo -err=0 if touch bar; then # We are likely running as root, so we cannot detect permission # issues. @@ -39,27 +51,17 @@ fi ltlcross ltl2tgba -f GFa 2>../err && err=1 cd .. cat err -grep 'failed to create temporary file' err || err=1 -grep 'executing this from a writable' err || err=1 +grep 'failed to create temporary file' err || err=3 +grep 'executing this from a writable' err || err=3 grep 'SPOT_TMPDIR' err || err=1 -SPOT_TMPDIR=foo ltlcross ltl2tgba -f GFa 2>err && err=2 +SPOT_TMPDIR=foo ltlcross ltl2tgba -f GFa 2>err && err=4 cat err -grep 'failed to create temporary file' err || err=2 -grep 'executing this from a writable' err && err=2 +grep 'failed to create temporary file' err || err=4 +grep 'executing this from a writable' err && err=4 grep 'SPOT_TMPDIR' err chmod a+w foo rmdir foo -SPOT_TMPDIR=bar ltlcross ltl2tgba -f GFa 2>err && err=3 -cat err -grep 'failed to create temporary file' err -grep 'Note that the directory.*SPOT_TMPDIR ' err - -TMPDIR=bar ltlcross ltl2tgba -f GFa 2>err && err=4 -cat err -grep 'failed to create temporary file' err -grep 'Note that the directory.* TMPDIR ' err - exit $err