Content-Type: multipart/mixed; boundary="===============1097622764907970423==" MIME-Version: 1.0 From: ramesh.thomas at intel.com Subject: [Accel-config] [PATCH v1 6/6] accel-config: Disable mdev operations if mdev support unavailable Date: Sat, 23 Jan 2021 00:35:42 -0500 Message-ID: <20210123053542.615622-7-ramesh.thomas@intel.com> In-Reply-To: 20210123053542.615622-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============1097622764907970423== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ramesh Thomas If idxd_mdev module is not found disable mdev tests and operations. Signed-off-by: Ramesh Thomas --- test/libaccfg.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/test/libaccfg.c b/test/libaccfg.c index 031b7fa..0ff43ca 100644 --- a/test/libaccfg.c +++ b/test/libaccfg.c @@ -34,6 +34,8 @@ #define PORTAL_SIZE 4096 #define BUF_SIZE 4096 = +static bool mdev_disabled; + struct accfg_wq_ctx { int major; int minor; @@ -491,12 +493,14 @@ static int device_test_reset(struct accfg_ctx *ctx, c= onst char *dev_name, /* make sure device is disabled before configuration */ if (accfg_device_is_active(device)) { = - /* Remove all mdevs */ - uuid_clear(uuid); - rc =3D accfg_remove_mdev(device, uuid); - if (rc && !forced) { - fprintf(stderr, "mdev removal failed\n"); - return rc; + if (!mdev_disabled) { + /* Remove all mdevs */ + uuid_clear(uuid); + rc =3D accfg_remove_mdev(device, uuid); + if (rc && !forced) { + fprintf(stderr, "mdev removal failed\n"); + return rc; + } } = /* make sure each wq is disabled */ @@ -1008,6 +1012,7 @@ struct _test_case { do_test_fn test_fn; char *desc; bool enabled; + bool mdev; }; = static struct _test_case test_cases[] =3D { @@ -1015,26 +1020,31 @@ static struct _test_case test_cases[] =3D { .test_fn =3D test_config, .desc =3D "set and get configurations", .enabled =3D true, + .mdev =3D false, }, { .test_fn =3D test_max_wq_size, .desc =3D "max wq size", .enabled =3D true, + .mdev =3D false, }, { .test_fn =3D test_wq_boundary_conditions, .desc =3D "wq boundary conditions", .enabled =3D true, + .mdev =3D false, }, { .test_fn =3D test_mdev_1swq, .desc =3D "1swq type mdev creation and removal", .enabled =3D true, + .mdev =3D true, }, { .test_fn =3D test_mdev_1dwq, .desc =3D "1dwq type mdev creation and removal", .enabled =3D true, + .mdev =3D true, }, }; = @@ -1070,6 +1080,7 @@ static int idxd_kmod_init(struct kmod_ctx **ctx, stru= ct kmod_module **mod, if (rc < 0) { kmod_module_unref(*mdev_mod); *mdev_mod =3D NULL; + mdev_disabled =3D true; } rc =3D kmod_module_get_initstate(*mod); if (rc =3D=3D -ENOENT) @@ -1130,6 +1141,10 @@ int test_libaccfg(int loglevel, struct accfg_test *t= est, fprintf(stderr, "\naccfg-test%d *disabled*\n", i); continue; } + + if (test_cases[i].mdev && mdev_disabled) + continue; + printf("\nRunning accfg-test%d: %s\n", i, test_cases[i].desc); err =3D test_cases[i].test_fn(ctx); if (err < 0) { -- = 2.26.2 --===============1097622764907970423==--