test_area.c 1.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*******************************************************************************
 * 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/area/linux.h"
12
#include <assert.h>
13

14 15 16 17
void test_map(const struct aml_area *area){
	assert(area != NULL);
	assert(area->ops->mmap != NULL);
	assert(area->ops->munmap != NULL);
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

	void *ptr;
	size_t s;
	const size_t sizes[4] = {1, 32, 4096, 1<<20};

	for(s = 0; s<sizeof(sizes)/sizeof(*sizes); s++){
		ptr = aml_area_mmap(area, &ptr, sizes[s]);
		assert(ptr != NULL);
		memset(ptr, 0, sizes[s]);
		assert(aml_area_munmap(area, ptr, sizes[s]) == AML_SUCCESS);
	}
}

void test_aml_area(struct aml_area *area){	
	test_map(area);
}

int main(int argc, char** argv){
	aml_init(&argc, &argv);
37
	test_map(&aml_area_linux);
38 39 40
	aml_finalize();
	return 0;
}