Skip to contentSkip to conversation

selftests: lib: prime_numbers: update presence check

PATCH In review Sumit Semwal 2 participants 5 messages Jun 19, 2017 – Jun 20, 2017 2 messages not in the archive Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 selftests: lib: prime_numbers: update presence check

The test for prime numbers doesn't differentiate between missing prime_numbers.ko and failure in prime_numbers.ko.

Update it to check for presence of the file itself to skip, therefore correctly exercising the test failure case.

---
 tools/testing/selftests/lib/prime_numbers.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/lib/prime_numbers.sh +3 -2
index da4cbcd766f5..492f0dcdf088 100755
@@ -1,8 +1,9 @@
 #!/bin/sh
 # Checks fast/slow prime_number generation for inconsistencies
 
-if ! /sbin/modprobe -q -r prime_numbers; then
-	echo "prime_numbers: [SKIP]"
+if ! find /lib/modules/$(uname -r) -type f -name prime_numbers.ko | grep -q .;
+then
+	echo "prime_numbers: prime_numbers.ko not found: [SKIP]"
 	exit 77
 fi
 
Signature · 1 line
2.7.4
#1 lore raw

Quoting Sumit Semwal (2017-06-19 14:44:32)

Quoted 5 lines

The test for prime numbers doesn't differentiate between missing prime_numbers.ko and failure in prime_numbers.ko.

Update it to check for presence of the file itself to skip, therefore correctly exercising the test failure case.

modprobe -r shouldn't be executing the module? But you still need to unload the module before you can load it with the selftest module parameters. If you can't unload the module due to an earlier failure, you cannot discern whether or not the module itself is at fault, so still want to SKIP.
-Chris

#2 lore raw

Hi Chris,

Quoted 4 lines · Chris Wilson

Quoting Sumit Semwal (2017-06-19 14:44:32)

Quoted 3 lines

The test for prime numbers doesn't differentiate between missing prime_numbers.ko and failure in prime_numbers.ko.

Quoted 8 lines
Quoted 2 lines

Update it to check for presence of the file itself to skip, therefore correctly exercising the test failure case.

modprobe -r shouldn't be executing the module? But you still need to unload the module before you can load it with the selftest module parameters. If you can't unload the module due to an earlier failure, you cannot discern whether or not the module itself is at fault, so still want to SKIP.

My bad here: I missed the '-r' in the first modprobe.

I am wondering if 'modprobe -q -n' won't suffice, as it is a dry-run only, but will still search for the module? Unless of course, there's something specific about '-q -r' that seems better still?

Shuah,
Could you please disregard this patch, and the other patch I sent:
will send out a new version soon.

Quoted 1 line

-Chris

Best,
Sumit.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 23 lines · Chris Wilson

Quoting Sumit Semwal (2017-06-19 15:46:20)

Quoted 16 lines

Hi Chris,

Quoted 4 lines · Chris Wilson

Quoting Sumit Semwal (2017-06-19 14:44:32)

Quoted 3 lines

The test for prime numbers doesn't differentiate between missing prime_numbers.ko and failure in prime_numbers.ko.

Quoted 8 lines
Quoted 2 lines

Update it to check for presence of the file itself to skip, therefore correctly exercising the test failure case.

modprobe -r shouldn't be executing the module? But you still need to unload the module before you can load it with the selftest module parameters. If you can't unload the module due to an earlier failure, you cannot discern whether or not the module itself is at fault, so still want to SKIP.

Quoted 5 lines

My bad here: I missed the '-r' in the first modprobe.

I am wondering if 'modprobe -q -n' won't suffice, as it is a dry-run only, but will still search for the module? Unless of course, there's something specific about '-q -r' that seems better still?

Quoted 7 lines

I think there are two things to be tested here, both causing a SKIP.

- If the module doesn't exist at all; modprobe -q -n seems sensible for querying its existence.

- If the module cannot be [un]loaded; for which I was using the modprobe -q -r. If we can't unload the module, then we can't test :)

:) Right; then the question is, for prime_numbers.ko, do we need to differentiate between these 2 SKIPs?

The unloading of the prime_numbers module before running the test is required since it isn't a standalone test module - unlike the test_bitmap and test_printf ones.

So then, for prime_numbers: if distinguishing between the two cases you mentioned above isn't important, we can just keep your original code. If it is important to distinguish, I can add the -q -n test to query existence separately.

For test_bitmap and test_printf tests, I think I will just go ahead with -q -n itself, since we can assume that the test modules will only be loaded/unloaded via these tests I guess?

Quoted 2 lines

-Chris

Best,
Sumit.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Hi Chris,

Quoted 48 lines · Chris Wilson

Quoting Sumit Semwal (2017-06-19 16:11:33)

Quoted 26 lines · Chris Wilson
Quoted 25 lines

Quoting Sumit Semwal (2017-06-19 15:46:20)

Quoted 16 lines

Hi Chris,

Quoted 4 lines · Chris Wilson

Quoting Sumit Semwal (2017-06-19 14:44:32)

Quoted 3 lines

The test for prime numbers doesn't differentiate between missing prime_numbers.ko and failure in prime_numbers.ko.

Quoted 8 lines
Quoted 2 lines

Update it to check for presence of the file itself to skip, therefore correctly exercising the test failure case.

modprobe -r shouldn't be executing the module? But you still need to unload the module before you can load it with the selftest module parameters. If you can't unload the module due to an earlier failure, you cannot discern whether or not the module itself is at fault, so still want to SKIP.

Quoted 5 lines

My bad here: I missed the '-r' in the first modprobe.

I am wondering if 'modprobe -q -n' won't suffice, as it is a dry-run only, but will still search for the module? Unless of course, there's something specific about '-q -r' that seems better still?

I think there are two things to be tested here, both causing a SKIP.

Quoted 8 lines
Quoted 5 lines

- If the module doesn't exist at all; modprobe -q -n seems sensible for querying its existence.

- If the module cannot be [un]loaded; for which I was using the modprobe -q -r. If we can't unload the module, then we can't test :)

:) Right; then the question is, for prime_numbers.ko, do we need to differentiate between these 2 SKIPs?

I don't see a downside to being verbose here. It both helps explain the test and alert the user about the remedy if desired.

Quoted 9 lines

The unloading of the prime_numbers module before running the test is required since it isn't a standalone test module - unlike the test_bitmap and test_printf ones.

So then, for prime_numbers: if distinguishing between the two cases you mentioned above isn't important, we can just keep your original code. If it is important to distinguish, I can add the -q -n test to query existence separately.

Quoted 6 lines
Quoted 3 lines

For test_bitmap and test_printf tests, I think I will just go ahead with -q -n itself, since we can assume that the test modules will only be loaded/unloaded via these tests I guess?

Yes. For that style of standalone test module, if the test module is still around it is probably for a reason :)

:) These test cases seem to try to load the module (and hence run the tests), and then try to unload the module right after, so I think we should be ok there.

Quoted 1 line

-Chris