[igt-dev] [PATCH i-g-t 1/1] tests/tools_test: Find the tool binaries also from bindir

Arkadiusz Hiler arkadiusz.hiler at intel.com
Mon Nov 5 13:45:30 UTC 2018


On Mon, Nov 05, 2018 at 01:42:52PM +0200, Petri Latvala wrote:
> On Mon, Nov 05, 2018 at 12:50:48PM +0200, Arkadiusz Hiler wrote:
> > On Mon, Oct 08, 2018 at 03:10:42PM +0300, Petri Latvala wrote:
> > > Also print what directory gets used.
> > > 
> > > Signed-off-by: Petri Latvala <petri.latvala at intel.com>
> > > ---
> > >  tests/tools_test.c | 27 ++++++++++++++++++++-------
> > >  1 file changed, 20 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/tests/tools_test.c b/tests/tools_test.c
> > > index a0025bed..ac8717c5 100644
> > > --- a/tests/tools_test.c
> > > +++ b/tests/tools_test.c
> > > @@ -59,20 +59,33 @@ static void assert_cmd_success(int exec_return)
> > >  	igt_assert_eq(exec_return, IGT_EXIT_SUCCESS);
> > >  }
> > >  
> > > +bool chdir_to_tools_dir()
> > > +{
> > > +	char path[4096];
> > 
> > use PATH_MAX
> > 
> > > +
> > > +	/* Try TOOLS relative to cwd */
> > > +	if (chdir(TOOLS) == 0)
> > > +		return true;
> > 
> > 1st chdir(TOOLS)
> > 
> > > +
> > > +	/* Try TOOLS and install dir relative to test binary */
> > > +	if (readlink("/proc/self/exe", path, sizeof(path)) > 0)
> > > +		chdir(dirname(path));
> > > +
> > > +	return chdir(TOOLS) == 0 || chdir("../../bin") == 0;
> > 
> > 2nd chdir(TOOLS)
> > 
> > one should be enough
> 
> TOOLS is "../blahblah" and chdir(dirname(path)) changes what the second one does.

right

Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>


More information about the igt-dev mailing list