Skip to contentSkip to conversation

block/ltp_block_dev.c: Update tests for the newer kernel

PATCH New Xiao Yang 2 participants 7 messages Dec 28, 2018 – Feb 13, 2019

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/1 block/ltp_block_dev.c: Update tests for the newer kernel

The maximum major number is set to 511 since kernel commit 133d55c, so register_blkdev() with a major number grater than the maximum(511) will get failure instead of pass as expected.

1) Update tests for the newer behavior of register_blkdev().
2) Add more major numbers(i.e. 511 and 512) to test.

Note:
It is possible that specified major numbers have been used by system, so we skip them if register_blkdev() returns EBUSY.

---
 .../block/block_dev_kernel/ltp_block_dev.c         | 47 +++++++++++++---------
 1 file changed, 29 insertions(+), 18 deletions(-)
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +29 -18
index d573085..8aeb6bb 100644
@@ -52,7 +52,8 @@ MODULE_LICENSE("GPL");
  *             |--------------------------+---------+-------------
  *             | [1..255]                 | valid   | tc03
  *             |--------------------------+---------+-------------
- *             | [256..UINT_MAX]          | valid   | tc04, tc05
+ *             | [256..511]               | valid   | tc04
+ *             | [512..UINT_MAX]          | invalid | tc05
  *  -----------+--------------------------+---------+-------------
  *  name       | [valid pointer to a zero |         |
  *             |  terminated string]      | valid   | tc01, tc02
@@ -205,17 +206,24 @@ static int tc03(void)
 static int tc04(void)
 {
 	int major, pass = 8;
+	unsigned int i, test_major[2] = {256, 511};
 
-	prk_info("Test Case 4: register_blkdev() with major=256\n");
+	prk_info("Test Case 4: register_blkdev() with major=256/511\n");
 
-	major = register_blkdev(256, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i < sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
 
-	if (major == 0) {
-		unregister_blkdev(256, BLK_DEV_NAME);
-	} else {
-		pass = 0;
-		prk_debug("register_blkdev() failed with error %i\n", major);
+		if (major == 0) {
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+		} else if (major == -EBUSY) {
+			prk_debug("device was busy, register_blkdev() with "
+				  "major %u skipped\n", test_major[i]);
+		} else {
+			pass = 0;
+			prk_debug("register_blkdev() with major %u got "
+				  "error %i\n", test_major[i], major);
+		}
 	}
 
 	prk_info("Test Case Result: %s\n", result_str(pass));
@@ -225,18 +233,21 @@ static int tc04(void)
 static int tc05(void)
 {
 	int major, pass = 16;
+	unsigned int i, test_major[2] = {512, UINT_MAX};
 
-	prk_info("Test Case 5: register_blkdev() with major=%u\n", UINT_MAX);
+	prk_info("Test Case 5: register_blkdev() with major=512/%u\n", UINT_MAX);
 
-	major = register_blkdev(UINT_MAX, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i < sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
 
-	if (major == 0) {
-		unregister_blkdev(UINT_MAX, BLK_DEV_NAME);
-	} else {
-		prk_debug("reg blkdev with major %d failed with error %i\n",
-			UINT_MAX, major);
-		pass = 0;
+		if (major >= 0) {
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+			pass = 0;
+		} else {
+			prk_debug("register_blkdev() with major %u got "
+				  "error %i\n", test_major[i], major);
+		}
 	}
 
 	prk_info("Test Case Result: %s\n", result_str(pass));
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 block/ltp_block_dev.c: Update tests for the newer kernel

Hi Xiao,

...

Quoted 12 lines

+++ b/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +2 -1
@@ -52,7 +52,8 @@ MODULE_LICENSE("GPL");
  *             |--------------------------+---------+-------------
  *             | [1..255]                 | valid   | tc03
  *             |--------------------------+---------+-------------
- *             | [256..UINT_MAX]          | valid   | tc04, tc05
+ *             | [256..511]               | valid   | tc04
+ *             | [512..UINT_MAX]          | invalid | tc05
  *  -----------+--------------------------+---------+-------------
  *  name       | [valid pointer to a zero |         |
  *             |  terminated string]      | valid   | tc01, tc02

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c static int tc03(void) · line 211

Quoted 7 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +2 -1
@@ -205,17 +206,24 @@ static int tc03(void)
 static int tc04(void)
 {
 	int major, pass = 8;
+	unsigned int i, test_major[2] = {256, 511};
 
-	prk_info("Test Case 4: register_blkdev() with major=256\n");
+	prk_info("Test Case 4: register_blkdev() with major=256/511\n");

Could we use test_major[0] and test_major[1] here?

Quoted 41 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +18 -12
-	major = register_blkdev(256, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i < sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
 
-	if (major == 0) {
-		unregister_blkdev(256, BLK_DEV_NAME);
-	} else {
-		pass = 0;
-		prk_debug("register_blkdev() failed with error %i\n", major);
+		if (major == 0) {
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+		} else if (major == -EBUSY) {
+			prk_debug("device was busy, register_blkdev() with "
+				  "major %u skipped\n", test_major[i]);
+		} else {
+			pass = 0;
+			prk_debug("register_blkdev() with major %u got "
+				  "error %i\n", test_major[i], major);
+		}
 	}
 
 	prk_info("Test Case Result: %s\n", result_str(pass));
@@ -225,18 +233,21 @@ static int tc04(void)
 static int tc05(void)
 {
 	int major, pass = 16;
+	unsigned int i, test_major[2] = {512, UINT_MAX};
 
-	prk_info("Test Case 5: register_blkdev() with major=%u\n", UINT_MAX);
+	prk_info("Test Case 5: register_blkdev() with major=512/%u\n", UINT_MAX);
 
-	major = register_blkdev(UINT_MAX, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i < sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
 
-	if (major == 0) {
-		unregister_blkdev(UINT_MAX, BLK_DEV_NAME);

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c static int tc04(void) · line 249

Quoted 10 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +6 -4
-	} else {
-		prk_debug("reg blkdev with major %d failed with error %i\n",
-			UINT_MAX, major);
-		pass = 0;
+		if (major >= 0) {
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+			pass = 0;
+		} else {
+			prk_debug("register_blkdev() with major %u got "
+				  "error %i\n", test_major[i], major);

I'd prefer to have string on a single line.

+ I'd replace licence info at the top with SPDX-License-Identifier.

Otherwise it looks good to me.

Kind regards,
Petr

author
#2 lore raw

PATCH 1/1 block/ltp_block_dev.c: Update tests for the newer kernel

Quoted 71 lines · Petr Vorel

Hi Xiao,

...

Quoted 12 lines

+++ b/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +2 -1
@@ -52,7 +52,8 @@ MODULE_LICENSE("GPL");
   *             |--------------------------+---------+-------------
   *             | [1..255]                 | valid   | tc03
   *             |--------------------------+---------+-------------
- *             | [256..UINT_MAX]          | valid   | tc04, tc05
+ *             | [256..511]               | valid   | tc04
+ *             | [512..UINT_MAX]          | invalid | tc05
   *  -----------+--------------------------+---------+-------------
   *  name       | [valid pointer to a zero |         |
   *             |  terminated string]      | valid   | tc01, tc02

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c static int tc03(void) · line 210

Quoted 6 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +2 -1
@@ -205,17 +206,24 @@ static int tc03(void)
  static int tc04(void)
  {
  	int major, pass = 8;
+	unsigned int i, test_major[2] = {256, 511};
-	prk_info("Test Case 4: register_blkdev() with major=256\n");
+	prk_info("Test Case 4: register_blkdev() with major=256/511\n");

Could we use test_major[0] and test_major[1] here?

Quoted 36 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +18 -12
-	major = register_blkdev(256, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i<  sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
-	if (major == 0) {
-		unregister_blkdev(256, BLK_DEV_NAME);
-	} else {
-		pass = 0;
-		prk_debug("register_blkdev() failed with error %i\n", major);
+		if (major == 0) {
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+		} else if (major == -EBUSY) {
+			prk_debug("device was busy, register_blkdev() with "
+				  "major %u skipped\n", test_major[i]);
+		} else {
+			pass = 0;
+			prk_debug("register_blkdev() with major %u got "
+				  "error %i\n", test_major[i], major);
+		}
  	}
  	prk_info("Test Case Result: %s\n", result_str(pass));
@@ -225,18 +233,21 @@ static int tc04(void)
  static int tc05(void)
  {
  	int major, pass = 16;
+	unsigned int i, test_major[2] = {512, UINT_MAX};
-	prk_info("Test Case 5: register_blkdev() with major=%u\n", UINT_MAX);
+	prk_info("Test Case 5: register_blkdev() with major=512/%u\n", UINT_MAX);
-	major = register_blkdev(UINT_MAX, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i<  sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
-	if (major == 0) {
-		unregister_blkdev(UINT_MAX, BLK_DEV_NAME);

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c static int tc04(void) · line 246

Quoted 10 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +6 -4
-	} else {
-		prk_debug("reg blkdev with major %d failed with error %i\n",
-			UINT_MAX, major);
-		pass = 0;
+		if (major>= 0) {
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+			pass = 0;
+		} else {
+			prk_debug("register_blkdev() with major %u got "
+				  "error %i\n", test_major[i], major);

I'd prefer to have string on a single line.

Quoted 3 lines

+ I'd replace licence info at the top with SPDX-License-Identifier.

Otherwise it looks good to me.

Hi Petr,

Thanks for your comment, and i will send v2 patch as you suggested. :-)

Best Regards,
Xiao Yang

Quoted 6 lines

Kind regards,
Petr

.

author
#3 lore raw

PATCH v2 1/1 block/ltp_block_dev.c: Update tests for the newer kernel

In reply to Petr Vorel

The maximum major number is set to 511 since kernel commit 133d55c, so register_blkdev() with a major number grater than the maximum(511) will get failure instead of pass as expected.

1) Update tests for the newer behavior of register_blkdev().
2) Add more major numbers(i.e. 511 and 512) to test.

Note:
It is possible that specified major numbers have been used by system, so we skip them if register_blkdev() returns EBUSY.

---
 .../block/block_dev_kernel/ltp_block_dev.c         | 64 +++++++++++-----------
 1 file changed, 32 insertions(+), 32 deletions(-)
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +32 -32
index d573085..b0f6ce5 100644
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2013 Oracle and/or its affiliates. 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 as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it would 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 the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
  * Only those functions are tested here which are declared in <linux/fs.h>
  *
  * Changes:
@@ -52,7 +39,8 @@ MODULE_LICENSE("GPL");
  *             |--------------------------+---------+-------------
  *             | [1..255]                 | valid   | tc03
  *             |--------------------------+---------+-------------
- *             | [256..UINT_MAX]          | valid   | tc04, tc05
+ *             | [256..511]               | valid   | tc04
+ *             | [512..UINT_MAX]          | invalid | tc05
  *  -----------+--------------------------+---------+-------------
  *  name       | [valid pointer to a zero |         |
  *             |  terminated string]      | valid   | tc01, tc02
@@ -205,17 +193,25 @@ static int tc03(void)
 static int tc04(void)
 {
 	int major, pass = 8;
+	unsigned int i, test_major[2] = {256, 511};
 
-	prk_info("Test Case 4: register_blkdev() with major=256\n");
+	prk_info("Test Case 4: register_blkdev() with major=%u/%u\n",
+		 test_major[0], test_major[1]);
 
-	major = register_blkdev(256, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i < sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
 
-	if (major == 0) {
-		unregister_blkdev(256, BLK_DEV_NAME);
-	} else {
-		pass = 0;
-		prk_debug("register_blkdev() failed with error %i\n", major);
+		if (major == 0) {
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+		} else if (major == -EBUSY) {
+			prk_debug("device was busy, register_blkdev() with major %u skipped\n",
+				  test_major[i]);
+		} else {
+			pass = 0;
+			prk_debug("register_blkdev() with major %u got error %i\n",
+				  test_major[i], major);
+		}
 	}
 
 	prk_info("Test Case Result: %s\n", result_str(pass));
@@ -225,18 +221,22 @@ static int tc04(void)
 static int tc05(void)
 {
 	int major, pass = 16;
+	unsigned int i, test_major[2] = {512, UINT_MAX};
 
-	prk_info("Test Case 5: register_blkdev() with major=%u\n", UINT_MAX);
+	prk_info("Test Case 5: register_blkdev() with major=%u/%u\n",
+		 test_major[0], test_major[1]);
 
-	major = register_blkdev(UINT_MAX, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i < sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
 
-	if (major == 0) {
-		unregister_blkdev(UINT_MAX, BLK_DEV_NAME);
-	} else {
-		prk_debug("reg blkdev with major %d failed with error %i\n",
-			UINT_MAX, major);
-		pass = 0;
+		if (major == 0) {
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+			pass = 0;
+		} else {
+			prk_debug("register_blkdev() with major %u got error %i\n",
+				  test_major[i], major);
+		}
 	}
 
 	prk_info("Test Case Result: %s\n", result_str(pass));
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v2 1/1 block/ltp_block_dev.c: Update tests for the newer kernel

Hi Xiao,

Quoted 7 lines

The maximum major number is set to 511 since kernel commit 133d55c, so register_blkdev() with a major number grater than the maximum(511) will get failure instead of pass as expected.

1) Update tests for the newer behavior of register_blkdev().
2) Add more major numbers(i.e. 511 and 512) to test.

Quoted 6 lines

Note:
It is possible that specified major numbers have been used by system, so we skip them if register_blkdev() returns EBUSY.

Thanks for your updates.

Quoted 5 lines
---
 .../block/block_dev_kernel/ltp_block_dev.c         | 64 +++++++++++-----------
 1 file changed, 32 insertions(+), 32 deletions(-)
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +0 -0

...

Quoted 2 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +0 -0
@@ -225,18 +221,22 @@ static int tc04(void)
 static int tc05(void)

...

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c static int tc04(void) · line 233

Quoted 13 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +4 -8
-	major = register_blkdev(UINT_MAX, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i < sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
 
-	if (major == 0) {
-		unregister_blkdev(UINT_MAX, BLK_DEV_NAME);
-	} else {
-		prk_debug("reg blkdev with major %d failed with error %i\n",
-			UINT_MAX, major);
-		pass = 0;
+		if (major == 0) {

In v1 this was major >= 0.
It looks to me as well that major == 0 is correct.

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c static int tc04(void) · line 242

Quoted 9 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +6 -0
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+			pass = 0;
+		} else {
+			prk_debug("register_blkdev() with major %u got error %i\n",
+				  test_major[i], major);
+		}
 	}
 
 	prk_info("Test Case Result: %s\n", result_str(pass));

Kind regards,
Petr

author
#5 lore raw

PATCH v2 1/1 block/ltp_block_dev.c: Update tests for the newer kernel

Quoted 24 lines · Petr Vorel

Hi Xiao,

Quoted 10 lines

The maximum major number is set to 511 since kernel commit 133d55c, so register_blkdev() with a major number grater than the maximum(511) will get failure instead of pass as expected.
1) Update tests for the newer behavior of register_blkdev().
2) Add more major numbers(i.e. 511 and 512) to test.
Note:
It is possible that specified major numbers have been used by system, so we skip them if register_blkdev() returns EBUSY.

Thanks for your updates.

Quoted 4 lines
---
  .../block/block_dev_kernel/ltp_block_dev.c         | 64 +++++++++++-----------
  1 file changed, 32 insertions(+), 32 deletions(-)
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +0 -0

...

Quoted 2 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +0 -0
@@ -225,18 +221,22 @@ static int tc04(void)
  static int tc05(void)

...

Quoted 14 lines

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c static int tc04(void) · line 233

Quoted 12 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +4 -8
-	major = register_blkdev(UINT_MAX, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i<  sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
-	if (major == 0) {
-		unregister_blkdev(UINT_MAX, BLK_DEV_NAME);
-	} else {
-		prk_debug("reg blkdev with major %d failed with error %i\n",
-			UINT_MAX, major);
-		pass = 0;
+		if (major == 0) {

In v1 this was major>= 0.
It looks to me as well that major == 0 is correct.

Hi Petr,

Thanks for your ack. :-)

According to the comment of register_blkdev() at block/genhd.c in kernel, i think register_blkdev() only
returns zero or a negative error if a positive major number(i.e. nonzero) is passed to register_blkdev().
---------------------------------------------------------------------------------------------------------------------------------

||

* - if a major device number was requested in range [1..BLKDEV_MAJOR_MAX-1]
* then the function returns zero on success, or a negative error code
* - if any unused major number was requested with @major = 0 parameter
* then the return value is the allocated major number in range
* [1..BLKDEV_MAJOR_MAX-1] or a negative error code otherwise

---------------------------------------------------------------------------------------------------------------------------------

So i perfer to use major == 0. :-)

Best Regards,
Xiao Yang

Quoted 13 lines

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c static int tc04(void) · line 242

Quoted 8 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +6 -0
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+			pass = 0;
+		} else {
+			prk_debug("register_blkdev() with major %u got error %i\n",
+				  test_major[i], major);
+		}
  	}
  	prk_info("Test Case Result: %s\n", result_str(pass));

Kind regards,
Petr

Quoted 2 lines

.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190211/0df21593/attachment.html>

author
#6 lore raw

PATCH v2 1/1 block/ltp_block_dev.c: Update tests for the newer kernel

In reply to Petr Vorel

Hi Petr,

Pushed, thanks for your review again. :-)

Best Regards,
Xiao Yang

Quoted 54 lines · Petr Vorel

Hi Xiao,

Quoted 10 lines

The maximum major number is set to 511 since kernel commit 133d55c, so register_blkdev() with a major number grater than the maximum(511) will get failure instead of pass as expected.
1) Update tests for the newer behavior of register_blkdev().
2) Add more major numbers(i.e. 511 and 512) to test.
Note:
It is possible that specified major numbers have been used by system, so we skip them if register_blkdev() returns EBUSY.

Thanks for your updates.

Quoted 4 lines
---
  .../block/block_dev_kernel/ltp_block_dev.c         | 64 +++++++++++-----------
  1 file changed, 32 insertions(+), 32 deletions(-)
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +0 -0

...

Quoted 2 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +0 -0
@@ -225,18 +221,22 @@ static int tc04(void)
  static int tc05(void)

...

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c static int tc04(void) · line 233

Quoted 12 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +4 -8
-	major = register_blkdev(UINT_MAX, BLK_DEV_NAME);
-	prk_debug("major = %i\n", major);
+	for (i = 0; i<  sizeof(test_major) / sizeof(unsigned int); i++) {
+		major = register_blkdev(test_major[i], BLK_DEV_NAME);
+		prk_debug("major = %i\n", major);
-	if (major == 0) {
-		unregister_blkdev(UINT_MAX, BLK_DEV_NAME);
-	} else {
-		prk_debug("reg blkdev with major %d failed with error %i\n",
-			UINT_MAX, major);
-		pass = 0;
+		if (major == 0) {

In v1 this was major>= 0.
It looks to me as well that major == 0 is correct.

testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c static int tc04(void) · line 242

Quoted 8 lines
testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c +6 -0
+			unregister_blkdev(test_major[i], BLK_DEV_NAME);
+			pass = 0;
+		} else {
+			prk_debug("register_blkdev() with major %u got error %i\n",
+				  test_major[i], major);
+		}
  	}
  	prk_info("Test Case Result: %s\n", result_str(pass));

Kind regards,
Petr

.