Skip to content

Commit

Permalink
test development
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed May 4, 2018
1 parent 661ebcd commit 2c02644
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions tests/cunit/test_darray_fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
int dim_len[NDIM1] = {28};

/* Run test for each of the rearrangers. */
#define NUM_REARRANGERS_TO_TEST 2
/* #define NUM_REARRANGERS_TO_TEST 2 */
#define NUM_REARRANGERS_TO_TEST 1

/* Run tests for darray functions. */
int main(int argc, char **argv)
Expand Down Expand Up @@ -69,8 +70,23 @@ int main(int argc, char **argv)
int maplen = MAPLEN;
MPI_Offset wcompmap[MAPLEN];
MPI_Offset rcompmap[MAPLEN];
int data[MAPLEN];
int rearranger[NUM_REARRANGERS_TO_TEST] = {PIO_REARR_BOX, PIO_REARR_SUBSET};
/* int rearranger[NUM_REARRANGERS_TO_TEST] = {PIO_REARR_BOX, PIO_REARR_SUBSET}; */
int rearranger[NUM_REARRANGERS_TO_TEST] = {PIO_REARR_SUBSET};

/* Data we will write for each type. */
signed char byte_data[MAPLEN];
char char_data[MAPLEN];
short short_data[MAPLEN];
int int_data[MAPLEN];
float float_data[MAPLEN];
double double_data[MAPLEN];
#ifdef _NETCDF4
unsigned char ubyte_data[MAPLEN];
unsigned short ushort_data[MAPLEN];
unsigned int uint_data[MAPLEN];
long long int64_data[MAPLEN];
unsigned long long uint64_data[MAPLEN];
#endif /* _NETCDF4 */

/* Expected results for each type. */
signed char byte_expected[MAPLEN];
Expand Down Expand Up @@ -125,7 +141,7 @@ int main(int argc, char **argv)
{
wcompmap[i] = i % 2 ? my_rank * MAPLEN + i + 1 : 0; /* Even values missing. */
rcompmap[i] = my_rank * MAPLEN + i + 1;
data[i] = wcompmap[i];
int_data[i] = wcompmap[i];
}

/* Figure out iotypes. */
Expand Down Expand Up @@ -172,6 +188,7 @@ int main(int argc, char **argv)
{
void *expected;
void *fill;
void *data;
int ncid, dimid, varid;
char filename[NC_MAX_NAME + 1];

Expand All @@ -192,6 +209,7 @@ int main(int argc, char **argv)
case PIO_INT:
expected = int_expected;
fill = fv ? &int_default_fill : &int_fill;
data = int_data;
break;
case PIO_FLOAT:
expected = float_expected;
Expand Down Expand Up @@ -260,7 +278,7 @@ int main(int argc, char **argv)
return ret;

/* Write some data. */
if ((ret = PIOc_write_darray(ncid, varid, wioid, MAPLEN, data, &int_fill)))
if ((ret = PIOc_write_darray(ncid, varid, wioid, MAPLEN, data, fill)))
return ret;
if ((ret = PIOc_sync(ncid)))
return ret;
Expand All @@ -281,6 +299,14 @@ int main(int argc, char **argv)
if (memcmp(data_in, expected, type_size * MAPLEN))
return ERR_AWFUL;

if (test_type[t] == PIO_SHORT)
{
short *s1 = data_in;
short *s2 = expected;
for (int i = 0; i < MAPLEN; i++)
printf("got %d expected %d\n", *s1++, *s2++);
}

/* Release storage. */
free(data_in);

Expand Down

0 comments on commit 2c02644

Please sign in to comment.