Commit dd20ee78 authored by Nicolas Denoyelle's avatar Nicolas Denoyelle

checkpatch

parent 6d4b1ebd
...@@ -17,12 +17,12 @@ static excit_t create_test_tleaf(const ssize_t depth, ...@@ -17,12 +17,12 @@ static excit_t create_test_tleaf(const ssize_t depth,
it = excit_alloc_test(EXCIT_TLEAF); it = excit_alloc_test(EXCIT_TLEAF);
assert(it != NULL); assert(it != NULL);
err = excit_tleaf_init(it, depth+1, arities, policy, user_policy); err = excit_tleaf_init(it, depth + 1, arities, policy, user_policy);
assert(err == EXCIT_SUCCESS); assert(err == EXCIT_SUCCESS);
ssize_t i, size = 1, it_size; ssize_t i, size = 1, it_size;
for(i=0; i<depth; i++) for (i = 0; i < depth; i++)
size *= arities[i]; size *= arities[i];
assert(excit_size(it, &it_size) == EXCIT_SUCCESS); assert(excit_size(it, &it_size) == EXCIT_SUCCESS);
assert(it_size == size); assert(it_size == size);
...@@ -30,58 +30,67 @@ static excit_t create_test_tleaf(const ssize_t depth, ...@@ -30,58 +30,67 @@ static excit_t create_test_tleaf(const ssize_t depth,
return it; return it;
} }
static void tleaf_test_round_robin_policy(excit_t tleaf){ static void tleaf_test_round_robin_policy(excit_t tleaf)
{
ssize_t i, value, size; ssize_t i, value, size;
assert(excit_size(tleaf, &size) == EXCIT_SUCCESS); assert(excit_size(tleaf, &size) == EXCIT_SUCCESS);
assert(excit_rewind(tleaf) == EXCIT_SUCCESS); assert(excit_rewind(tleaf) == EXCIT_SUCCESS);
for(i = 0; i < size; i++){ for (i = 0; i < size; i++) {
assert(excit_next(tleaf, &value) == EXCIT_SUCCESS); assert(excit_next(tleaf, &value) == EXCIT_SUCCESS);
assert(value == i); assert(value == i);
} }
assert(excit_next(tleaf, &value) == EXCIT_STOPIT); assert(excit_next(tleaf, &value) == EXCIT_STOPIT);
} }
static void tleaf_test_scatter_policy_no_split(excit_t tleaf,
static void tleaf_test_scatter_policy_no_split(excit_t tleaf, const ssize_t depth, const ssize_t *arities){ const ssize_t depth,
const ssize_t *arities)
{
ssize_t i, j, r, n, c, value, val, size; ssize_t i, j, r, n, c, value, val, size;
assert(excit_size(tleaf, &size) == EXCIT_SUCCESS); assert(excit_size(tleaf, &size) == EXCIT_SUCCESS);
assert(excit_rewind(tleaf) == EXCIT_SUCCESS); assert(excit_rewind(tleaf) == EXCIT_SUCCESS);
for(i = 0; i < size; i++){ for (i = 0; i < size; i++) {
c = i; c = i;
n = size; n = size;
val = 0; val = 0;
assert(excit_next(tleaf, &value) == EXCIT_SUCCESS); assert(excit_next(tleaf, &value) == EXCIT_SUCCESS);
for(j=0; j<depth; j++){ for (j = 0; j < depth; j++) {
r = c % arities[j]; r = c % arities[j];
n = n / arities[j]; n = n / arities[j];
c = c / arities[j]; c = c / arities[j];
val += n*r; val += n * r;
} }
assert(value == val); assert(value == val);
} }
assert(excit_next(tleaf, &value) == EXCIT_STOPIT); assert(excit_next(tleaf, &value) == EXCIT_STOPIT);
} }
void run_tests(const ssize_t depth, const ssize_t *arities){ void run_tests(const ssize_t depth, const ssize_t *arities)
excit_t rrobin = create_test_tleaf(depth, arities, TLEAF_POLICY_ROUND_ROBIN, NULL); {
excit_t rrobin =
create_test_tleaf(depth, arities, TLEAF_POLICY_ROUND_ROBIN, NULL);
assert(rrobin != NULL); assert(rrobin != NULL);
tleaf_test_round_robin_policy(rrobin); tleaf_test_round_robin_policy(rrobin);
excit_free(rrobin); excit_free(rrobin);
excit_t scatter = create_test_tleaf(depth, arities, TLEAF_POLICY_SCATTER, NULL); excit_t scatter =
create_test_tleaf(depth, arities, TLEAF_POLICY_SCATTER, NULL);
assert(scatter != NULL); assert(scatter != NULL);
tleaf_test_scatter_policy_no_split(scatter, depth, arities); tleaf_test_scatter_policy_no_split(scatter, depth, arities);
excit_free(scatter); excit_free(scatter);
int i = 0; int i = 0;
while (synthetic_tests[i]) { while (synthetic_tests[i]) {
excit_t it = create_test_tleaf(depth, arities, TLEAF_POLICY_ROUND_ROBIN, NULL); excit_t it =
create_test_tleaf(depth, arities, TLEAF_POLICY_ROUND_ROBIN,
NULL);
synthetic_tests[i](it); synthetic_tests[i] (it);
excit_free(it); excit_free(it);
i++; i++;
} }
...@@ -89,10 +98,15 @@ void run_tests(const ssize_t depth, const ssize_t *arities){ ...@@ -89,10 +98,15 @@ void run_tests(const ssize_t depth, const ssize_t *arities){
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
const ssize_t depth = 4; ssize_t depth = 4;
const ssize_t arities[4] = {4,8,2,4}; const ssize_t arities_0[4] = { 4, 8, 2, 4 };
run_tests(depth, arities_0);
depth = 8;
const ssize_t arities_1[8] = { 4, 6, 2, 4, 3, 6, 2, 9 };
run_tests(depth, arities_1);
run_tests(depth, arities);
return 0; return 0;
} }
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