[Spice-devel] [cacard 2/2] tests: Fix 'simpletlv' on i686 arches

Christophe Fergeau cfergeau at redhat.com
Mon Aug 13 16:11:04 UTC 2018


The simpletlv_* functions return lengths as an int, but the test is
casting it to a size_t before comparing it against -1. This is not
giving the expected result on i686, causing the test to fail.

Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
 tests/simpletlv.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/simpletlv.c b/tests/simpletlv.c
index cd0cd69..2665eef 100644
--- a/tests/simpletlv.c
+++ b/tests/simpletlv.c
@@ -66,11 +66,11 @@ static void test_length_nested(void)
     /* Nested structures do not support splitting TL and V buffers ?? */
     /* Simple short value to TL */
     length = simpletlv_get_length(nested, 1, SIMPLETLV_TL);
-    g_assert_cmpint(length, ==, -1);
+    g_assert_cmpint((int)length, ==, -1);
 
     /* Simple short value to V */
     length = simpletlv_get_length(nested, 1, SIMPLETLV_VALUE);
-    g_assert_cmpint(length, ==, -1);
+    g_assert_cmpint((int)length, ==, -1);
 }
 
 static void test_length_skipped(void)
@@ -127,7 +127,7 @@ static void test_encode_simple(void)
     /* Encode simple short TLV with pre-allocated buffer (too short) */
     result = g_malloc(2);
     result_len = simpletlv_encode(simple, 1, &result, 2, NULL);
-    g_assert_cmpint(result_len, ==, -1);
+    g_assert_cmpint((int)result_len, ==, -1);
     g_free(result);
 
     /* Encode only TL part */
@@ -195,18 +195,18 @@ static void test_encode_nested(void)
     /* Encode simple short TLV with pre-allocated buffer (too short) */
     result = g_malloc(4);
     result_len = simpletlv_encode(nested, 1, &result, 4, NULL);
-    g_assert_cmpint(result_len, ==, -1);
+    g_assert_cmpint((int)result_len, ==, -1);
     g_free(result);
 
     /* Encode only TL part */
     result = NULL;
     result_len = simpletlv_encode_tl(nested, 1, &result, 0, NULL);
-    g_assert_cmpint(result_len, ==, -1);
+    g_assert_cmpint((int)result_len, ==, -1);
 
     /* Encode only VALUE part (equals to the value itself) */
     result = NULL;
     result_len = simpletlv_encode_val(nested, 1, &result, 0, NULL);
-    g_assert_cmpint(result_len, ==, -1);
+    g_assert_cmpint((int)result_len, ==, -1);
 }
 
 static void test_encode_skipped(void)
-- 
2.17.1



More information about the Spice-devel mailing list