Skip to content

Commit

Permalink
tests UPDATE use only absolute paths
Browse files Browse the repository at this point in the history
Drops the requirement for the tests to
be run only from binary dir.
  • Loading branch information
michalvasko committed May 20, 2024
1 parent a4558be commit c703a29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
18 changes: 7 additions & 11 deletions tests/np_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,6 @@ np_glob_setup_np2(void **state, const char *test_name, const char **modules)
char str[256], server_dir[256], extdata_path[256], sock_path[256], pidfile_path[256];
int fd, pipefd[2], buf;

if (!getcwd(str, 256)) {
SETUP_FAIL_LOG;
return 1;
}
if (strcmp(str, NP_BINARY_DIR)) {
printf("Tests must be started from the build directory \"%s\".\n", NP_BINARY_DIR);
printf("CWD = %s\n", str);
SETUP_FAIL_LOG;
return 1;
}

/* sysrepo environment variables must be set by NP_GLOB_SETUP_ENV_FUNC prior */
/* install modules */
if (setenv("NP2_MODULE_DIR", NP_ROOT_DIR "/modules", 1)) {
Expand Down Expand Up @@ -206,6 +195,13 @@ np_glob_setup_np2(void **state, const char *test_name, const char **modules)

/* fork and start the server */
if (!(pid = fork())) {
/* create test dir */
sprintf(str, "%s/%s", NP_TEST_DIR, test_name);
if ((mkdir(str, 00700) == -1) && (errno != EEXIST)) {
SETUP_FAIL_LOG;
goto child_error;
}

/* open log file */
sprintf(str, "%s/%s/%s", NP_TEST_DIR, test_name, NP_LOG_FILE);
fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 00600);
Expand Down
8 changes: 4 additions & 4 deletions tests/np_test_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @brief test configuration header
*
* @copyright
* Copyright (c) 2019 - 2022 Deutsche Telekom AG.
* Copyright (c) 2017 - 2022 CESNET, z.s.p.o.
* Copyright (c) 2019 - 2024 Deutsche Telekom AG.
* Copyright (c) 2017 - 2024 CESNET, z.s.p.o.
*
* This source code is licensed under BSD 3-Clause License (the "License").
* You may not use this file except in compliance with the License.
Expand All @@ -31,8 +31,8 @@
/* sysrepo SHM prefix */
#define NP_SR_SHM_PREFIX "_tests_np_"

/* path to put test-specific directory into, just relative NP_SR_REPOS_DIR to NP_BINARY_DIR */
#define NP_TEST_DIR "./tests/repositories"
/* path to put test-specific directory into */
#define NP_TEST_DIR NP_SR_REPOS_DIR

/* server PID file */
#define NP_PID_FILE "np2.pid"
Expand Down

0 comments on commit c703a29

Please sign in to comment.