mirror of
https://github.com/linux-msm/qdl.git
synced 2026-10-07 06:29:17 -07:00
Introduce two initial set of test cases for the newly introduced contents.xml handling. One is used to validate the storage and flavor selector logic, and the other more broadly the loading of contents.xml files. Extract the common operation of creating a temporary directory to a new file that is shared across tests. Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
32 lines
667 B
C
32 lines
667 B
C
// SPDX-License-Identifier: BSD-3-Clause
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
|
|
#include "common.h"
|
|
|
|
int test_make_temp_dir(char *buf, size_t size, const char *prefix)
|
|
{
|
|
int ret;
|
|
|
|
#ifdef _WIN32
|
|
const char *tmp_base = getenv("TMPDIR");
|
|
|
|
if (!tmp_base || tmp_base[0] == '\0')
|
|
tmp_base = getenv("TEMP");
|
|
if (!tmp_base || tmp_base[0] == '\0')
|
|
tmp_base = getenv("TMP");
|
|
if (!tmp_base || tmp_base[0] == '\0')
|
|
tmp_base = ".";
|
|
|
|
ret = snprintf(buf, size, "%s/%s-XXXXXX", tmp_base, prefix);
|
|
#else
|
|
ret = snprintf(buf, size, "/tmp/%s-XXXXXX", prefix);
|
|
#endif
|
|
|
|
if (ret <= 0 || (size_t)ret >= size)
|
|
return -1;
|
|
|
|
return mkdtemp(buf) ? 0 : -1;
|
|
}
|