Skip to content

Commit

Permalink
updated unit test suite for SIROCCO env
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmatthews committed Oct 18, 2024
1 parent 88ea0b9 commit 7e44295
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
36 changes: 18 additions & 18 deletions source/tests/tests/test_define_wind.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "../assert.h"
#include "../unit_test.h"

char *PYTHON_ENV;
char *SIROCCO_ENV;
char TEST_CWD[LINELENGTH];
char ATOMIC_DATA_TARGET[LINELENGTH];
char ATOMIC_DATA_DEST[LINELENGTH];
Expand All @@ -38,9 +38,9 @@ char ATOMIC_DATA_DEST_DEVELOPER[LINELENGTH];
*
* @details
*
* This uses the data from $PYTHON/source/tests/test_data/define_wind/agn_macro.pf and
* $PYTHON/source/tests/test_data/define_wind/agn_macro.grid.txt. The latter was created using the Python script in the
* $PYTHON/source/tests/test_data/define_wind directory.
* This uses the data from $SIROCCO/source/tests/test_data/define_wind/agn_macro.pf and
* $SIROCCO/source/tests/test_data/define_wind/agn_macro.grid.txt. The latter was created using the Python script in the
* $SIROCCO/source/tests/test_data/define_wind directory.
*
* TODO: we don't check anything to do with macro atoms (we don't output this from windsave2table)
*
Expand All @@ -65,7 +65,7 @@ test_sv_agn_macro_wind (void)

define_wind ();

snprintf (test_data_filename, LINELENGTH, "%s/source/tests/test_data/define_wind/agn_macro.grid.txt", PYTHON_ENV);
snprintf (test_data_filename, LINELENGTH, "%s/source/tests/test_data/define_wind/agn_macro.grid.txt", SIROCCO_ENV);
fp = fopen (test_data_filename, "r");
if (fp == NULL)
{
Expand Down Expand Up @@ -166,9 +166,9 @@ test_sv_agn_macro_wind (void)
*
* @details
*
* This uses the data from $PYTHON/source/tests/test_data/define_wind/cv.pf and
* $PYTHON/source/tests/test_data/define_wind/cv.grid.txt. The latter was created using the Python script in the
* $PYTHON/source/tests/test_data/define_wind directory.
* This uses the data from $SIROCCO/source/tests/test_data/define_wind/cv.pf and
* $SIROCCO/source/tests/test_data/define_wind/cv.grid.txt. The latter was created using the Python script in the
* $SIROCCO/source/tests/test_data/define_wind directory.
*
* ****************************************************************************************************************** */

Expand All @@ -195,7 +195,7 @@ test_sv_cv_wind (void)
define_wind ();

/* And now we can compare our created grid to the "ground truth" grid */
snprintf (test_data_filename, LINELENGTH, "%s/source/tests/test_data/define_wind/cv.grid.txt", PYTHON_ENV);
snprintf (test_data_filename, LINELENGTH, "%s/source/tests/test_data/define_wind/cv.grid.txt", SIROCCO_ENV);
fp = fopen (test_data_filename, "r");
if (fp == NULL)
{
Expand Down Expand Up @@ -289,7 +289,7 @@ test_sv_cv_wind (void)
}

/* For the CV model, we want to save the wind_save to use in another test */
snprintf (windsave_filename, LINELENGTH, "%s/source/tests/test_data/define_wind/restart_cv.wind_save", PYTHON_ENV);
snprintf (windsave_filename, LINELENGTH, "%s/source/tests/test_data/define_wind/restart_cv.wind_save", SIROCCO_ENV);
const int err = wind_save (windsave_filename);
if (err == 0)
{
Expand Down Expand Up @@ -329,7 +329,7 @@ test_shell_wind (void)
define_wind ();

/* And now we can compare our created grid to the "ground truth" grid */
snprintf (test_data_filename, LINELENGTH, "%s/source/tests/test_data/define_wind/shell.grid.txt", PYTHON_ENV);
snprintf (test_data_filename, LINELENGTH, "%s/source/tests/test_data/define_wind/shell.grid.txt", SIROCCO_ENV);
fp = fopen (test_data_filename, "r");
if (fp == NULL)
{
Expand Down Expand Up @@ -454,7 +454,7 @@ test_spherical_star_wind (void)
define_wind ();

/* And now we can compare our created grid to the "ground truth" grid */
snprintf (test_data_filename, LINELENGTH, "%s/source/tests/test_data/define_wind/star.grid.txt", PYTHON_ENV);
snprintf (test_data_filename, LINELENGTH, "%s/source/tests/test_data/define_wind/star.grid.txt", SIROCCO_ENV);
fp = fopen (test_data_filename, "r");
if (fp == NULL)
{
Expand Down Expand Up @@ -593,13 +593,13 @@ suite_init (void)
{
struct stat sb;

/* Find the PYTHON env var and the directory where tests are called. We need
/* Find the SIROCCO env var and the directory where tests are called. We need
* these to create a symbolic link to the atomic data required for the
* tests */
PYTHON_ENV = getenv ("PYTHON");
if (PYTHON_ENV == NULL)
SIROCCO_ENV = getenv ("SIROCCO");
if (SIROCCO_ENV == NULL)
{
fprintf (stderr, "Failed to find PYTHON environment variable\n");
fprintf (stderr, "Failed to find SIROCCO environment variable\n");
return EXIT_FAILURE;
}
if (getcwd (TEST_CWD, LINELENGTH) == NULL)
Expand All @@ -609,7 +609,7 @@ suite_init (void)
}

/* Set global variables for atomic data */
snprintf (ATOMIC_DATA_TARGET, LINELENGTH, "%s/xdata", PYTHON_ENV);
snprintf (ATOMIC_DATA_TARGET, LINELENGTH, "%s/xdata", SIROCCO_ENV);
if (!(stat (ATOMIC_DATA_TARGET, &sb) == EXIT_SUCCESS && S_ISDIR (sb.st_mode)))
{
perror ("Unable to find atomic data directory");
Expand All @@ -629,7 +629,7 @@ suite_init (void)
}

/* Set global variables for atomic data for developers */
snprintf (ATOMIC_DATA_TARGET_DEVELOPER, LINELENGTH, "%s/zdata", PYTHON_ENV);
snprintf (ATOMIC_DATA_TARGET_DEVELOPER, LINELENGTH, "%s/zdata", SIROCCO_ENV);
if (!(stat (ATOMIC_DATA_TARGET_DEVELOPER, &sb) == EXIT_SUCCESS && S_ISDIR (sb.st_mode)))
{
perror ("Unable to find atomic data directory");
Expand Down
8 changes: 4 additions & 4 deletions source/tests/tests/test_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ get_solve_matrix_test_data (const char *a_path, const char *b_path, const char *
static int
call_invert_matrix (const char *test_name)
{
const char *sirocco_path = getenv ((const char *) "PYTHON");
const char *sirocco_path = getenv ((const char *) "SIROCCO");
if (sirocco_path == NULL)
{
CU_FAIL_FATAL ("$PYTHON has not been set");
CU_FAIL_FATAL ("$SIROCCO has not been set");
}

double *matrix;
Expand Down Expand Up @@ -221,10 +221,10 @@ call_invert_matrix (const char *test_name)
int
call_solve_matrix (const char *test_name)
{
const char *sirocco_path = getenv ((const char *) "PYTHON");
const char *sirocco_path = getenv ((const char *) "SIROCCO");
if (sirocco_path == NULL)
{
CU_FAIL_FATAL ("$PYTHON has not been set");
CU_FAIL_FATAL ("$SIROCCO has not been set");
}

double *matrix_a;
Expand Down
4 changes: 2 additions & 2 deletions source/tests/unit_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*
* ****************************************************************************************************************** */

#ifndef PYTHON_UNIT_TEST_H
#define PYTHON_UNIT_TEST_H
#ifndef SIROCCO_UNIT_TEST_H
#define SIROCCO_UNIT_TEST_H

int cleanup_model (const char *root_name);
int setup_model_grid (const char *root_name, const char *atomic_data_location);
Expand Down
28 changes: 14 additions & 14 deletions source/tests/unit_test_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
const char *
get_sirocco_env_variable (void)
{
const char *env = getenv ("PYTHON");
const char *env = getenv ("SIROCCO");
if (env == NULL)
{
fprintf (stderr, "Failed to find PYTHON environment variable\n");
fprintf (stderr, "Failed to find SIROCCO environment variable\n");
return NULL;
}

Expand Down Expand Up @@ -69,7 +69,7 @@ free_and_null (void **ptr)
*
* @brief Clean up after a model has run as a test case.
*
* @param [in] root_name The root name of the model in $PYTHON/source/tests/test_data/define_wind
* @param [in] root_name The root name of the model in $SIROCCO/source/tests/test_data/define_wind
*
* @details
*
Expand All @@ -79,22 +79,22 @@ int
cleanup_model (const char *root_name)
{
int n_plasma;
char *PYTHON_ENV;
char *SIROCCO_ENV;
char parameter_filepath[LINELENGTH];

PlasmaPtr plasma_cell;
MacroPtr macro_cell;

(void) root_name;

PYTHON_ENV = getenv ("PYTHON");
if (PYTHON_ENV == NULL)
SIROCCO_ENV = getenv ("SIROCCO");
if (SIROCCO_ENV == NULL)
{
fprintf (stderr, "Failed to find PYTHON environment variable\n");
fprintf (stderr, "Failed to find SIROCCO environment variable\n");
return EXIT_FAILURE;
}

snprintf (parameter_filepath, LINELENGTH, "%s/source/tests/test_data/define_wind/%s.pf", PYTHON_ENV, files.root);
snprintf (parameter_filepath, LINELENGTH, "%s/source/tests/test_data/define_wind/%s.pf", SIROCCO_ENV, files.root);
if (cpar (parameter_filepath) != 1) /* cpar returns 1 when something is "normal" */
{
return EXIT_FAILURE;
Expand Down Expand Up @@ -269,7 +269,7 @@ set_atomic_data_filename (const char *atomic_data_location)
*
* @brief Initialise all the necessary parameters to define the wind
*
* @param [in] root_name The root name of the model in $PYTHON/source/tests/test_data/define_wind
* @param [in] root_name The root name of the model in $SIROCCO/source/tests/test_data/define_wind
* @param [in] atomic_data_location The location of atomic data
*
* @details
Expand All @@ -284,15 +284,15 @@ int
setup_model_grid (const char *root_name, const char *atomic_data_location)
{
int n_dom;
char *PYTHON_ENV;
char *SIROCCO_ENV;
char rdchoice_answer[LINELENGTH];
char rdchoice_choices[LINELENGTH];
char parameter_filepath[LINELENGTH];

PYTHON_ENV = getenv ("PYTHON");
if (PYTHON_ENV == NULL)
SIROCCO_ENV = getenv ("SIROCCO");
if (SIROCCO_ENV == NULL)
{
fprintf (stderr, "Failed to find PYTHON environment variable\n");
fprintf (stderr, "Failed to find SIROCCO environment variable\n");
return EXIT_FAILURE;
}

Expand All @@ -301,7 +301,7 @@ setup_model_grid (const char *root_name, const char *atomic_data_location)
/* Set up parameter file, that way we can get all the parameters from that
* instead of defining them manually */
strcpy (files.root, root_name);
snprintf (parameter_filepath, LINELENGTH, "%s/source/tests/test_data/define_wind/%s.pf", PYTHON_ENV, files.root);
snprintf (parameter_filepath, LINELENGTH, "%s/source/tests/test_data/define_wind/%s.pf", SIROCCO_ENV, files.root);
if (opar (parameter_filepath) != 2) /* opar returns 2 when reading for the parameter file */
{
fprintf (stderr, "Unable to read from parameter file %s.pf", files.root);
Expand Down

0 comments on commit 7e44295

Please sign in to comment.