mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
test: add a helper function for making tempfiles
Having a helper aids with the file being in the right directory and cleaned up automatically on exit. Plus, failing the test with the sytem error status code signals that it's not the actual test failing here.
This commit is contained in:
parent
dd3f14d9d6
commit
dc5751b569
2 changed files with 27 additions and 0 deletions
|
|
@ -381,6 +381,21 @@ pwtest_spa_plugin_load_interface(struct pwtest_spa_plugin *plugin,
|
|||
return iface;
|
||||
}
|
||||
|
||||
void
|
||||
pwtest_mkstemp(char path[PATH_MAX])
|
||||
{
|
||||
const char *tmpdir = getenv("TMPDIR");
|
||||
int r;
|
||||
|
||||
if (tmpdir == NULL)
|
||||
pwtest_error_with_msg("tmpdir is unset");
|
||||
|
||||
spa_scnprintf(path, PATH_MAX, "%s/%s", tmpdir, "tmp.XXXXXX");
|
||||
r = mkstemp(path);
|
||||
if (r == -1)
|
||||
pwtest_error_with_msg("Unable to create temporary file: %s", strerror(errno));
|
||||
}
|
||||
|
||||
void _pwtest_add(struct pwtest_context *ctx, struct pwtest_suite *suite,
|
||||
const char *funcname, const void *func, ...)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue