diff options
| author | Ben Pfaff <blp@nicira.com> | 2011-05-13 14:20:10 -0700 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2011-05-24 11:32:22 -0700 |
| commit | be44585c21cc8dbe097a460a930696f0350dc12d (patch) | |
| tree | 764ac76d7386879748e3b4fd0e43fc797923bd70 /tests/ovsdb-data.at | |
| parent | 19997ceee06cec2ce1f36ebfc225fa379b6b1ed0 (diff) | |
| download | openvswitch-be44585c21cc8dbe097a460a930696f0350dc12d.tar.gz | |
tests: Fix the two Python XFAIL tests.
OVS has two Python tests that have always failed, for reasons not
understood, since they were added to the tree. This commit fixes them.
One problem was that Python was assuming that stdout was encoded in ASCII.
Apparently the only way to "fix" this at runtime is to set PYTHONIOENCODING
to utf_8 in the environment, so this change does that.
Second, it appears that Python really doesn't like to print invalid UTF-8,
so this avoids doing that in python/ovs/json.py, instead just printing
the hexadecimal values of the invalid bytes. For consistency, it makes
the same change to the C version.
Third, the C version of test-ovsdb doesn't check UTF-8 for consistency, it
just sends it blindly to the OVSDB server, but Python does check it and so
it bails out earlier. This commit changes the Python version of the
"no invalid UTF-8 sequences in strings" to allow for the slight difference
in output that occurs for that reason.
Finally, test-ovsdb.py needs to convert error messages to Unicode
explicitly before printing them in the "parse-atoms" function. I don't
really understand why, but now it works.
Diffstat (limited to 'tests/ovsdb-data.at')
| -rw-r--r-- | tests/ovsdb-data.at | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/ovsdb-data.at b/tests/ovsdb-data.at index d45e07bfa..b74e68217 100644 --- a/tests/ovsdb-data.at +++ b/tests/ovsdb-data.at @@ -231,14 +231,28 @@ OVSDB_CHECK_POSITIVE_CPY([real not acceptable integer JSON atom], dnl <C0> is not allowed anywhere in a UTF-8 string. dnl <ED A0 80> is a surrogate and not allowed in UTF-8. -OVSDB_CHECK_POSITIVE_CPY([no invalid UTF-8 sequences in strings], +OVSDB_CHECK_POSITIVE([no invalid UTF-8 sequences in strings], [parse-atoms '[["string"]]' \ '@<:@"m4_esyscmd([printf "\300"])"@:>@' \ '@<:@"m4_esyscmd([printf "\355\240\200"])"@:>@' \ ], - [constraint violation: "m4_esyscmd([printf "\300"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xc0 -constraint violation: "m4_esyscmd([printf "\355\240\200"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0], - [], [], [xfail]) + [constraint violation: not a valid UTF-8 string: invalid UTF-8 sequence 0xc0 +constraint violation: not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0]) + +dnl Python won't let invalid UTF-8 (its idea of invalid UTF-8, anyway) into it +dnl at all, so this test never gets as far as a constraint violation. It's +dnl just a JSON parse error. +dnl +dnl <C0> is not allowed anywhere in a UTF-8 string. +dnl (<ED A0 80> is not allowed in UTF-8 but Python doesn't care.) +dnl <ED 80 7F> is not allowed in UTF-8. +OVSDB_CHECK_POSITIVE_PY([no invalid UTF-8 sequences in strings - Python], + [parse-atoms '[["string"]]' \ + '@<:@"m4_esyscmd([printf "\300"])"@:>@' \ + '@<:@"m4_esyscmd([printf "\355\200\177"])"@:>@' \ +], + ["not a valid UTF-8 string: invalid UTF-8 sequence 0xc0" +"not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0x80"]) OVSDB_CHECK_NEGATIVE([real not acceptable integer string atom], [[parse-atom-strings '["integer"]' '0.5' ]], @@ -452,8 +466,7 @@ OVSDB_CHECK_POSITIVE_CPY([strings at least 2 characters long], constraint violation: "a" length 1 is less than minimum allowed length 2 "ab" "abc" -constraint violation: "𝄞" length 1 is less than minimum allowed length 2]], - [], [], [xfail]) +constraint violation: "𝄞" length 1 is less than minimum allowed length 2]]) OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long], [[parse-atoms '{"type": "string", "maxLength": 2}' \ |
