[Tests] Fix bug, errors ignored
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 18 Jul 2018 06:57:48 +0000 (15:57 +0900)
committer오세원/Data Service Lab(SR)/Engineer/삼성전자 <sewon.oh@samsung.com>
Fri, 20 Jul 2018 01:27:45 +0000 (10:27 +0900)
Bug:
- When there is no log files, a test results in "PASSED"
- When there is differences between golden and test, the result sasy "PASSED"

Fixes #275

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
tests/testAPI.sh

index e3e9da6..3ebdbd5 100644 (file)
@@ -93,6 +93,24 @@ function gstFailTest {
 function compareAll {
        cmp $1 $2
        output=$?
+       if [ ! -f $1 ]; then
+               output=1
+       else
+               size1=$(wc -c < "$1")
+               if [ $size1 -eq 0 ]; then
+                       # If the size is 0, it's an error
+                       output=2
+               fi
+       fi
+       if [ ! -f $2 ]; then
+               output=1
+       else
+               size2=$(wc -c < "$2")
+               if [ $size2 -eq 0 ]; then
+                       # If the size is 0, it's an error
+                       output=2
+               fi
+       fi
        if [[ $output -eq 0 ]]; then
                lsucc=$((lsucc+1))
                log="${log}$GREEN[PASSED]$NC golden test comparison case $3\n"
@@ -111,6 +129,25 @@ function compareAll {
 function compareAllSizeLimit {
        # @TODO enter -n option with the size of #1
        cmp -n `stat --printf="%s" $1` $1 $2
+       output=$?
+       if [ ! -f $1 ]; then
+               output=1
+       else
+               size1=$(wc -c < "$1")
+               if [ $size1 -eq 0 ]; then
+                       # If the size is 0, it's an error
+                       output=2
+               fi
+       fi
+       if [ ! -f $2 ]; then
+               output=1
+       else
+               size2=$(wc -c < "$2")
+               if [ $size2 -eq 0 ]; then
+                       # If the size is 0, it's an error
+                       output=2
+               fi
+       fi
        if [[ $output -eq 0 ]]; then
                lsucc=$((lsucc+1))
                log="${log}$GREEN[PASSED]$NC golden test comparison case $3\n"