Skip to content

Commit

Permalink
updated unit tests to work with zdata
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmatthews committed May 23, 2024
1 parent 344d8c7 commit 4306a6e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ unit_test: startup unit_test.o $(python_objects)
# the Python source. It doesn't require anything to be compiled, actually, as
# the Makefile in tests/ will compile what is requried
check:
cd tests; make check NVCC=$(NVCC) CC=$(CC)
cd tests; make check NVCC=$(NVCC) CC=$(CC) MATOM_VER=$(MATOM_VER)

# The next line runs recompiles all of the routines after first cleaning the directory
# all: clean run_indent python windsave2table py_wind
Expand Down
3 changes: 2 additions & 1 deletion source/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
C = gcc
NVCC =
MATOM_VER = 1
TARGET = py_unit_test

I_FLAGS = -I$(PYTHON)/include
L_FLAGS = -L$(PYTHON)/lib
C_FLAGS = -O3 -Wall -Wno-deprecated-non-prototype
C_FLAGS = -O3 -Wall -Wno-deprecated-non-prototype -DMATOM_VER=$(MATOM_VER)
CU_FLAGS = -O3

INCLUDES =
Expand Down
25 changes: 24 additions & 1 deletion source/tests/tests/test_define_wind.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ char *PYTHON_ENV;
char TEST_CWD[LINELENGTH];
char ATOMIC_DATA_TARGET[LINELENGTH];
char ATOMIC_DATA_DEST[LINELENGTH];
char ATOMIC_DATA_TARGET_DEVELOPER[LINELENGTH];
char ATOMIC_DATA_DEST_DEVELOPER[LINELENGTH];

#define TEST_DATA_LENGTH 2056

Expand Down Expand Up @@ -316,7 +318,7 @@ test_shell_wind (void)
WindPtr wind_cell;
PlasmaPtr plasma_cell;

const int init_error = setup_model_grid ("shell", ATOMIC_DATA_DEST);
const int init_error = setup_model_grid ("shell", ATOMIC_DATA_DEST_DEVELOPER);
if (init_error)
{
cleanup_model ("shell");
Expand Down Expand Up @@ -613,6 +615,7 @@ suite_init (void)
perror ("Unable to find atomic data directory");
return EXIT_FAILURE;
}

snprintf (ATOMIC_DATA_DEST, LINELENGTH, "%s/data", TEST_CWD);
if (symlink (ATOMIC_DATA_TARGET, ATOMIC_DATA_DEST) != EXIT_SUCCESS)
{
Expand All @@ -625,6 +628,26 @@ suite_init (void)
}
}

/* Set global variables for atomic data for developers */
snprintf (ATOMIC_DATA_TARGET_DEVELOPER, LINELENGTH, "%s/zdata", PYTHON_ENV);
if (!(stat (ATOMIC_DATA_TARGET_DEVELOPER, &sb) == EXIT_SUCCESS && S_ISDIR (sb.st_mode)))
{
perror ("Unable to find atomic data directory");
return EXIT_FAILURE;
}

snprintf (ATOMIC_DATA_DEST_DEVELOPER, LINELENGTH, "%s/zdata", TEST_CWD);
if (symlink (ATOMIC_DATA_TARGET_DEVELOPER, ATOMIC_DATA_DEST_DEVELOPER) != EXIT_SUCCESS)
{
/* If the symlink exists, we'll try not worry about it as if something is
* wrong with the atomic data it'll be caught later */
if (errno != EEXIST)
{
perror ("Unable to created symbolic link for atomic data for test case");
return EXIT_FAILURE;
}
}

/* Now initialise the things Python will need to work, and things which aren't
* specific to the model being tested such as the domain allocation */
rel_mode = REL_MODE_FULL;
Expand Down

0 comments on commit 4306a6e

Please sign in to comment.