[CRIU] [PATCH] zdtm/static/maps06: removed hardcoded page-size

Andrei Vagin avagin at virtuozzo.com
Mon Jun 18 21:02:35 MSK 2018


Applied, thanks!

On Tue, Jun 05, 2018 at 07:58:59PM +0000, Adrian Reber wrote:
> From: Adrian Reber <areber at redhat.com>
> 
> zdtm/static/maps06 failed on systems with different page-size than 4096.
> This changes maps06 to use sysconf(_SC_PAGESIZE) instead.
> 
> Signed-off-by: Adrian Reber <areber at redhat.com>
> ---
>  test/zdtm/static/maps06.c | 25 +++++++++++++++----------
>  1 file changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/test/zdtm/static/maps06.c b/test/zdtm/static/maps06.c
> index 14dd90f..7480d6b 100644
> --- a/test/zdtm/static/maps06.c
> +++ b/test/zdtm/static/maps06.c
> @@ -10,12 +10,12 @@ const char *test_author	= "Andrei Vagin <avagin at openvz.org>";
>  char *filename;
>  TEST_OPTION(filename, string, "file name", 1);
>  
> -#define TEST_SIZE 10240
> -
>  int main(int argc, char ** argv)
>  {
>  	void *start;
>  	int fd, i;
> +	int ps = sysconf(_SC_PAGESIZE);
> +	int test_size;
>  
>  	test_init(argc, argv);
>  
> @@ -23,21 +23,26 @@ int main(int argc, char ** argv)
>  	if (fd < 0)
>  		return 1;
>  
> -	ftruncate(fd, 4096);
> +	ftruncate(fd, ps);
> +
> +	if (ps == 0x1000)
> +		test_size = 10240;
> +	else
> +		test_size = 512;
>  
> -	start = mmap(0, 4096 * TEST_SIZE * 4, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
> +	start = mmap(0, ps * test_size * 4, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
>  	if (start == MAP_FAILED)
>  		return 1;
>  
> -	for (i = 0; i < TEST_SIZE; i++) {
> +	for (i = 0; i < test_size; i++) {
>  		int *addr;
> -		addr = mmap(start + i * 3 * 4096, 4096,
> +		addr = mmap(start + i * 3 * ps, ps,
>  				PROT_READ | PROT_WRITE,
>  				MAP_PRIVATE | MAP_FILE | MAP_FIXED, fd, 0);
>  		if (addr == MAP_FAILED)
>  			return 1;
>  		addr[0] = i * 2;
> -		addr = mmap(start + (i * 3 + 1) * 4096, 4096,
> +		addr = mmap(start + (i * 3 + 1) * ps, ps,
>  				PROT_READ | PROT_WRITE,
>  				MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
>  		if (addr == MAP_FAILED)
> @@ -49,12 +54,12 @@ int main(int argc, char ** argv)
>  
>  	test_waitsig();
>  
> -	for (i = 0; i < TEST_SIZE; i++) {
> +	for (i = 0; i < test_size; i++) {
>  		int *addr;
> -		addr = start + i * 3 * 4096;
> +		addr = start + i * 3 * ps;
>  		if (addr[0] != i * 2)
>  			fail();
> -		addr = start + (i * 3  + 1) * 4096;
> +		addr = start + (i * 3  + 1) * ps;
>  		if (addr[0] != i)
>  			fail();
>  	}
> -- 
> 1.8.3.1
> 


More information about the CRIU mailing list