blob: 49f61949754a9955699409f6af5e6845ad7a7a06 [file] [log] [blame]
Jan Stancek5765e2c2012-10-26 15:31:16 +02001/*
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 Stancek5765e2c2012-10-26 15:31:16 +020026#include "migrate_pages_common.h"
27
28void set_bit(unsigned long *b, unsigned int n, unsigned int v)
29{
30 if (v)
Wanlong Gao354ebb42012-12-07 10:10:04 +080031 b[n / bitsperlong] |= 1UL << (n % bitsperlong);
Jan Stancek5765e2c2012-10-26 15:31:16 +020032 else
Wanlong Gao354ebb42012-12-07 10:10:04 +080033 b[n / bitsperlong] &= ~(1UL << (n % bitsperlong));
Jan Stancek5765e2c2012-10-26 15:31:16 +020034}
35
36int check_ret(long expected_ret)
37{
38 if (expected_ret == TEST_RETURN) {
39 tst_resm(TPASS, "expected ret success: "
Wanlong Gao354ebb42012-12-07 10:10:04 +080040 "returned value = %ld", TEST_RETURN);
Jan Stancek5765e2c2012-10-26 15:31:16 +020041 return 0;
42 } else
43 tst_resm(TFAIL, "unexpected failure - "
Wanlong Gao354ebb42012-12-07 10:10:04 +080044 "returned value = %ld, expected: %ld",
45 TEST_RETURN, expected_ret);
Jan Stancek5765e2c2012-10-26 15:31:16 +020046 return 1;
47}
48
49int check_errno(long expected_errno)
50{
51 if (TEST_ERRNO == expected_errno) {
Wanlong Gao354ebb42012-12-07 10:10:04 +080052 tst_resm(TPASS | TTERRNO, "expected failure");
Jan Stancek5765e2c2012-10-26 15:31:16 +020053 return 0;
54 } else if (TEST_ERRNO == 0)
55 tst_resm(TFAIL, "call succeeded unexpectedly");
56 else
Wanlong Gao354ebb42012-12-07 10:10:04 +080057 tst_resm(TFAIL | TTERRNO, "unexpected failure - "
58 "expected = %ld : %s, actual",
59 expected_errno, strerror(expected_errno));
Jan Stancek5765e2c2012-10-26 15:31:16 +020060 return 1;
61}