Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / fs / btrfs / tests / extent-buffer-tests.c
index b9142c6..7d72eab 100644 (file)
@@ -1,19 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2013 Fusion IO.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License v2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
  */
 
 #include <linux/slab.h>
@@ -39,31 +26,31 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        u32 value_len = strlen(value);
        int ret = 0;
 
-       test_msg("Running btrfs_split_item tests\n");
+       test_msg("running btrfs_split_item tests");
 
        fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
        if (!fs_info) {
-               test_msg("Could not allocate fs_info\n");
+               test_err("could not allocate fs_info");
                return -ENOMEM;
        }
 
        root = btrfs_alloc_dummy_root(fs_info);
        if (IS_ERR(root)) {
-               test_msg("Could not allocate root\n");
+               test_err("could not allocate root");
                ret = PTR_ERR(root);
                goto out;
        }
 
        path = btrfs_alloc_path();
        if (!path) {
-               test_msg("Could not allocate path\n");
+               test_err("could not allocate path");
                ret = -ENOMEM;
                goto out;
        }
 
        path->nodes[0] = eb = alloc_dummy_extent_buffer(fs_info, nodesize);
        if (!eb) {
-               test_msg("Could not allocate dummy buffer\n");
+               test_err("could not allocate dummy buffer");
                ret = -ENOMEM;
                goto out;
        }
@@ -88,7 +75,7 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
         */
        ret = btrfs_split_item(NULL, root, path, &key, 17);
        if (ret) {
-               test_msg("Split item failed %d\n", ret);
+               test_err("split item failed %d", ret);
                goto out;
        }
 
@@ -99,14 +86,14 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        btrfs_item_key_to_cpu(eb, &key, 0);
        if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
            key.offset != 0) {
-               test_msg("Invalid key at slot 0\n");
+               test_err("invalid key at slot 0");
                ret = -EINVAL;
                goto out;
        }
 
        item = btrfs_item_nr(0);
        if (btrfs_item_size(eb, item) != strlen(split1)) {
-               test_msg("Invalid len in the first split\n");
+               test_err("invalid len in the first split");
                ret = -EINVAL;
                goto out;
        }
@@ -114,8 +101,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 0),
                           strlen(split1));
        if (memcmp(buf, split1, strlen(split1))) {
-               test_msg("Data in the buffer doesn't match what it should "
-                        "in the first split have='%.*s' want '%s'\n",
+               test_err(
+"data in the buffer doesn't match what it should in the first split have='%.*s' want '%s'",
                         (int)strlen(split1), buf, split1);
                ret = -EINVAL;
                goto out;
@@ -124,14 +111,14 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        btrfs_item_key_to_cpu(eb, &key, 1);
        if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
            key.offset != 3) {
-               test_msg("Invalid key at slot 1\n");
+               test_err("invalid key at slot 1");
                ret = -EINVAL;
                goto out;
        }
 
        item = btrfs_item_nr(1);
        if (btrfs_item_size(eb, item) != strlen(split2)) {
-               test_msg("Invalid len in the second split\n");
+               test_err("invalid len in the second split");
                ret = -EINVAL;
                goto out;
        }
@@ -139,8 +126,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 1),
                           strlen(split2));
        if (memcmp(buf, split2, strlen(split2))) {
-               test_msg("Data in the buffer doesn't match what it should "
-                        "in the second split\n");
+               test_err(
+       "data in the buffer doesn't match what it should in the second split");
                ret = -EINVAL;
                goto out;
        }
@@ -149,21 +136,21 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        /* Do it again so we test memmoving the other items in the leaf */
        ret = btrfs_split_item(NULL, root, path, &key, 4);
        if (ret) {
-               test_msg("Second split item failed %d\n", ret);
+               test_err("second split item failed %d", ret);
                goto out;
        }
 
        btrfs_item_key_to_cpu(eb, &key, 0);
        if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
            key.offset != 0) {
-               test_msg("Invalid key at slot 0\n");
+               test_err("invalid key at slot 0");
                ret = -EINVAL;
                goto out;
        }
 
        item = btrfs_item_nr(0);
        if (btrfs_item_size(eb, item) != strlen(split3)) {
-               test_msg("Invalid len in the first split\n");
+               test_err("invalid len in the first split");
                ret = -EINVAL;
                goto out;
        }
@@ -171,8 +158,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 0),
                           strlen(split3));
        if (memcmp(buf, split3, strlen(split3))) {
-               test_msg("Data in the buffer doesn't match what it should "
-                        "in the third split");
+               test_err(
+       "data in the buffer doesn't match what it should in the third split");
                ret = -EINVAL;
                goto out;
        }
@@ -180,14 +167,14 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        btrfs_item_key_to_cpu(eb, &key, 1);
        if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
            key.offset != 1) {
-               test_msg("Invalid key at slot 1\n");
+               test_err("invalid key at slot 1");
                ret = -EINVAL;
                goto out;
        }
 
        item = btrfs_item_nr(1);
        if (btrfs_item_size(eb, item) != strlen(split4)) {
-               test_msg("Invalid len in the second split\n");
+               test_err("invalid len in the second split");
                ret = -EINVAL;
                goto out;
        }
@@ -195,8 +182,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 1),
                           strlen(split4));
        if (memcmp(buf, split4, strlen(split4))) {
-               test_msg("Data in the buffer doesn't match what it should "
-                        "in the fourth split\n");
+               test_err(
+       "data in the buffer doesn't match what it should in the fourth split");
                ret = -EINVAL;
                goto out;
        }
@@ -204,14 +191,14 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        btrfs_item_key_to_cpu(eb, &key, 2);
        if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
            key.offset != 3) {
-               test_msg("Invalid key at slot 2\n");
+               test_err("invalid key at slot 2");
                ret = -EINVAL;
                goto out;
        }
 
        item = btrfs_item_nr(2);
        if (btrfs_item_size(eb, item) != strlen(split2)) {
-               test_msg("Invalid len in the second split\n");
+               test_err("invalid len in the second split");
                ret = -EINVAL;
                goto out;
        }
@@ -219,8 +206,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
        read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 2),
                           strlen(split2));
        if (memcmp(buf, split2, strlen(split2))) {
-               test_msg("Data in the buffer doesn't match what it should "
-                        "in the last chunk\n");
+               test_err(
+       "data in the buffer doesn't match what it should in the last chunk");
                ret = -EINVAL;
                goto out;
        }
@@ -233,6 +220,6 @@ out:
 
 int btrfs_test_extent_buffer_operations(u32 sectorsize, u32 nodesize)
 {
-       test_msg("Running extent buffer operation tests\n");
+       test_msg("running extent buffer operation tests");
        return test_btrfs_split_item(sectorsize, nodesize);
 }