Re: [igt-dev] [PATCH i-g-t 7/9] lib/chamelium: Make it clear that function asserts

Arkadiusz Hiler
2020-02-17T14:11:05Z

On Mon, Feb 17, 2020 at 04:00:48PM +0200, Petri Latvala wrote:
> On Mon, Feb 17, 2020 at 03:45:04PM +0200, Arkadiusz Hiler wrote:
> > On Fri, Feb 14, 2020 at 02:19:58PM +0200, Petri Latvala wrote:
> > > On Wed, Feb 12, 2020 at 03:23:13PM +0200, Arkadiusz Hiler wrote:
> > > > chamelium_wait_reachable() is asserting internally if the chamelium not
> > > > reachable. Let's make it return bool instead and create
> > > > void chamelium_assert_reachable() that fails the run.
> > > >
> > > > Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> > >
> > > Reviewed-by: Petri Latvala <petri.latvala@intel.com>
> > >
> > > Aside, Chamelium stuff is documented in a .txt but are there docs for
> > > the lib/igt_chamelium functions anywhere?
> >
> > https://drm.pages.freedesktop.org/igt-gpu-tools/igt-gpu-tools-Chamelium.html ?
>
> /me blind
>
> I got confuz by the patch context not having documentation comments
> visible. And speaking of, docs for chamelium_wait_reachable pls?

↓↓↓ bueno enough?

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 5f9f777c..28706012 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -374,12 +374,26 @@ static bool __chamelium_is_reachable(struct chamelium *chamelium)
return true;
}

+/**
+ * chamelium_wait_reachable:
+ * @chamelium: The Chamelium instance to use
+ * @timeout: Time (in seconds) to wait for chamelium to be reachable
+ *
+ * Returns: %true if the Chamelium is reachable, %false otherwise.
+ */
bool chamelium_wait_reachable(struct chamelium *chamelium, int timeout)
{
return igt_wait(__chamelium_is_reachable(chamelium),
timeout * 1000, 100);
}

+/**
+ * chamelium_assert_reachable:
+ * @chamelium: The Chamelium instance to use
+ * @timeout: Time (in seconds) to wait for chamelium to be reachable
+ *
+ * Asserts that the chamelium is reachable.
+ */
void chamelium_assert_reachable(struct chamelium *chamelium, int timeout)
{
bool chamelium_online = chamelium_wait_reachable(chamelium, timeout);