tests: Use g_mkdir_with_parents()
Use the same g_mkdir_with_parents() call to create a directory on all platforms. Signed-off-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20220824094029.1634519-13-bmeng.cn@gmail.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
3c239aa77e
commit
413bebc046
@ -232,7 +232,7 @@ static void stress(unsigned long long ramsizeGB, int ncpus)
|
|||||||
|
|
||||||
static int mount_misc(const char *fstype, const char *dir)
|
static int mount_misc(const char *fstype, const char *dir)
|
||||||
{
|
{
|
||||||
if (mkdir(dir, 0755) < 0 && errno != EEXIST) {
|
if (g_mkdir_with_parents(dir, 0755) < 0 && errno != EEXIST) {
|
||||||
fprintf(stderr, "%s (%05d): ERROR: cannot create %s: %s\n",
|
fprintf(stderr, "%s (%05d): ERROR: cannot create %s: %s\n",
|
||||||
argv0, gettid(), dir, strerror(errno));
|
argv0, gettid(), dir, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -761,14 +761,14 @@ test_migrate_tls_psk_start_common(QTestState *from,
|
|||||||
data->workdir = g_strdup_printf("%s/tlscredspsk0", tmpfs);
|
data->workdir = g_strdup_printf("%s/tlscredspsk0", tmpfs);
|
||||||
data->pskfile = g_strdup_printf("%s/%s", data->workdir,
|
data->pskfile = g_strdup_printf("%s/%s", data->workdir,
|
||||||
QCRYPTO_TLS_CREDS_PSKFILE);
|
QCRYPTO_TLS_CREDS_PSKFILE);
|
||||||
mkdir(data->workdir, 0700);
|
g_mkdir_with_parents(data->workdir, 0700);
|
||||||
test_tls_psk_init(data->pskfile);
|
test_tls_psk_init(data->pskfile);
|
||||||
|
|
||||||
if (mismatch) {
|
if (mismatch) {
|
||||||
data->workdiralt = g_strdup_printf("%s/tlscredspskalt0", tmpfs);
|
data->workdiralt = g_strdup_printf("%s/tlscredspskalt0", tmpfs);
|
||||||
data->pskfilealt = g_strdup_printf("%s/%s", data->workdiralt,
|
data->pskfilealt = g_strdup_printf("%s/%s", data->workdiralt,
|
||||||
QCRYPTO_TLS_CREDS_PSKFILE);
|
QCRYPTO_TLS_CREDS_PSKFILE);
|
||||||
mkdir(data->workdiralt, 0700);
|
g_mkdir_with_parents(data->workdiralt, 0700);
|
||||||
test_tls_psk_init_alt(data->pskfilealt);
|
test_tls_psk_init_alt(data->pskfilealt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -873,7 +873,7 @@ test_migrate_tls_x509_start_common(QTestState *from,
|
|||||||
data->clientcert = g_strdup_printf("%s/client-cert.pem", data->workdir);
|
data->clientcert = g_strdup_printf("%s/client-cert.pem", data->workdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir(data->workdir, 0700);
|
g_mkdir_with_parents(data->workdir, 0700);
|
||||||
|
|
||||||
test_tls_init(data->keyfile);
|
test_tls_init(data->keyfile);
|
||||||
g_assert(link(data->keyfile, data->serverkey) == 0);
|
g_assert(link(data->keyfile, data->serverkey) == 0);
|
||||||
|
@ -75,7 +75,7 @@ static void test_tls_creds(const void *opaque)
|
|||||||
QCryptoTLSCreds *creds;
|
QCryptoTLSCreds *creds;
|
||||||
|
|
||||||
#define CERT_DIR "tests/test-crypto-tlscredsx509-certs/"
|
#define CERT_DIR "tests/test-crypto-tlscredsx509-certs/"
|
||||||
mkdir(CERT_DIR, 0700);
|
g_mkdir_with_parents(CERT_DIR, 0700);
|
||||||
|
|
||||||
unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
|
unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
|
||||||
if (data->isServer) {
|
if (data->isServer) {
|
||||||
@ -141,7 +141,7 @@ int main(int argc, char **argv)
|
|||||||
g_test_init(&argc, &argv, NULL);
|
g_test_init(&argc, &argv, NULL);
|
||||||
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
||||||
|
|
||||||
mkdir(WORKDIR, 0700);
|
g_mkdir_with_parents(WORKDIR, 0700);
|
||||||
|
|
||||||
test_tls_init(KEYFILE);
|
test_tls_init(KEYFILE);
|
||||||
|
|
||||||
|
@ -249,8 +249,8 @@ static void test_crypto_tls_session_x509(const void *opaque)
|
|||||||
|
|
||||||
#define CLIENT_CERT_DIR "tests/test-crypto-tlssession-client/"
|
#define CLIENT_CERT_DIR "tests/test-crypto-tlssession-client/"
|
||||||
#define SERVER_CERT_DIR "tests/test-crypto-tlssession-server/"
|
#define SERVER_CERT_DIR "tests/test-crypto-tlssession-server/"
|
||||||
mkdir(CLIENT_CERT_DIR, 0700);
|
g_mkdir_with_parents(CLIENT_CERT_DIR, 0700);
|
||||||
mkdir(SERVER_CERT_DIR, 0700);
|
g_mkdir_with_parents(SERVER_CERT_DIR, 0700);
|
||||||
|
|
||||||
unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
|
unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
|
||||||
unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
|
unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
|
||||||
@ -398,7 +398,7 @@ int main(int argc, char **argv)
|
|||||||
g_test_init(&argc, &argv, NULL);
|
g_test_init(&argc, &argv, NULL);
|
||||||
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
||||||
|
|
||||||
mkdir(WORKDIR, 0700);
|
g_mkdir_with_parents(WORKDIR, 0700);
|
||||||
|
|
||||||
test_tls_init(KEYFILE);
|
test_tls_init(KEYFILE);
|
||||||
test_tls_psk_init(PSKFILE);
|
test_tls_psk_init(PSKFILE);
|
||||||
|
@ -125,8 +125,8 @@ static void test_io_channel_tls(const void *opaque)
|
|||||||
|
|
||||||
#define CLIENT_CERT_DIR "tests/test-io-channel-tls-client/"
|
#define CLIENT_CERT_DIR "tests/test-io-channel-tls-client/"
|
||||||
#define SERVER_CERT_DIR "tests/test-io-channel-tls-server/"
|
#define SERVER_CERT_DIR "tests/test-io-channel-tls-server/"
|
||||||
mkdir(CLIENT_CERT_DIR, 0700);
|
g_mkdir_with_parents(CLIENT_CERT_DIR, 0700);
|
||||||
mkdir(SERVER_CERT_DIR, 0700);
|
g_mkdir_with_parents(SERVER_CERT_DIR, 0700);
|
||||||
|
|
||||||
unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
|
unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
|
||||||
unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
|
unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
|
||||||
@ -273,7 +273,7 @@ int main(int argc, char **argv)
|
|||||||
g_test_init(&argc, &argv, NULL);
|
g_test_init(&argc, &argv, NULL);
|
||||||
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
||||||
|
|
||||||
mkdir(WORKDIR, 0700);
|
g_mkdir_with_parents(WORKDIR, 0700);
|
||||||
|
|
||||||
test_tls_init(KEYFILE);
|
test_tls_init(KEYFILE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user