psp_responder, used in the PSP self tests, fails when no PSP devices are
found. This makes the PSP test time out on connecting to the responder
and throw out an unpleasant Python exception.

Change psp_responder to open the server socket and listen for control
connections normally, and leave the skipping of the various test cases
which require a PSP device (~most, but not all of them) to the parent
test. This results in output like:

ok 1 psp.test_case # SKIP No PSP devices found
[...]
ok 12 psp.dev_get_device # SKIP No PSP devices found
ok 13 psp.dev_get_device_bad
ok 14 psp.dev_rotate # SKIP No PSP devices found
[...]

Signed-off-by: Cosmin Ratiu <[email protected]>
Reviewed-by: Carolina Jubran <[email protected]>
---
 tools/testing/selftests/drivers/net/psp_responder.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/drivers/net/psp_responder.c 
b/tools/testing/selftests/drivers/net/psp_responder.c
index 8d2bad134e63..b240888068d3 100644
--- a/tools/testing/selftests/drivers/net/psp_responder.c
+++ b/tools/testing/selftests/drivers/net/psp_responder.c
@@ -430,12 +430,8 @@ int main(int argc, char **argv)
        }
 
        dev_list = psp_dev_get_dump(ys);
-       if (ynl_dump_empty(dev_list)) {
-               if (ys->err.code)
-                       goto err_close;
-               fprintf(stderr, "No PSP devices\n");
-               goto err_close_silent;
-       }
+       if (ynl_dump_empty(dev_list) && ys->err.code)
+               goto err_close;
 
        ynl_dump_foreach(dev_list, d) {
                if (opts.devid) {
@@ -464,7 +460,7 @@ int main(int argc, char **argv)
                opts.devid = first_id;
        }
 
-       if (ver_ena != ver_cap) {
+       if (opts.devid && ver_ena != ver_cap) {
                ret = psp_dev_set_ena(ys, opts.devid, ver_cap);
                if (ret)
                        goto err_close;
@@ -472,7 +468,8 @@ int main(int argc, char **argv)
 
        ret = run_responder(ys, &opts);
 
-       if (ver_ena != ver_cap && psp_dev_set_ena(ys, opts.devid, ver_ena))
+       if (opts.devid && ver_ena != ver_cap &&
+           psp_dev_set_ena(ys, opts.devid, ver_ena))
                fprintf(stderr, "WARN: failed to set the PSP versions back\n");
 
        ynl_sock_destroy(ys);
-- 
2.45.0


Reply via email to