From: Ethan Jackson Date: Mon, 31 Jan 2011 04:02:16 +0000 (-0800) Subject: tests: Fix tests with UCS-2 Python. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=656833530941ef21c1a59656a5572b5155d0c302;p=openvswitch tests: Fix tests with UCS-2 Python. Python can be built with either UCS2 or UCS4 support. When built with UCS2 the python related surrogate pairs tests cannot pass. This commit handles this situation more gracefully. --- diff --git a/tests/json.at b/tests/json.at index 56329ed2..3962da1c 100644 --- a/tests/json.at +++ b/tests/json.at @@ -19,6 +19,18 @@ m4_define([JSON_CHECK_POSITIVE_PY], ]) AT_CLEANUP]) +m4_define([JSON_CHECK_POSITIVE_UCS4PY], + [AT_SETUP([$1]) + AT_KEYWORDS([json positive Python]) + AT_SKIP_IF([test $HAVE_PYTHON = no]) + AT_XFAIL_IF([$PYTHON -c "exit(len(u'\U00010800'))"; test $? -ne 1]) + AT_CHECK([printf %s "AS_ESCAPE([$2])" > input]) + AT_CAPTURE_FILE([input]) + AT_CHECK([$PYTHON $srcdir/test-json.py $4 input], [0], [stdout], []) + AT_CHECK([cat stdout], [0], [$3 +]) + AT_CLEANUP]) + m4_define([JSON_CHECK_POSITIVE], [JSON_CHECK_POSITIVE_C([$1 - C], [$2], [$3], [$4]) JSON_CHECK_POSITIVE_PY([$1 - Python], [$2], [$3], [$4])]) @@ -75,7 +87,10 @@ JSON_CHECK_POSITIVE([escape sequences], JSON_CHECK_POSITIVE([Unicode escape sequences], [[[ " \u0022 \u005c \u002F \u0008 \u000c \u000A \u000d \u0009" ]]], [[[" \" \\ / \b \f \n \r \t"]]]) -JSON_CHECK_POSITIVE([surrogate pairs], +JSON_CHECK_POSITIVE_C([surrogate pairs - C], + [[["\ud834\udd1e"]]], + [[["𝄞"]]]) +JSON_CHECK_POSITIVE_UCS4PY([surrogate pairs - Python], [[["\ud834\udd1e"]]], [[["𝄞"]]]) JSON_CHECK_NEGATIVE([a string by itself is not valid JSON], ["xxx"], diff --git a/tests/ovsdb-data.at b/tests/ovsdb-data.at index 98e81083..97369619 100644 --- a/tests/ovsdb-data.at +++ b/tests/ovsdb-data.at @@ -457,12 +457,12 @@ OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long], '["a"]' \ '["ab"]' \ '["abc"]' \ - '["\ud834\udd1e"]']], + '["de"]']], [["" "a" "ab" constraint violation: "abc" length 3 is greater than maximum allowed length 2 -"𝄞"]]) +"de"]]) AT_BANNER([OSVDB -- simple data])