[Piglit] [PATCH v2] framework: keep track of running stats and display them

Dylan Baker baker.dylan.c at gmail.com
Sun Feb 16 14:47:37 PST 2014


On Sunday, February 16, 2014 12:54:09 AM Ilia Mirkin wrote:
> This will display a line that looks like:
> [00076/11064] fail: 1, pass: 55, skip: 19 Running Test(s): 00075
> 
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> 
> One problem that I noticed is that this might make the line go over 80
> characters when running in parallel mode. If the line length is longer than
> the terminal width (at least with aterm), then the \r trick doesn't work
> nearly as well -- the stuff before the wrap stays, and a new line is emitted
> every time. Not the end of the world, but not great. IMHO the value of this
> feature outweighs the potential for such things. It's easy enough to resize
> the term if this happens.
> 
>  framework/core.py |  8 +++++---
>  framework/log.py  | 16 +++++++++++++---
>  2 files changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/framework/core.py b/framework/core.py
> index ac25917..fc59e3c 100644
> --- a/framework/core.py
> +++ b/framework/core.py
> @@ -435,6 +435,7 @@ class Test(object):
>          '''
> 
>          log_current = log.get_current()
> +        test_result = None
>          # Run the test
>          if env.execute:
>              try:
> @@ -462,15 +463,16 @@ class Test(object):
>                  result['traceback'] = \
>                      "".join(traceback.format_tb(sys.exc_info()[2]))
> 
> -            if 'subtest' in result and len(result['subtest'].keys()) > 1:
> -                for test in result['subtest'].keys():
> +            test_result = result['result']
> +            if 'subtest' in result and len(result['subtest']) > 1:
> +                for test in result['subtest']:
>                      result['result'] = result['subtest'][test]
>                      json_writer.write_dict_item(os.path.join(path, test),
> result) else:
>                  json_writer.write_dict_item(path, result)
>          else:
>              log.log()
> -        log.mark_complete(log_current)
> +        log.mark_complete(log_current, test_result)
> 
> 
>  class Group(dict):
> diff --git a/framework/log.py b/framework/log.py
> index 01c3a32..9f2d723 100644
> --- a/framework/log.py
> +++ b/framework/log.py
> @@ -37,6 +37,11 @@ class Log(object):
>          self.__running = []
>          self.__generator = (x for x in xrange(self.__total))
>          self.__pad = len(str(self.__total))
> +        self.__summary = {}
> +
> +    def _summary(self):
> +        return ", ".join("{0}: {1}".format(k, self.__summary[k])
> +                         for k in sorted(self.__summary))
> 
>      def _running(self):
>          return "Running Test(s): {}".format(
> @@ -47,12 +52,13 @@ class Log(object):
>                                    str(self.__total).zfill(self.__pad))
> 
>      @synchronized_self
> -    def mark_complete(self, value):
> +    def mark_complete(self, value, result):
>          """ Used to mark a test as complete in the log
> 
>          Arguments:
>          value -- the test number to mark complete
> -
> +        result -- the result of the completed test
> +
>          """
>          # Mark running complete
>          assert value in self.__running
> @@ -61,6 +67,9 @@ class Log(object):
>          # increment the number of completed tests
>          self.__complete += 1
> 
> +        if result:
> +            self.__summary[result] = self.__summary.get(result, 0) + 1
> +
>      @synchronized_self
>      def log(self):
>          """ Print to the screen
> @@ -69,7 +78,8 @@ class Log(object):
>          over it.
> 
>          """
> -        sys.stdout.write("{0} {1} \r".format(self._percent(),
> self._running())) +        sys.stdout.write("{0} {1} {2}\r".format(
> +            self._percent(), self._summary(), self._running()))
>          # Need to flush explicitly, otherwise it all gets buffered without
> a # newline.
>          sys.stdout.flush()


I read your comments on V1, and I misunderstood what you were doing. Both 
versions look fine to me, you have my r-b on whichever you like better:
Reviewed-by: Dylan Baker <baker.dylan.c at gmail.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140216/2de2403b/attachment-0001.pgp>


More information about the Piglit mailing list