Skip to content

Commit

Permalink
Test balance: surviving without ZLIB
Browse files Browse the repository at this point in the history
  • Loading branch information
cburstedde committed Dec 15, 2023
1 parent a43cd90 commit 594ada9
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions test/test_balance2.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,19 @@ refine_fn (p4est_t * p4est, p4est_topidx_t which_tree,
return 1;
}

static unsigned
test_checksum (p4est_t * p4est, int have_zlib)
{
return have_zlib ? p4est_checksum (p4est) : 0;
}

int
main (int argc, char **argv)
{
sc_MPI_Comm mpicomm;
int mpiret;
int mpisize, mpirank;
int have_zlib;
unsigned crc;
#ifndef P4_TO_P8
size_t kz;
Expand All @@ -114,6 +121,12 @@ main (int argc, char **argv)
sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT);
p4est_init (NULL, SC_LP_DEFAULT);

/* check for ZLIB usability */
if (!(have_zlib = sc_have_zlib ())) {
P4EST_GLOBAL_LERROR
("Not found a working ZLIB installation: ignoring CRCs\n");
}

#ifndef P4_TO_P8
connectivity = p4est_connectivity_new_star ();
#else
Expand Down Expand Up @@ -175,19 +188,19 @@ main (int argc, char **argv)
p4est_reset_data (p4est, 8, init_fn, NULL);

/* checksum and partition */
crc = p4est_checksum (p4est);
crc = test_checksum (p4est, have_zlib);
p4est_partition (p4est, 0, NULL);
SC_CHECK_ABORT (p4est_checksum (p4est) == crc, "Partition");
SC_CHECK_ABORT (test_checksum (p4est, have_zlib) == crc, "Partition");
SC_CHECK_ABORT (p4est_is_balanced (p4est, P4EST_CONNECT_FULL), "Balance 4");

/* check reset data function */
p4est_reset_data (p4est, 3, NULL, NULL);
p4est_reset_data (p4est, 3, NULL, NULL);

/* checksum and rebalance */
crc = p4est_checksum (p4est);
crc = test_checksum (p4est, have_zlib);
p4est_balance (p4est, P4EST_CONNECT_FULL, NULL);
SC_CHECK_ABORT (p4est_checksum (p4est) == crc, "Rebalance");
SC_CHECK_ABORT (test_checksum (p4est, have_zlib) == crc, "Rebalance");

/* clean up and exit */
P4EST_ASSERT (p4est->user_data_pool->elem_count ==
Expand Down

0 comments on commit 594ada9

Please sign in to comment.