expect remove and unlink to set errno when file doesn't exist, reduce misleading spam.

This commit is contained in:
Enno Rehling 2016-09-11 17:19:27 +02:00
parent 03a8e0449a
commit 95481211e5
3 changed files with 10 additions and 3 deletions

View File

@ -22,6 +22,7 @@
#include <tests.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
static const struct race * race_with_flag(const char * name) {
char data[1024];
@ -445,7 +446,9 @@ static void test_configs(CuTest * tc)
CuAssertPtrEquals(tc, 0, buildingtypes);
json_config(json);
CuAssertPtrNotNull(tc, buildingtypes);
unlink("test.json");
if (unlink("test.json")!=0 && errno==ENOENT) {
errno = 0;
}
cJSON_Delete(json);
test_cleanup();
}

View File

@ -1877,7 +1877,11 @@ int writegame(const char *filename)
join_path(datapath(), filename, path, sizeof(path));
#ifdef HAVE_UNISTD_H
/* make sure we don't overwrite an existing file (hard links) */
unlink(path);
if (unlink(path)!=0) {
if (errno==ENOENT) {
errno = 0;
}
}
#endif
F = fopen(path, "wb");
if (!F) {

View File

@ -36,7 +36,7 @@ VALGRIND=`which valgrind`
SERVER=../Debug/eressea/eressea
if [ -n "$VALGRIND" ]; then
SUPP=../share/ubuntu-12_04.supp
SERVER="$VALGRIND --track-origins=yes --gen-suppressions=all --suppressions=$SUPP --error-exitcode=1 --leak-check=no $SERVER"
SERVER="$VALGRIND --track-origins=yes --gen-suppressions=all --suppressions=$SUPP --error-exitcode=1 --leak-check=full $SERVER"
fi
echo "running $SERVER"
$SERVER -t 184 test-turn.lua