Jan Stancek | 5765e2c | 2012-10-26 15:31:16 +0200 | [diff] [blame] | 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" |
Jan Stancek | 5765e2c | 2012-10-26 15:31:16 +0200 | [diff] [blame] | 26 | #include "migrate_pages_common.h" |
| 27 | |
| 28 | void set_bit(unsigned long *b, unsigned int n, unsigned int v) |
| 29 | { |
| 30 | if (v) |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 31 | b[n / bitsperlong] |= 1UL << (n % bitsperlong); |
Jan Stancek | 5765e2c | 2012-10-26 15:31:16 +0200 | [diff] [blame] | 32 | else |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 33 | b[n / bitsperlong] &= ~(1UL << (n % bitsperlong)); |
Jan Stancek | 5765e2c | 2012-10-26 15:31:16 +0200 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | int check_ret(long expected_ret) |
| 37 | { |
| 38 | if (expected_ret == TEST_RETURN) { |
| 39 | tst_resm(TPASS, "expected ret success: " |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 40 | "returned value = %ld", TEST_RETURN); |
Jan Stancek | 5765e2c | 2012-10-26 15:31:16 +0200 | [diff] [blame] | 41 | return 0; |
| 42 | } else |
| 43 | tst_resm(TFAIL, "unexpected failure - " |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 44 | "returned value = %ld, expected: %ld", |
| 45 | TEST_RETURN, expected_ret); |
Jan Stancek | 5765e2c | 2012-10-26 15:31:16 +0200 | [diff] [blame] | 46 | return 1; |
| 47 | } |
| 48 | |
| 49 | int check_errno(long expected_errno) |
| 50 | { |
| 51 | if (TEST_ERRNO == expected_errno) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 52 | tst_resm(TPASS | TTERRNO, "expected failure"); |
Jan Stancek | 5765e2c | 2012-10-26 15:31:16 +0200 | [diff] [blame] | 53 | return 0; |
| 54 | } else if (TEST_ERRNO == 0) |
| 55 | tst_resm(TFAIL, "call succeeded unexpectedly"); |
| 56 | else |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 57 | tst_resm(TFAIL | TTERRNO, "unexpected failure - " |
| 58 | "expected = %ld : %s, actual", |
| 59 | expected_errno, strerror(expected_errno)); |
Jan Stancek | 5765e2c | 2012-10-26 15:31:16 +0200 | [diff] [blame] | 60 | return 1; |
| 61 | } |