igt: modify test definition for igt_runner

There is a test runner, igt_runner, comes with the newer version of
igt-gpu-tests. We can run the tests with it rather than piglit. Now the
test definition is compatible with both igt_runner and piglit.

Signed-off-by: Arthur She <arthur.she@linaro.org>
diff --git a/automated/linux/igt/print-test-result.py b/automated/linux/igt/print-test-result.py
index 5eefd6f..42a939d 100755
--- a/automated/linux/igt/print-test-result.py
+++ b/automated/linux/igt/print-test-result.py
@@ -5,22 +5,24 @@
 
 
 def print_result(results):
-    try:
-        for test, content in results['tests'].iteritems():
-            print '<LAVA_SIGNAL_STARTTC %s>' % test
-            print '************************************************************************************************************************************'
-            print '%-15s %s' % ('Test:', test)
-            print '%-15s %s' % ('Result:', content['result'])
+    for test, content in results['tests'].iteritems():
+        content = {k: unicode(v).encode("utf-8") for k, v in content.iteritems()}
+        print '<LAVA_SIGNAL_STARTTC %s>' % test
+        print '************************************************************************************************************************************'
+        print '%-15s %s' % ('Test:', test)
+        print '%-15s %s' % ('Result:', content['result'])
+        # Test result generated by igt_runner doesn't have the following values
+        try:
             print '%-15s %s' % ('Command:', content['command'])
             print '%-15s %s' % ('Environment:', content['environment'])
             print '%-15s %s' % ('Returncode:', content['returncode'])
-            print '%-15s %s' % ('Stdout:', content['out'].replace('\n', '\n                '))
-            print '%-15s %s' % ('Stderr:', content['err'].replace('\n', '\n                '))
-            print '%-15s %s' % ('dmesg:', content['dmesg'].replace('\n', '\n                '))
-            print '<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=%s>' % (test, content['result'])
-            print '<LAVA_SIGNAL_ENDTC %s>' % test
-    except KeyError:
-        print "Error: Can not find required data"
+        except KeyError:
+            pass
+        print '%-15s %s' % ('Stdout:', content['out'].replace('\n', '\n                '))
+        print '%-15s %s' % ('Stderr:', content['err'].replace('\n', '\n                '))
+        print '%-15s %s' % ('dmesg:', content['dmesg'].replace('\n', '\n                '))
+        print '<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=%s>' % (test, content['result'])
+        print '<LAVA_SIGNAL_ENDTC %s>' % test
 
 
 if __name__ == '__main__':