1 /*
2  * Copyright (C) 2012 Linux Test Project, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 2 of the GNU General Public
6  * License as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it would be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *
12  * Further, this software is distributed without any warranty that it
13  * is free of the rightful claim of any third person regarding
14  * infringement or the like.  Any license provided herein, whether
15  * implied or otherwise, applies only to this software file.  Patent
16  * licenses, if any, provided herein do not apply to combinations of
17  * this program with other software, or any other product whatsoever.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301, USA.
23  */
24 
25 #include "test.h"
26 #include "migrate_pages_common.h"
27 
set_bit(unsigned long * b,unsigned int n,unsigned int v)28 void set_bit(unsigned long *b, unsigned int n, unsigned int v)
29 {
30 	if (v)
31 		b[n / bitsperlong] |= 1UL << (n % bitsperlong);
32 	else
33 		b[n / bitsperlong] &= ~(1UL << (n % bitsperlong));
34 }
35 
check_ret(long expected_ret)36 int check_ret(long expected_ret)
37 {
38 	if (expected_ret == TEST_RETURN) {
39 		tst_resm(TPASS, "expected ret success: "
40 			 "returned value = %ld", TEST_RETURN);
41 		return 0;
42 	} else
43 		tst_resm(TFAIL, "unexpected failure - "
44 			 "returned value = %ld, expected: %ld",
45 			 TEST_RETURN, expected_ret);
46 	return 1;
47 }
48 
check_errno(long expected_errno)49 int check_errno(long expected_errno)
50 {
51 	if (TEST_ERRNO == expected_errno) {
52 		tst_resm(TPASS | TTERRNO, "expected failure");
53 		return 0;
54 	} else if (TEST_ERRNO == 0)
55 		tst_resm(TFAIL, "call succeeded unexpectedly");
56 	else
57 		tst_resm(TFAIL | TTERRNO, "unexpected failure - "
58 			 "expected = %ld : %s, actual",
59 			 expected_errno, strerror(expected_errno));
60 	return 1;
61 }
62