[Fuego] [PATCH 28/29] tiff: convert AGL test into a Fuego test

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Fri Jul 21 08:02:19 UTC 2017


Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
---
 engine/tests/Functional.tiff/create_xml_tiff.py | 85 -------------------------
 engine/tests/Functional.tiff/criteria.json      |  9 +++
 engine/tests/Functional.tiff/fuego_test.sh      | 75 +++++++++++++---------
 engine/tests/Functional.tiff/parser.py          | 18 ++++++
 engine/tests/Functional.tiff/reference.json     | 45 +++++++++++++
 5 files changed, 118 insertions(+), 114 deletions(-)
 delete mode 100755 engine/tests/Functional.tiff/create_xml_tiff.py
 create mode 100644 engine/tests/Functional.tiff/criteria.json
 create mode 100755 engine/tests/Functional.tiff/parser.py
 create mode 100644 engine/tests/Functional.tiff/reference.json

diff --git a/engine/tests/Functional.tiff/create_xml_tiff.py b/engine/tests/Functional.tiff/create_xml_tiff.py
deleted file mode 100755
index 4a75cf1..0000000
--- a/engine/tests/Functional.tiff/create_xml_tiff.py
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/python
-
-import os, re, sys, time, collections
-
-jta_home = os.environ.get('JTA_ENGINE_PATH', '/home/jenkins')
-testname = os.environ.get('JOB_NAME', "Functional.tiff")
-
-ret_val = 0
-parser_path = "%s/scripts/detailed_results/" % jta_home
-sys.path.insert(0, parser_path)
-import xmltodict
-
-cur_dict = collections.OrderedDict()
-cur_dict['report'] = collections.OrderedDict()
-cur_dict['report']['name'] = testname
-
-# Get build number
-number_file = "%s/jta/jobs/%s/nextBuildNumber" % (jta_home, testname)
-file_hd = open(number_file, 'r')
-number_line = file_hd.read()
-file_hd.close
-number = int(number_line.strip()) - 1
-number = int(os.environ.get('BUILD_NUMBER', number))
-
-# Get start time and result of the testset
-build_xml = "%s/jta/jobs/%s/builds/%d/build.xml" % (jta_home, testname, number)
-build_file = open(build_xml, 'rb')
-build_raw_values = build_file.read()
-build_file.close()
-build_dict = xmltodict.parse(build_raw_values)
-start_sec = int(build_dict['build']['startTime']) / 1000
-cur_dict['report']['starttime'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_sec))
-log = "%s/jta/jobs/%s/builds/%d/log" % (jta_home, testname, number)
-cur_dict['report']['endtime'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(os.path.getmtime(log)))
-cur_dict['report']['result'] = str(build_dict['build']['result'])
-
-# Get result and value of the testcase
-cur_dict['report']['items'] = collections.OrderedDict({'item': []})
-log_file = open(log, 'r')
-log_raw_lines = log_file.readlines()
-log_file.close()
-
-for line in log_raw_lines:
-	if line.startswith("++++ BOARD_VER"):
-		cur_dict['report']['board_version'] = line.split("=")[1].strip()
-	if line.startswith("++++ DEVICE_TEST"):
-		cur_dict['report']['device'] = line.split("=")[1].strip()
-	if line.startswith("++++ DEVICE_FS"):
-		cur_dict['report']['filesystem'] = line.split("=")[1].strip()
-	if line.startswith("++++ TESTLOG"):
-		test_log = line.split("=")[1].strip()
-	if line.startswith("+++ report "):
-		tmp_cmd = line.split(";")[0]
-		cur_dict['report']['test_dir'] = tmp_cmd.split()[3]
-		tmp_cmd = line.split(";")[1].strip()
-		cur_dict['report']['command_line'] = tmp_cmd.split("'")[0]
-		break
-
-cur_search_pat = re.compile("^(TEST-[\d]+) (.*)$", re.MULTILINE)
-cur_file = open(test_log, 'r')
-pat_result = cur_search_pat.findall(cur_file.read())
-cur_file.close()
-
-if pat_result:
-	for i in range(0, len(pat_result)):
-		ditem = collections.OrderedDict()
-		cur_dict['report']['items']['item'].append(ditem)
-		ditem['name'] = "%s" % pat_result[i][0]
-		if ((pat_result[i][1]).strip() == "OK"):
-			ditem['result'] = "PASS"
-		else:
-			ditem['result'] = "FAIL"
-			ret_val = 1
-if (ret_val == 1):
-	cur_dict['report']['result'] = "FAILURE"
-print cur_dict
-
-content = xmltodict.unparse(cur_dict, pretty=True)
-
-cur_xml = "%s/jta/jobs/%s/builds/%d/test_result.xml" % (jta_home, testname, number)
-cur_file = open(cur_xml, 'wb')
-cur_file.write(content)
-cur_file.close()
-
-sys.exit(ret_val)
diff --git a/engine/tests/Functional.tiff/criteria.json b/engine/tests/Functional.tiff/criteria.json
new file mode 100644
index 0000000..cf42154
--- /dev/null
+++ b/engine/tests/Functional.tiff/criteria.json
@@ -0,0 +1,9 @@
+{
+    "schema_version":"1.0",
+    "criteria":[
+        {
+            "tguid":"default",
+            "min_pass": 12
+        }
+    ]
+}
diff --git a/engine/tests/Functional.tiff/fuego_test.sh b/engine/tests/Functional.tiff/fuego_test.sh
index 35703fb..0516c85 100755
--- a/engine/tests/Functional.tiff/fuego_test.sh
+++ b/engine/tests/Functional.tiff/fuego_test.sh
@@ -1,45 +1,62 @@
 tarball=tiff-4.0.6.tar.gz
 
+function test_pre_check {
+    # This test requires 3 libraries to be present on the SDK
+    # libtiff.so
+    #    E.g.: apt-get install libtiff5-dev:armhf
+    # liblzma.so
+    #    E.g.: apt-get install liblzma-dev:armhf
+    # libjpeg.so
+    #    E.g.: apt-get install libjpeg-dev:armhf
+    is_on_sdk libtiff.so LIBTIFF /lib:/usr/lib/:/usr/local/lib:/usr/lib/$ARCH-linux-*/
+    LIBTIFF_PATH=$LOCATION
+    is_on_sdk liblzma.so LIBLZMA /lib:/usr/lib/:/usr/local/lib:/usr/lib/$ARCH-linux-*/
+    LIBLZMA_PATH=$LOCATION
+    is_on_sdk libjpeg.so LIBJPEG /lib:/usr/lib/:/usr/local/lib:/usr/lib/$ARCH-linux-*/
+    LIBJPEG_PATH=$LOCATION
+    assert_define LIBTIFF
+    assert_define LIBLZMA
+    assert_define LIBJPEG
+}
+
 function test_build {
     echo " test_build tif.sh "
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiff2bw tools/tiff2bw.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiff2pdf tools/tiff2pdf.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiff2ps tools/tiff2ps.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiff2rgba tools/tiff2rgba.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffcmp tools/tiffcmp.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffdither tools/tiffdither.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffdump tools/tiffdump.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffinfo tools/tiffinfo.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffset tools/tiffset.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffsplit tools/tiffsplit.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffcp tools/tiffcp.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
-    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffcrop tools/tiffcrop.c  $SDKROOT/usr/lib/libtiff.so $SDKROOT/usr/lib/liblzma.so $SDKROOT/usr/lib/libjpeg.so -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiff2bw tools/tiff2bw.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiff2pdf tools/tiff2pdf.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiff2ps tools/tiff2ps.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiff2rgba tools/tiff2rgba.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffcmp tools/tiffcmp.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffdither tools/tiffdither.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffdump tools/tiffdump.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffinfo tools/tiffinfo.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffset tools/tiffset.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffsplit tools/tiffsplit.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffcp tools/tiffcp.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
+    $CC -O2 -pipe -g -I./libtiff  -Wall -W -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o  tools/.libs/tiffcrop tools/tiffcrop.c  $LIBTIFF_PATH $LIBLZMA_PATH $LIBJPEG_PATH -lz -lm -pthread
 }
 
 function test_deploy {
-put tools/1.tif tools/111.tif tools/11.tif tools/jello.tif $BOARD_TESTDIR/fuego.$TESTDIR/
-put tools/.libs/* $BOARD_TESTDIR/fuego.$TESTDIR/
+    put tools/1.tif tools/111.tif tools/11.tif tools/jello.tif $BOARD_TESTDIR/fuego.$TESTDIR/
+    put tools/.libs/* $BOARD_TESTDIR/fuego.$TESTDIR/
 }
 
 function test_run {
-report "cd $BOARD_TESTDIR/fuego.$TESTDIR; export PATH=$BOARD_TESTDIR/fuego.$TESTDIR:$PATH; chmod 777 *;
-if tiff2bw 1.tif 2.tif; then echo 'TEST-1 OK'; else echo 'TEST-1 FAILED'; fi;\
-if tiff2pdf -o output.pdf 1.tif; then echo 'TEST-2 OK'; else echo 'TEST-2 FAILED'; fi;\
-if tiff2ps -1 jello.tif; then echo 'TEST-3 OK'; else echo 'TEST-3 FAILED'; fi;\
-if tiff2rgba -b jello.tif jello; then echo 'TEST-4 OK'; else echo 'TEST-4 FAILED'; fi;\
-if tiffcmp jello.tif 111.tif; then echo 'TEST-5 OK'; else echo 'TEST-5 FAILED'; fi;\
-if tiffdither -c lzw:2 111.tif 666.tif; then echo 'TEST-6 OK'; else echo 'TEST-6 FAILED'; fi;\
-if tiffdump 111.tif; then echo 'TEST-7 OK'; else echo 'TEST-7 FAILED'; fi;\
-if tiffinfo 111.tif; then echo 'TEST-8 OK'; else echo 'TEST-8 FAILED'; fi;\
-if tiffset jello.tif; then echo 'TEST-9 OK'; else echo 'TEST-9 FAILED'; fi;\
-if tiffsplit 11.tif -l; then echo 'TEST-10 OK'; else echo 'TEST-10 FAILED'; fi;\
-if tiffcp 11.tif 000.tif;then echo 'TEST-11 OK'; else echo 'TEST-11 FAILED'; fi;\
-if tiffcrop 11.tif 0000.tif;then echo 'TEST-12 OK'; else echo 'TEST-12 FAILED';fi"
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR; export PATH=$BOARD_TESTDIR/fuego.$TESTDIR:$PATH; chmod 777 *;\
+        if tiff2bw 1.tif 2.tif; then echo 'TEST-1 OK'; else echo 'TEST-1 FAILED'; fi;\
+        if tiff2pdf -o output.pdf 1.tif; then echo 'TEST-2 OK'; else echo 'TEST-2 FAILED'; fi;\
+        if tiff2ps -1 jello.tif; then echo 'TEST-3 OK'; else echo 'TEST-3 FAILED'; fi;\
+        if tiff2rgba -b jello.tif jello; then echo 'TEST-4 OK'; else echo 'TEST-4 FAILED'; fi;\
+        if tiffcmp jello.tif 111.tif; then echo 'TEST-5 OK'; else echo 'TEST-5 FAILED'; fi;\
+        if tiffdither -c lzw:2 111.tif 666.tif; then echo 'TEST-6 OK'; else echo 'TEST-6 FAILED'; fi;\
+        if tiffdump 111.tif; then echo 'TEST-7 OK'; else echo 'TEST-7 FAILED'; fi;\
+        if tiffinfo 111.tif; then echo 'TEST-8 OK'; else echo 'TEST-8 FAILED'; fi;\
+        if tiffset jello.tif; then echo 'TEST-9 OK'; else echo 'TEST-9 FAILED'; fi;\
+        if tiffsplit 11.tif -l; then echo 'TEST-10 OK'; else echo 'TEST-10 FAILED'; fi;\
+        if tiffcp 11.tif 000.tif;then echo 'TEST-11 OK'; else echo 'TEST-11 FAILED'; fi;\
+        if tiffcrop 11.tif 0000.tif;then echo 'TEST-12 OK'; else echo 'TEST-12 FAILED';fi"
 }
 
 function test_processing {
     log_compare "$TESTDIR" "12" "^TEST.*OK" "p"
     log_compare "$TESTDIR" "0" "^TEST.*FAILED" "n"
 }
-
-
diff --git a/engine/tests/Functional.tiff/parser.py b/engine/tests/Functional.tiff/parser.py
new file mode 100755
index 0000000..7afc2ea
--- /dev/null
+++ b/engine/tests/Functional.tiff/parser.py
@@ -0,0 +1,18 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+import common as plib
+
+measurements = {}
+
+regex_string = '^TEST-(\d+) (.*)$'
+matches = plib.parse(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.test' + m[0]] = 'PASS' if m[1] == 'OK' else 'FAIL'
+
+sys.exit(plib.process_data(measurements))
diff --git a/engine/tests/Functional.tiff/reference.json b/engine/tests/Functional.tiff/reference.json
new file mode 100644
index 0000000..8e3fbd3
--- /dev/null
+++ b/engine/tests/Functional.tiff/reference.json
@@ -0,0 +1,45 @@
+{
+    "test_sets":[
+        {
+            "name":"default",
+            "test_cases":[
+                {
+                    "name":"test1"
+                },
+                {
+                    "name":"test2"
+                },
+                {
+                    "name":"test3"
+                },
+                {
+                    "name":"test4"
+                },
+                {
+                    "name":"test5"
+                },
+                {
+                    "name":"test6"
+                },
+                {
+                    "name":"test7"
+                },
+                {
+                    "name":"test8"
+                },
+                {
+                    "name":"test9"
+                },
+                {
+                    "name":"test10"
+                },
+                {
+                    "name":"test11"
+                },
+                {
+                    "name":"test12"
+                }
+            ]
+        }
+    ]
+}
-- 
2.7.4




More information about the Fuego mailing list