tools: PCI: exit with error code when test fails

Message ID 1537455773-13470-1-git-send-email-jjhiblot@ti.com
State Needs Review / ACK
Delegated to: Lorenzo Pieralisi
Headers show
Series
  • tools: PCI: exit with error code when test fails
Related show

Commit Message

Jean-Jacques Hiblot Sept. 20, 2018, 3:02 p.m.
This makes it easier to use pcitest in automated setups.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 tools/pci/pcitest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Lorenzo Pieralisi Oct. 4, 2018, 11:11 a.m. | #1
On Thu, Sep 20, 2018 at 05:02:53PM +0200, Jean-Jacques Hiblot wrote:
> This makes it easier to use pcitest in automated setups.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>  tools/pci/pcitest.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
> index af146bb..5adc8cd 100644
> --- a/tools/pci/pcitest.c
> +++ b/tools/pci/pcitest.c
> @@ -143,6 +143,7 @@ static int run_test(struct pci_test *test)
>  	}
>  
>  	fflush(stdout);
> +	return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */
>  }
>  
>  int main(int argc, char **argv)
> @@ -231,6 +232,5 @@ int main(int argc, char **argv)
>  		return -EINVAL;
>  	}
>  
> -	run_test(test);
> -	return 0;
> +	return run_test(test);
>  }
> -- 
> 2.7.4
> 

Hi Kishon,

are you OK with this patch ? Please let me know.

Thanks,
Lorenzo
Lorenzo Pieralisi Nov. 16, 2018, 12:01 p.m. | #2
On Thu, Oct 04, 2018 at 12:11:44PM +0100, Lorenzo Pieralisi wrote:
> On Thu, Sep 20, 2018 at 05:02:53PM +0200, Jean-Jacques Hiblot wrote:
> > This makes it easier to use pcitest in automated setups.
> > 
> > Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> > ---
> >  tools/pci/pcitest.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
> > index af146bb..5adc8cd 100644
> > --- a/tools/pci/pcitest.c
> > +++ b/tools/pci/pcitest.c
> > @@ -143,6 +143,7 @@ static int run_test(struct pci_test *test)
> >  	}
> >  
> >  	fflush(stdout);
> > +	return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */
> >  }
> >  
> >  int main(int argc, char **argv)
> > @@ -231,6 +232,5 @@ int main(int argc, char **argv)
> >  		return -EINVAL;
> >  	}
> >  
> > -	run_test(test);
> > -	return 0;
> > +	return run_test(test);
> >  }
> > -- 
> > 2.7.4
> > 
> 
> Hi Kishon,
> 
> are you OK with this patch ? Please let me know.

Please let me know, I need your ACK on this to queue it.

Lorenzo

Patch

diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
index af146bb..5adc8cd 100644
--- a/tools/pci/pcitest.c
+++ b/tools/pci/pcitest.c
@@ -143,6 +143,7 @@  static int run_test(struct pci_test *test)
 	}
 
 	fflush(stdout);
+	return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */
 }
 
 int main(int argc, char **argv)
@@ -231,6 +232,5 @@  int main(int argc, char **argv)
 		return -EINVAL;
 	}
 
-	run_test(test);
-	return 0;
+	return run_test(test);
 }