Skip to content

Commit

Permalink
test: use the glib function for a tmpdir in $TMP
Browse files Browse the repository at this point in the history
mkdtmp() creates the directory in $PWD, let's use the glib function to create
it in $TMP instead. With mkdtmp() running ninja test can sometimes fail due to
a race contion: our pytest invocation collects all files in the current
directory, the dbverify test creates files that may be removed before pytest
gets to actually open them.

Signed-off-by: Peter Hutterer <[email protected]>
  • Loading branch information
whot committed Apr 28, 2021
1 parent 94a5a93 commit 34e11c4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test/test-dbverify.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,8 @@ int main(int argc, char **argv)

db = load_database();

dirname = strdup("tmp.dbverify.XXXXXX");
g_assert(mkdtemp(dirname)); /* just check for non-null to avoid
Coverity complaints */
dirname = g_dir_make_tmp("tmp.dbverify.XXXXXX", NULL);
g_assert(dirname);

duplicate_database(db, dirname);
db_new = libwacom_database_new_for_path(dirname);
Expand All @@ -255,7 +254,7 @@ int main(int argc, char **argv)
libwacom_database_destroy(db_old);

rmtmpdir(dirname);
free(dirname);
g_free(dirname);

return rc;
}
Expand Down

0 comments on commit 34e11c4

Please sign in to comment.