Commit 773f131f authored by Swann Perarnau's avatar Swann Perarnau
Browse files

[fix] move common replicaset test in test lib

Move common code in a different file, add a header just for the tests.
Also cleanup a little bit the test Makefile.am.
parent 6295df05
......@@ -37,17 +37,19 @@ if HAVE_CUDA
AREA_TESTS += area/test_cuda
endif
noinst_LTLIBRARIES = liblayout_test.la
liblayout_test_la_CPPFLAGS =
liblayout_test_la_LDFLAGS =
noinst_LTLIBRARIES = liblayout_test.la libreplicaset_test.la
liblayout_test_la_SOURCES = \
layout/test_layout.h \
layout/coords.c \
layout/dense.c \
layout/layout.c \
layout/reshape.c
liblayout_test_la_LIBADD = ../src/libaml.la
LDADD = liblayout_test.la
libreplicaset_test_la_SOURCES = \
replicaset/test_replicaset.h \
replicaset/common.c
LDADD = liblayout_test.la libreplicaset_test.la
LAYOUT_TESTS = \
layout/test_coords \
......@@ -61,6 +63,7 @@ TILING_TESTS = tiling/test_tiling
DMA_TESTS = dma/test_dma_linux_seq \
dma/test_dma_linux_par
REPLICASET_TESTS =
if HAVE_CUDA
......
/*******************************************************************************
* Copyright 2019 UChicago Argonne, LLC.
* (c.f. AUTHORS, LICENSE)
*
* This file is part of the AML project.
* For more info, see https://xgitlab.cels.anl.gov/argo/aml
*
* SPDX-License-Identifier: BSD-3-Clause
******************************************************************************/
#include "test_replicaset.h"
void test_replicaset(struct aml_replicaset *replicaset,
const void *src,
int (*comp)(const void *, const void *, size_t))
{
// Basic tests
assert(replicaset != NULL);
assert(replicaset->ops != NULL);
assert(replicaset->ops->init != NULL);
assert(replicaset->ops->sync != NULL);
assert(replicaset->n > 0);
for (unsigned i = 0; i < replicaset->n; i++)
assert(replicaset->replica[i] != NULL);
// Check sync
assert(aml_replicaset_sync(replicaset, 0) == AML_SUCCESS);
for (unsigned i = 1; i < replicaset->n; i++)
assert(!comp(replicaset->replica[i], replicaset->replica[0],
replicaset->size));
// Check init
assert(aml_replicaset_init(replicaset, src) == AML_SUCCESS);
for (unsigned i = 0; i < replicaset->n; i++)
assert(!comp(replicaset->replica[i], src, replicaset->size));
}
......@@ -8,38 +8,12 @@
* SPDX-License-Identifier: BSD-3-Clause
******************************************************************************/
#include <stdlib.h>
#include "test_replicaset.h"
#include "aml.h"
#include <stdlib.h>
#include "aml/higher/replicaset.h"
#include "aml/higher/replicaset/hwloc.h"
void test_replicaset(struct aml_replicaset *replicaset,
const void *src,
int (*comp)(const void *, const void *, size_t))
{
// Basic tests
assert(replicaset != NULL);
assert(replicaset->ops != NULL);
assert(replicaset->ops->init != NULL);
assert(replicaset->ops->sync != NULL);
assert(replicaset->n > 0);
for (unsigned i = 0; i < replicaset->n; i++)
assert(replicaset->replica[i] != NULL);
// Check sync
assert(aml_replicaset_sync(replicaset, 0) == AML_SUCCESS);
for (unsigned i = 1; i < replicaset->n; i++)
assert(!comp(replicaset->replica[i], replicaset->replica[0],
replicaset->size));
// Check init
assert(aml_replicaset_init(replicaset, src) == AML_SUCCESS);
for (unsigned i = 0; i < replicaset->n; i++)
assert(!comp(replicaset->replica[i], src, replicaset->size));
}
const size_t size = 1 << 20; // 1 Mo
void *src;
......
/*******************************************************************************
* Copyright 2019 UChicago Argonne, LLC.
* (c.f. AUTHORS, LICENSE)
*
* This file is part of the AML project.
* For more info, see https://xgitlab.cels.anl.gov/argo/aml
*
* SPDX-License-Identifier: BSD-3-Clause
******************************************************************************/
#include "aml.h"
#include "aml/higher/replicaset.h"
#ifndef TEST_REPLICASET_H
#define TEST_REPLICASET_H 1
void test_replicaset(struct aml_replicaset *replicaset,
const void *src,
int (*comp)(const void *, const void *, size_t));
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment