tmpfile: improve error message
* spot/misc/tmpfile.cc: Display strerror(errno) plus some suggestions that depend on the error. Based on a report from Shengping Shaw. * THANKS: Add reporter. * tests/core/ltlcross5.test: New file. * tests/Makefile.am: Add it.
This commit is contained in:
parent
a06e547473
commit
d2ba554507
4 changed files with 91 additions and 2 deletions
1
THANKS
1
THANKS
|
|
@ -42,6 +42,7 @@ Reuben Rowe
|
||||||
Rüdiger Ehlers
|
Rüdiger Ehlers
|
||||||
Silien Hong
|
Silien Hong
|
||||||
Simon Jantsch
|
Simon Jantsch
|
||||||
|
Shengping Shaw
|
||||||
Shufang Zhu
|
Shufang Zhu
|
||||||
Sonali Dutta
|
Sonali Dutta
|
||||||
Tereza Šťastná
|
Tereza Šťastná
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2013, 2015, 2017, 2018 Laboratoire de Recherche et
|
// Copyright (C) 2013, 2015, 2017-2019 Laboratoire de Recherche et
|
||||||
// Développement de l'Epita (LRDE).
|
// Développement de l'Epita (LRDE).
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
|
|
@ -75,7 +75,29 @@ namespace spot
|
||||||
fd = mkstemp(*name);
|
fd = mkstemp(*name);
|
||||||
}
|
}
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
throw std::runtime_error("failed to create "s + *name);
|
{
|
||||||
|
std::string err = ("failed to create temporary file "s + *name
|
||||||
|
+ ": " + strerror(errno));
|
||||||
|
if (errno == EACCES)
|
||||||
|
{
|
||||||
|
if (tmpdir)
|
||||||
|
err += ("\nConsider setting the SPOT_TMPDIR environment "
|
||||||
|
"variable to a writable directory.");
|
||||||
|
else
|
||||||
|
err += ("\nConsider executing this from a writable "
|
||||||
|
"directory, or setting\nthe SPOT_TMPDIR environment "
|
||||||
|
"variable to such a directory.");
|
||||||
|
}
|
||||||
|
else if (tmpdir)
|
||||||
|
{
|
||||||
|
const char* dir =
|
||||||
|
secure_getenv("SPOT_TMPDIR") ? "SPOT_TMPDIR" : "TMPDIR";
|
||||||
|
err += ("\nNote that the directory comes from the "s
|
||||||
|
+ dir
|
||||||
|
+ " environment variable.");
|
||||||
|
}
|
||||||
|
throw std::runtime_error(err);
|
||||||
|
}
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,7 @@ TESTS_twa = \
|
||||||
core/bdddict.test \
|
core/bdddict.test \
|
||||||
core/alternating.test \
|
core/alternating.test \
|
||||||
core/ltlcross3.test \
|
core/ltlcross3.test \
|
||||||
|
core/ltlcross5.test \
|
||||||
core/taatgba.test \
|
core/taatgba.test \
|
||||||
core/renault.test \
|
core/renault.test \
|
||||||
core/nondet.test \
|
core/nondet.test \
|
||||||
|
|
|
||||||
65
tests/core/ltlcross5.test
Normal file
65
tests/core/ltlcross5.test
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2019 Laboratoire de Recherche et Développement de
|
||||||
|
# l'Epita (LRDE).
|
||||||
|
#
|
||||||
|
# This file is part of Spot, a model checking library.
|
||||||
|
#
|
||||||
|
# Spot is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Spot is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
# License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
. ./defs
|
||||||
|
set -e
|
||||||
|
|
||||||
|
unset TMPDIR
|
||||||
|
unset SPOT_TMPDIR
|
||||||
|
|
||||||
|
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.
|
||||||
|
cd ..
|
||||||
|
rm -rf foo
|
||||||
|
exit 77
|
||||||
|
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 'SPOT_TMPDIR' err || err=1
|
||||||
|
|
||||||
|
SPOT_TMPDIR=foo ltlcross ltl2tgba -f GFa 2>err && err=2
|
||||||
|
cat err
|
||||||
|
grep 'failed to create temporary file' err || err=2
|
||||||
|
grep 'executing this from a writable' err && err=2
|
||||||
|
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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue