From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============4952323327538786847==" MIME-Version: 1.0 From: Jiang, Dave Subject: [Accel-config] Re: [PATCH v1 11/11] accel-config: Clear conditions blocking unit test after failure Date: Sat, 05 Dec 2020 00:09:43 +0000 Message-ID: <4cf803a6e44a41a5acf99924efbf2011@intel.com> In-Reply-To: 20201202193057.299615-12-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============4952323327538786847== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: ramesh.thomas(a)intel.com > Sent: Wednesday, December 2, 2020 12:31 PM > To: accel-config(a)lists.01.org > Cc: Thomas, Ramesh ; Luck, Tony > ; Jiang, Dave > Subject: [PATCH v1 11/11] accel-config: Clear conditions blocking unit te= st > after failure > = > From: Ramesh Thomas > = > Not disabling components and resetting driver blocks future > tests. This change force closes mdevs, wqs, devices and resets > the driver. Also at start loads driver if it was not. > = > Signed-off-by: Ramesh Thomas Reviewed-by: Dave Jiang > --- > test/libaccfg.c | 53 +++++++++++++++++++++++++++++++++++++----------- > - > 1 file changed, 40 insertions(+), 13 deletions(-) > = > diff --git a/test/libaccfg.c b/test/libaccfg.c > index d423d1d..94d6156 100644 > --- a/test/libaccfg.c > +++ b/test/libaccfg.c > @@ -475,12 +475,14 @@ static int check_engine(struct accfg_ctx *ctx, int > dev_id, int engine_id, > return 0; > } > = > -static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name) > +static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name, > + bool forced) > { > int rc =3D 0; > struct accfg_device *device; > struct accfg_wq *wq; > enum accfg_wq_state wq_state; > + uuid_t uuid; > = > device =3D accfg_ctx_device_get_by_name(ctx, dev_name); > if (!device) > @@ -488,6 +490,15 @@ static int device_test_reset(struct accfg_ctx *ctx, > const 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; > + } > + > /* make sure each wq is disabled */ > accfg_wq_foreach(device, wq) { > wq_state =3D accfg_wq_get_state(wq); > @@ -498,14 +509,14 @@ static int device_test_reset(struct accfg_ctx *ctx, > const char *dev_name) > } > = > rc =3D accfg_wq_disable(wq, true); > - if (rc < 0) { > + if (rc < 0 && !forced) { > fprintf(stderr, "wq under %s disable > failed\n", dev_name); > return rc; > } > } > rc =3D accfg_device_disable(device, true); > if (rc < 0) { > - fprintf(stderr, "%s should be disabled before config > but failed\n", dev_name); > + fprintf(stderr, "%s disabling failed\n", dev_name); > return rc; > } > } > @@ -514,6 +525,17 @@ static int device_test_reset(struct accfg_ctx *ctx, > const char *dev_name) > = > } > = > +static void test_cleanup(struct accfg_ctx *ctx) > +{ > + struct accfg_device *device; > + > + accfg_device_foreach(ctx, device) { > + const char *dev_name =3D > accfg_device_get_devname(device); > + > + device_test_reset(ctx, dev_name, true); > + } > +} > + > static int set_config(struct accfg_ctx *ctx, const char *dev_name) > { > int rc =3D 0; > @@ -780,7 +802,7 @@ static int test_config(struct accfg_ctx *ctx) > { > int rc =3D 0; > = > - rc =3D device_test_reset(ctx, "dsa0"); > + rc =3D device_test_reset(ctx, "dsa0", false); > if (rc !=3D 0) > return rc; > = > @@ -794,7 +816,7 @@ static int test_config(struct accfg_ctx *ctx) > if (rc !=3D 0) > return rc; > = > - rc =3D device_test_reset(ctx, "dsa0"); > + rc =3D device_test_reset(ctx, "dsa0", false); > if (rc !=3D 0) > return rc; > = > @@ -806,7 +828,7 @@ static int test_max_wq_size(struct accfg_ctx *ctx) > { > int rc =3D 0; > = > - rc =3D device_test_reset(ctx, "dsa1"); > + rc =3D device_test_reset(ctx, "dsa1", false); > if (rc !=3D 0) > return rc; > = > @@ -814,7 +836,7 @@ static int test_max_wq_size(struct accfg_ctx *ctx) > if (rc !=3D 0) > return rc; > = > - rc =3D device_test_reset(ctx, "dsa1"); > + rc =3D device_test_reset(ctx, "dsa1", false); > if (rc !=3D 0) > return rc; > = > @@ -826,7 +848,7 @@ static int test_wq_boundary_conditions(struct > accfg_ctx *ctx) > { > int rc =3D 0; > = > - rc =3D device_test_reset(ctx, "dsa0"); > + rc =3D device_test_reset(ctx, "dsa0", false); > if (rc !=3D 0) > return rc; > = > @@ -834,7 +856,7 @@ static int test_wq_boundary_conditions(struct > accfg_ctx *ctx) > if (rc !=3D 0) > return rc; > = > - rc =3D device_test_reset(ctx, "dsa0"); > + rc =3D device_test_reset(ctx, "dsa0", false); > if (rc !=3D 0) > return rc; > = > @@ -924,7 +946,7 @@ static int test_mdev_1swq(struct accfg_ctx *ctx) > { > int rc =3D 0; > = > - rc =3D device_test_reset(ctx, "dsa0"); > + rc =3D device_test_reset(ctx, "dsa0", false); > if (rc) > return rc; > = > @@ -943,7 +965,7 @@ static int test_mdev_1swq(struct accfg_ctx *ctx) > if (rc) > return rc; > = > - rc =3D device_test_reset(ctx, "dsa0"); > + rc =3D device_test_reset(ctx, "dsa0", false); > if (rc) > return rc; > = > @@ -955,7 +977,7 @@ static int test_mdev_1dwq(struct accfg_ctx *ctx) > { > int rc =3D 0; > = > - rc =3D device_test_reset(ctx, "dsa0"); > + rc =3D device_test_reset(ctx, "dsa0", false); > if (rc) > return rc; > = > @@ -974,7 +996,7 @@ static int test_mdev_1dwq(struct accfg_ctx *ctx) > if (rc) > return rc; > = > - rc =3D device_test_reset(ctx, "dsa0"); > + rc =3D device_test_reset(ctx, "dsa0", false); > if (rc) > return rc; > = > @@ -1037,6 +1059,9 @@ static int idxd_kmod_init(struct kmod_ctx **ctx, > struct kmod_module **mod, > } > = > rc =3D kmod_module_get_initstate(*mod); > + if (rc =3D=3D -ENOENT) > + rc =3D kmod_module_probe_insert_module(*mod, 0, NULL, > NULL, NULL, > + NULL); > return rc; > } > = > @@ -1098,6 +1123,8 @@ int test_libaccfg(int loglevel, struct accfg_test *= test, > = > if (i >=3D ARRAY_SIZE(test_cases)) > result =3D EXIT_SUCCESS; > + else > + test_cleanup(ctx); > = > kmod_module_remove_module(mod, 0); > kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, > NULL); > -- > 2.26.2 --===============4952323327538786847==--