Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] Make sure that temporary directories are deleted
Some tests did't delete temporary directories.
- Loading branch information
Showing
16 changed files
with
212 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (C) 2016 Jolla Ltd. | ||
* Contact: Slava Monich <slava.monich@jolla.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
*/ | ||
|
||
#include "test_util.h" | ||
#include "mms_file_util.h" | ||
#include "mms_log.h" | ||
|
||
void | ||
test_dirs_init( | ||
TestDirs* dirs, | ||
const char* test) | ||
{ | ||
const char* tmp = g_get_tmp_dir(); | ||
dirs->root = g_mkdtemp(g_strconcat(tmp, "/", test, "_XXXXXX", NULL)); | ||
dirs->msg = g_strconcat(dirs->root, "/" MMS_MESSAGE_DIR, NULL); | ||
dirs->attic = g_strconcat(dirs->root, "/" MMS_ATTIC_DIR, NULL); | ||
MMS_VERBOSE("Temporary directory %s", dirs->root); | ||
} | ||
|
||
static | ||
void | ||
test_dir_remove( | ||
const char* dir) | ||
{ | ||
if (rmdir(dir) < 0) { | ||
if (errno != ENOENT) { | ||
MMS_ERR("Failed to remove %s: %s", dir, strerror(errno)); | ||
} | ||
} else { | ||
MMS_VERBOSE("Deleted %s", dir); | ||
} | ||
} | ||
|
||
void | ||
test_dirs_cleanup( | ||
TestDirs* dirs, | ||
gboolean remove) | ||
{ | ||
if (remove) { | ||
test_dir_remove(dirs->attic); | ||
test_dir_remove(dirs->msg); | ||
test_dir_remove(dirs->root); | ||
} | ||
g_free(dirs->root); | ||
g_free(dirs->msg); | ||
g_free(dirs->attic); | ||
} | ||
|
||
/* | ||
* Local Variables: | ||
* mode: C | ||
* c-basic-offset: 4 | ||
* indent-tabs-mode: nil | ||
* End: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (C) 2016 Jolla Ltd. | ||
* Contact: Slava Monich <slava.monich@jolla.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
*/ | ||
|
||
#ifndef TEST_UTIL_H | ||
#define TEST_UTIL_H | ||
|
||
#include "mms_lib_types.h" | ||
|
||
typedef struct test_dirs { | ||
char* root; | ||
char* msg; | ||
char* attic; | ||
} TestDirs; | ||
|
||
void | ||
test_dirs_init( | ||
TestDirs* dirs, | ||
const char* test); | ||
|
||
void | ||
test_dirs_cleanup( | ||
TestDirs* dirs, | ||
gboolean remove); | ||
|
||
#endif /* TEST_UTIL_H */ | ||
|
||
/* | ||
* Local Variables: | ||
* mode: C | ||
* c-basic-offset: 4 | ||
* indent-tabs-mode: nil | ||
* End: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# -*- Mode: makefile-gmake -*- | ||
|
||
EXE = test_delivery_ind | ||
SRC = test_delivery_ind.c | ||
COMMON_SRC = test_connection.c test_connman.c test_handler.c | ||
SRC = $(EXE).c | ||
COMMON_SRC = test_connection.c test_connman.c test_handler.c test_util.c | ||
|
||
include ../common/Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# -*- Mode: makefile-gmake -*- | ||
|
||
EXE = test_read_ind | ||
SRC = test_read_ind.c | ||
COMMON_SRC = test_connection.c test_connman.c test_handler.c | ||
SRC = $(EXE).c | ||
COMMON_SRC = test_connection.c test_connman.c test_handler.c test_util.c | ||
|
||
include ../common/Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# -*- Mode: makefile-gmake -*- | ||
|
||
EXE = test_read_report | ||
SRC = test_read_report.c | ||
COMMON_SRC = test_connection.c test_connman.c test_handler.c test_http.c | ||
SRC = $(EXE).c | ||
COMMON_SRC = test_connection.c test_connman.c test_handler.c test_http.c \ | ||
test_util.c | ||
|
||
include ../common/Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# -*- Mode: makefile-gmake -*- | ||
|
||
EXE = test_retrieve | ||
SRC = test_retrieve.c | ||
COMMON_SRC = test_connection.c test_connman.c test_handler.c test_http.c | ||
SRC = $(EXE).c | ||
COMMON_SRC = test_connection.c test_connman.c test_handler.c test_http.c \ | ||
test_util.c | ||
|
||
include ../common/Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.