test: drop TEST_DATA_DIR, fold into get_testdata_dir()
Drop the TEST_DATA_DIR macro as this was using alloca() within a function call which is allegedly unsafe. So add a "suffix" argument to get_testdata_dir() instead and call that directly.
This commit is contained in:
@@ -35,7 +35,7 @@ static int test_cgroup_mask(void) {
|
||||
int r;
|
||||
|
||||
/* Prepare the manager. */
|
||||
assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0);
|
||||
assert_se(set_unit_path(get_testdata_dir("")) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
r = manager_new(UNIT_FILE_USER, true, &m);
|
||||
if (r == -EPERM || r == -EACCES) {
|
||||
|
||||
@@ -38,7 +38,7 @@ int main(int argc, char *argv[]) {
|
||||
int r;
|
||||
|
||||
/* prepare the test */
|
||||
assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0);
|
||||
assert_se(set_unit_path(get_testdata_dir("")) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
r = manager_new(UNIT_FILE_USER, true, &m);
|
||||
if (MANAGER_SKIP_TEST(r)) {
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#endif
|
||||
#include "stat-util.h"
|
||||
#include "test-helper.h"
|
||||
#include "tests.h"
|
||||
#include "unit.h"
|
||||
#include "util.h"
|
||||
#include "virt.h"
|
||||
@@ -516,7 +517,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
assert_se(setenv("XDG_RUNTIME_DIR", "/tmp/", 1) == 0);
|
||||
assert_se(set_unit_path(TEST_DATA_DIR("/test-execute/")) >= 0);
|
||||
assert_se(set_unit_path(get_testdata_dir("/test-execute")) >= 0);
|
||||
|
||||
/* Unset VAR1, VAR2 and VAR3 which are used in the PassEnvironment test
|
||||
* cases, otherwise (and if they are present in the environment),
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
***/
|
||||
|
||||
#include "sd-daemon.h"
|
||||
#include "string-util.h"
|
||||
#include "tests.h"
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
@@ -41,6 +39,3 @@
|
||||
-ENOENT, \
|
||||
-ENOMEDIUM /* cannot determine cgroup */ \
|
||||
)
|
||||
|
||||
#define TEST_DATA_DIR(subdir) \
|
||||
strjoina(get_testdata_dir(), subdir)
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "log.h"
|
||||
#include "journal-importer.h"
|
||||
#include "string-util.h"
|
||||
#include "test-helper.h"
|
||||
#include "tests.h"
|
||||
|
||||
static void assert_iovec_entry(const struct iovec *iovec, const char* content) {
|
||||
assert_se(strlen(content) == iovec->iov_len);
|
||||
@@ -39,7 +39,7 @@ static void test_basic_parsing(void) {
|
||||
_cleanup_(journal_importer_cleanup) JournalImporter imp = {};
|
||||
int r;
|
||||
|
||||
imp.fd = open(TEST_DATA_DIR("/journal-data/journal-1.txt"), O_RDONLY|O_CLOEXEC);
|
||||
imp.fd = open(get_testdata_dir("/journal-data/journal-1.txt"), O_RDONLY|O_CLOEXEC);
|
||||
assert_se(imp.fd >= 0);
|
||||
|
||||
do
|
||||
@@ -68,7 +68,7 @@ static void test_bad_input(void) {
|
||||
_cleanup_(journal_importer_cleanup) JournalImporter imp = {};
|
||||
int r;
|
||||
|
||||
imp.fd = open(TEST_DATA_DIR("/journal-data/journal-2.txt"), O_RDONLY|O_CLOEXEC);
|
||||
imp.fd = open(get_testdata_dir("/journal-data/journal-2.txt"), O_RDONLY|O_CLOEXEC);
|
||||
assert_se(imp.fd >= 0);
|
||||
|
||||
do
|
||||
|
||||
@@ -262,7 +262,7 @@ int main(int argc, char *argv[]) {
|
||||
log_parse_environment();
|
||||
log_open();
|
||||
|
||||
assert_se(set_unit_path(TEST_DATA_DIR("/test-path/")) >= 0);
|
||||
assert_se(set_unit_path(get_testdata_dir("/test-path")) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
for (test = tests; test && *test; test++) {
|
||||
|
||||
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
|
||||
int r;
|
||||
|
||||
/* prepare the test */
|
||||
assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0);
|
||||
assert_se(set_unit_path(get_testdata_dir("")) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
r = manager_new(UNIT_FILE_USER, true, &m);
|
||||
if (MANAGER_SKIP_TEST(r)) {
|
||||
|
||||
Reference in New Issue
Block a user