Skip to contentSkip to conversation

runner: Unprintable characters in json

PATCH In review Petri Latvala 2 participants 8 messages Jan 10, 2020 – Jan 15, 2020

lore
Share & tools
lore
#0 lore raw

v2 cover runner: Unprintable characters in json

Rebase of https://patchwork.freedesktop.org/series/70492/ adjusted for handling dynamic subtest outputs. Patch 2/2 won't survive sending by email, or patchwork's handling, but
https://gitlab.freedesktop.org/adrinael/igt-gpu-tools/commits/unprintable
has this version.

Petri Latvala (2):
runner: Ensure generated json is properly UTF8-encoded runner/json_tests: Test handling of unprintable output from tests

 .../unprintable-characters/0/dmesg.txt        |   5 +
 .../unprintable-characters/0/err.txt          | 258 +++++++++++++++++
 .../unprintable-characters/0/journal.txt      |   2 +
 .../unprintable-characters/0/out.txt          | 259 ++++++++++++++++++
 .../unprintable-characters/README.txt         |   2 +
 .../unprintable-characters/endtime.txt        |   1 +
 .../unprintable-characters/joblist.txt        |   1 +
 .../unprintable-characters/metadata.txt       |  12 +
 .../unprintable-characters/reference.json     |  72 +++++
 .../unprintable-characters/starttime.txt      |   1 +
 .../unprintable-characters/uname.txt          |   1 +
 runner/resultgen.c                            |  45 ++-
 runner/runner_json_tests.c                    |   1 +
 13 files changed, 650 insertions(+), 10 deletions(-)
 create mode 100644 runner/json_tests_data/unprintable-characters/0/dmesg.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/0/err.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/0/journal.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/0/out.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/README.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/endtime.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/joblist.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/metadata.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/reference.json
 create mode 100644 runner/json_tests_data/unprintable-characters/starttime.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/uname.txt
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

PATCH v2 1/2 runner: Ensure generated json is properly UTF8-encoded

Sometimes tests output garbage (e.g. due to extreme occurrences of
https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/55) but we need to present the garbage as results.

We already ignore any test output after the first \0, and for the rest of the bytes that are not directly UTF-8 as-is, we can quite easily represent them with two-byte UTF-8 encoding.

libjson-c already expects the string you feed it through json_object_new_string* functions to be UTF-8.

v2: Rebase, adjust for dynamic subtest parsing

---
 runner/resultgen.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)
runner/resultgen.c +35 -10
index 2c8a55da..105ec887 100644
@@ -405,15 +405,40 @@ static void free_matches(struct matches *matches)
 	free(matches->items);
 }
 
+static struct json_object *new_escaped_json_string(const char *buf, size_t len)
+{
+	struct json_object *obj;
+	char *str = NULL;
+	size_t strsize = 0;
+	size_t i;
+
+	for (i = 0; i < len; i++) {
+		if (buf[i] > 0 && buf[i] < 128) {
+			str = realloc(str, strsize + 1);
+			str[strsize] = buf[i];
+			++strsize;
+		} else {
+			/* Encode > 128 character to UTF-8. */
+			str = realloc(str, strsize + 2);
+			str[strsize] = ((unsigned char)buf[i] >> 6) | 0xC0;
+			str[strsize + 1] = ((unsigned char)buf[i] & 0x3F) | 0x80;
+			strsize += 2;
+		}
+	}
+
+	obj = json_object_new_string_len(str, strsize);
+	free(str);
+
+	return obj;
+}
+
 static void add_igt_version(struct json_object *testobj,
 			    const char *igt_version,
 			    size_t igt_version_len)
 {
 	if (igt_version)
 		json_object_object_add(testobj, "igt-version",
-				       json_object_new_string_len(igt_version,
-								  igt_version_len));
-
+				       new_escaped_json_string(igt_version, igt_version_len));
 }
 
 enum subtest_find_pattern {
@@ -608,7 +633,7 @@ static void process_dynamic_subtest_output(const char *piglit_name,
 		current_dynamic_test = get_or_create_json_object(tests, dynamic_piglit_name);
 
 		json_object_object_add(current_dynamic_test, key,
-				       json_object_new_string_len(dynbeg, dynend - dynbeg));
+				       new_escaped_json_string(dynbeg, dynend - dynbeg));
 		add_igt_version(current_dynamic_test, igt_version, igt_version_len);
 
 		if (!json_object_object_get_ex(current_dynamic_test, "result", NULL)) {
@@ -680,7 +705,7 @@ static bool fill_from_output(int fd, const char *binary, const char *key,
 		current_test = get_or_create_json_object(tests, piglit_name);
 
 		json_object_object_add(current_test, key,
-				       json_object_new_string_len(buf, statbuf.st_size));
+				       new_escaped_json_string(buf, statbuf.st_size));
 		add_igt_version(current_test, igt_version, igt_version_len);
 
 		return true;
@@ -704,7 +729,7 @@ static bool fill_from_output(int fd, const char *binary, const char *key,
 		end = find_subtest_end_limit(matches, begin_idx, result_idx, buf, bufend);
 
 		json_object_object_add(current_test, key,
-				       json_object_new_string_len(beg, end - beg));
+				       new_escaped_json_string(beg, end - beg));
 
 		add_igt_version(current_test, igt_version, igt_version_len);
 
@@ -863,11 +888,11 @@ static void add_dmesg(struct json_object *obj,
 		      const char *warnings, size_t warningslen)
 {
 	json_object_object_add(obj, "dmesg",
-			       json_object_new_string_len(dmesg, dmesglen));
+			       new_escaped_json_string(dmesg, dmesglen));
 
 	if (warnings) {
 		json_object_object_add(obj, "dmesg-warnings",
-				       json_object_new_string_len(warnings, warningslen));
+				       new_escaped_json_string(warnings, warningslen));
 	}
 }
 
@@ -1482,7 +1507,7 @@ struct json_object *generate_results_json(int dirfd)
 			r--;
 
 		json_object_object_add(obj, "uname",
-				       json_object_new_string_len(buf, r));
+				       new_escaped_json_string(buf, r));
 		close(fd);
 	}
 
@@ -1545,7 +1570,7 @@ struct json_object *generate_results_json(int dirfd)
 		s = read(fd, buf, sizeof(buf));
 
 		json_object_object_add(aborttest, "out",
-				       json_object_new_string_len(buf, s));
+				       new_escaped_json_string(buf, s));
 		json_object_object_add(aborttest, "err",
 				       json_object_new_string(""));
 		json_object_object_add(aborttest, "dmesg",
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Reviewed-by on v2 1/2
#2 lore raw

Re: [igt-dev] [PATCH i-g-t v2 1/2] runner: Ensure generated json is properly UTF8-encoded

Quoted 44 lines · Petri Latvala

Sometimes tests output garbage (e.g. due to extreme occurrences of
https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/55) but we need to present the garbage as results.

We already ignore any test output after the first \0, and for the rest of the bytes that are not directly UTF-8 as-is, we can quite easily represent them with two-byte UTF-8 encoding.

libjson-c already expects the string you feed it through json_object_new_string* functions to be UTF-8.

v2: Rebase, adjust for dynamic subtest parsing

---
 runner/resultgen.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)
runner/resultgen.c +16 -0
index 2c8a55da..105ec887 100644
@@ -405,15 +405,40 @@ static void free_matches(struct matches *matches)
 	free(matches->items);
 }
 
+static struct json_object *new_escaped_json_string(const char *buf, size_t len)
+{
+	struct json_object *obj;
+	char *str = NULL;
+	size_t strsize = 0;
+	size_t i;
+
+	for (i = 0; i < len; i++) {
+		if (buf[i] > 0 && buf[i] < 128) {
+			str = realloc(str, strsize + 1);
+			str[strsize] = buf[i];
+			++strsize;
+		} else {
+			/* Encode > 128 character to UTF-8. */
+			str = realloc(str, strsize + 2);
+			str[strsize] = ((unsigned char)buf[i] >> 6) | 0xC0;

runner/resultgen.c static void free_matches(struct matches *matches) · line 433

Quoted 10 lines
runner/resultgen.c +10 -0
+			str[strsize + 1] = ((unsigned char)buf[i] & 0x3F) | 0x80;
+			strsize += 2;
+		}
+	}
+
+	obj = json_object_new_string_len(str, strsize);
+	free(str);
+
+	return obj;
+}

Looking at this for the 3rd time I wonder whether this realloc() every character is not too costly, especially that we do that for every field. Have you tried comparing times igt_results for some intermediates with large dmesgs?

Anyway, let's not optimize prematurely:

Quoted 76 lines
runner/resultgen.c +9 -10
+
 static void add_igt_version(struct json_object *testobj,
 			    const char *igt_version,
 			    size_t igt_version_len)
 {
 	if (igt_version)
 		json_object_object_add(testobj, "igt-version",
-				       json_object_new_string_len(igt_version,
-								  igt_version_len));
-
+				       new_escaped_json_string(igt_version, igt_version_len));
 }
 
 enum subtest_find_pattern {
@@ -608,7 +633,7 @@ static void process_dynamic_subtest_output(const char *piglit_name,
 		current_dynamic_test = get_or_create_json_object(tests, dynamic_piglit_name);
 
 		json_object_object_add(current_dynamic_test, key,
-				       json_object_new_string_len(dynbeg, dynend - dynbeg));
+				       new_escaped_json_string(dynbeg, dynend - dynbeg));
 		add_igt_version(current_dynamic_test, igt_version, igt_version_len);
 
 		if (!json_object_object_get_ex(current_dynamic_test, "result", NULL)) {
@@ -680,7 +705,7 @@ static bool fill_from_output(int fd, const char *binary, const char *key,
 		current_test = get_or_create_json_object(tests, piglit_name);
 
 		json_object_object_add(current_test, key,
-				       json_object_new_string_len(buf, statbuf.st_size));
+				       new_escaped_json_string(buf, statbuf.st_size));
 		add_igt_version(current_test, igt_version, igt_version_len);
 
 		return true;
@@ -704,7 +729,7 @@ static bool fill_from_output(int fd, const char *binary, const char *key,
 		end = find_subtest_end_limit(matches, begin_idx, result_idx, buf, bufend);
 
 		json_object_object_add(current_test, key,
-				       json_object_new_string_len(beg, end - beg));
+				       new_escaped_json_string(beg, end - beg));
 
 		add_igt_version(current_test, igt_version, igt_version_len);
 
@@ -863,11 +888,11 @@ static void add_dmesg(struct json_object *obj,
 		      const char *warnings, size_t warningslen)
 {
 	json_object_object_add(obj, "dmesg",
-			       json_object_new_string_len(dmesg, dmesglen));
+			       new_escaped_json_string(dmesg, dmesglen));
 
 	if (warnings) {
 		json_object_object_add(obj, "dmesg-warnings",
-				       json_object_new_string_len(warnings, warningslen));
+				       new_escaped_json_string(warnings, warningslen));
 	}
 }
 
@@ -1482,7 +1507,7 @@ struct json_object *generate_results_json(int dirfd)
 			r--;
 
 		json_object_object_add(obj, "uname",
-				       json_object_new_string_len(buf, r));
+				       new_escaped_json_string(buf, r));
 		close(fd);
 	}
 
@@ -1545,7 +1570,7 @@ struct json_object *generate_results_json(int dirfd)
 		s = read(fd, buf, sizeof(buf));
 
 		json_object_object_add(aborttest, "out",
-				       json_object_new_string_len(buf, s));
+				       new_escaped_json_string(buf, s));
 		json_object_object_add(aborttest, "err",
 				       json_object_new_string(""));
 		json_object_object_add(aborttest, "dmesg",
Signature · 1 line
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

Re: [igt-dev] [PATCH i-g-t v2 1/2] runner: Ensure generated json is properly UTF8-encoded

Quoted 50 lines · Arkadiusz Hiler
Quoted 49 lines · Petri Latvala

Sometimes tests output garbage (e.g. due to extreme occurrences of
https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/55) but we need to present the garbage as results.

We already ignore any test output after the first \0, and for the rest of the bytes that are not directly UTF-8 as-is, we can quite easily represent them with two-byte UTF-8 encoding.

libjson-c already expects the string you feed it through json_object_new_string* functions to be UTF-8.

v2: Rebase, adjust for dynamic subtest parsing

---
 runner/resultgen.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)
runner/resultgen.c +21 -0
index 2c8a55da..105ec887 100644
@@ -405,15 +405,40 @@ static void free_matches(struct matches *matches)
 	free(matches->items);
 }
 
+static struct json_object *new_escaped_json_string(const char *buf, size_t len)
+{
+	struct json_object *obj;
+	char *str = NULL;
+	size_t strsize = 0;
+	size_t i;
+
+	for (i = 0; i < len; i++) {
+		if (buf[i] > 0 && buf[i] < 128) {
+			str = realloc(str, strsize + 1);
+			str[strsize] = buf[i];
+			++strsize;
+		} else {
+			/* Encode > 128 character to UTF-8. */
+			str = realloc(str, strsize + 2);
+			str[strsize] = ((unsigned char)buf[i] >> 6) | 0xC0;
+			str[strsize + 1] = ((unsigned char)buf[i] & 0x3F) | 0x80;
+			strsize += 2;
+		}
+	}
+
Quoted 8 lines

runner/resultgen.c static void free_matches(struct matches *matches) · line 433

Quoted 5 lines
runner/resultgen.c +5 -0
+	obj = json_object_new_string_len(str, strsize);
+	free(str);
+
+	return obj;
+}

Looking at this for the 3rd time I wonder whether this realloc() every character is not too costly, especially that we do that for every field.

Do you mean as opposed to allocating a larger chunk at a time? realloc already does this.

With a quick whipup test, realloc()ing same pointer repeatedly for sizes 1 to 0xffffff (randomly chosen end point) with increments of 1, the returned pointer was different a total of 29 times. For funzies, a total of 9 times when stdout was a pipe instead of tty.

Quoted 2 lines

Have you tried comparing times igt_results for some intermediates with large dmesgs?

I can do that but I won't be expecting much difference.

Signature · 5 lines
Petri Latvala
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#4 lore raw

Re: [igt-dev] [PATCH i-g-t v2 1/2] runner: Ensure generated json is properly UTF8-encoded

Quoted 60 lines · Petri Latvala
Quoted 50 lines · Arkadiusz Hiler
Quoted 49 lines · Petri Latvala

Sometimes tests output garbage (e.g. due to extreme occurrences of
https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/55) but we need to present the garbage as results.

We already ignore any test output after the first \0, and for the rest of the bytes that are not directly UTF-8 as-is, we can quite easily represent them with two-byte UTF-8 encoding.

libjson-c already expects the string you feed it through json_object_new_string* functions to be UTF-8.

v2: Rebase, adjust for dynamic subtest parsing

---
 runner/resultgen.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)
runner/resultgen.c +21 -0
index 2c8a55da..105ec887 100644
@@ -405,15 +405,40 @@ static void free_matches(struct matches *matches)
 	free(matches->items);
 }
 
+static struct json_object *new_escaped_json_string(const char *buf, size_t len)
+{
+	struct json_object *obj;
+	char *str = NULL;
+	size_t strsize = 0;
+	size_t i;
+
+	for (i = 0; i < len; i++) {
+		if (buf[i] > 0 && buf[i] < 128) {
+			str = realloc(str, strsize + 1);
+			str[strsize] = buf[i];
+			++strsize;
+		} else {
+			/* Encode > 128 character to UTF-8. */
+			str = realloc(str, strsize + 2);
+			str[strsize] = ((unsigned char)buf[i] >> 6) | 0xC0;
+			str[strsize + 1] = ((unsigned char)buf[i] & 0x3F) | 0x80;
+			strsize += 2;
+		}
+	}
+
Quoted 8 lines

runner/resultgen.c static void free_matches(struct matches *matches) · line 433

Quoted 5 lines
runner/resultgen.c +5 -0
+	obj = json_object_new_string_len(str, strsize);
+	free(str);
+
+	return obj;
+}

Looking at this for the 3rd time I wonder whether this realloc() every character is not too costly, especially that we do that for every field.

Quoted 7 lines

Do you mean as opposed to allocating a larger chunk at a time? realloc already does this.

With a quick whipup test, realloc()ing same pointer repeatedly for sizes 1 to 0xffffff (randomly chosen end point) with increments of 1, the returned pointer was different a total of 29 times. For funzies, a total of 9 times when stdout was a pipe instead of tty.

I have expected that even if it's not a part of the standard the actual implementation would optimize for this. Nice to see it's this good.

Quoted 4 lines
Quoted 2 lines

Have you tried comparing times igt_results for some intermediates with large dmesgs?

I can do that but I won't be expecting much difference.

Yeah, does not make sense to test it. Go ahead with mergeing.
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#5 lore raw

Re: [igt-dev] [PATCH i-g-t v2 1/2] runner: Ensure generated json is properly UTF8-encoded

Quoted 72 lines · Arkadiusz Hiler
Quoted 60 lines · Petri Latvala
Quoted 50 lines · Arkadiusz Hiler
Quoted 49 lines · Petri Latvala

Sometimes tests output garbage (e.g. due to extreme occurrences of
https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/55) but we need to present the garbage as results.

We already ignore any test output after the first \0, and for the rest of the bytes that are not directly UTF-8 as-is, we can quite easily represent them with two-byte UTF-8 encoding.

libjson-c already expects the string you feed it through json_object_new_string* functions to be UTF-8.

v2: Rebase, adjust for dynamic subtest parsing

---
 runner/resultgen.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)
runner/resultgen.c +21 -0
index 2c8a55da..105ec887 100644
@@ -405,15 +405,40 @@ static void free_matches(struct matches *matches)
 	free(matches->items);
 }
 
+static struct json_object *new_escaped_json_string(const char *buf, size_t len)
+{
+	struct json_object *obj;
+	char *str = NULL;
+	size_t strsize = 0;
+	size_t i;
+
+	for (i = 0; i < len; i++) {
+		if (buf[i] > 0 && buf[i] < 128) {
+			str = realloc(str, strsize + 1);
+			str[strsize] = buf[i];
+			++strsize;
+		} else {
+			/* Encode > 128 character to UTF-8. */
+			str = realloc(str, strsize + 2);
+			str[strsize] = ((unsigned char)buf[i] >> 6) | 0xC0;
+			str[strsize + 1] = ((unsigned char)buf[i] & 0x3F) | 0x80;
+			strsize += 2;
+		}
+	}
+
Quoted 8 lines

runner/resultgen.c static void free_matches(struct matches *matches) · line 433

Quoted 5 lines
runner/resultgen.c +5 -0
+	obj = json_object_new_string_len(str, strsize);
+	free(str);
+
+	return obj;
+}

Looking at this for the 3rd time I wonder whether this realloc() every character is not too costly, especially that we do that for every field.

Quoted 7 lines

Do you mean as opposed to allocating a larger chunk at a time? realloc already does this.

With a quick whipup test, realloc()ing same pointer repeatedly for sizes 1 to 0xffffff (randomly chosen end point) with increments of 1, the returned pointer was different a total of 29 times. For funzies, a total of 9 times when stdout was a pipe instead of tty.

I have expected that even if it's not a part of the standard the actual implementation would optimize for this. Nice to see it's this good.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Have you tried comparing times igt_results for some intermediates with large dmesgs?

I can do that but I won't be expecting much difference.

Yeah, does not make sense to test it. Go ahead with mergeing.

Thanks. Merged now.

Signature · 5 lines
Petri Latvala
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#6 lore raw

PATCH v2 2/2 runner/json_tests: Test handling of unprintable output from tests

In reply to Petri Latvala

A simple test output with numbers from 1 to 255, both in plain text form and as a single byte with that particular value.

Note that the json spec doesn't require \u-encoding for characters other than '"', '\' and the range U+0000 to U+001F, the raw non-\u-encoded UTF-8 in the reference.json file for bytes 128 and up is what libjson-c outputs for those codepoints and is valid.

The validity of the json file can be verified with iconv, i.e.

 $ iconv -f UTF-8 reference.json -o /dev/null && echo it is utf-8

v2: Rebase over dynamic subtest tests, trivial

---
 .../unprintable-characters/0/dmesg.txt        |   5 +
 .../unprintable-characters/0/err.txt          | 258 +++++++++++++++++
 .../unprintable-characters/0/journal.txt      |   2 +
 .../unprintable-characters/0/out.txt          | 259 ++++++++++++++++++
 .../unprintable-characters/README.txt         |   2 +
 .../unprintable-characters/endtime.txt        |   1 +
 .../unprintable-characters/joblist.txt        |   1 +
 .../unprintable-characters/metadata.txt       |  12 +
 .../unprintable-characters/reference.json     |  72 +++++
 .../unprintable-characters/starttime.txt      |   1 +
 .../unprintable-characters/uname.txt          |   1 +
 runner/runner_json_tests.c                    |   1 +
 12 files changed, 615 insertions(+)
 create mode 100644 runner/json_tests_data/unprintable-characters/0/dmesg.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/0/err.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/0/journal.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/0/out.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/README.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/endtime.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/joblist.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/metadata.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/reference.json
 create mode 100644 runner/json_tests_data/unprintable-characters/starttime.txt
 create mode 100644 runner/json_tests_data/unprintable-characters/uname.txt
runner/json_tests_data/unprintable-characters/0/dmesg.txt new file +5 -0
new file mode 100644
index 00000000..6aac2735
@@ -0,0 +1,5 @@
+6,951,3216186095083,-;Console: switching to colour dummy device 80x25
+14,952,3216186095097,-;[IGT] successtest: executing
+14,953,3216186101115,-;[IGT] successtest: starting subtest first-subtest
+14,955,3216186101160,-;[IGT] successtest: exiting, ret=0
+6,956,3216186101299,-;Console: switching to colour frame buffer device 240x75
runner/json_tests_data/unprintable-characters/0/err.txt new file +258 -0

258 lines not on this page · raw message

runner/json_tests_data/unprintable-characters/0/journal.txt new file +2 -0
new file mode 100644
index 00000000..86a30e07
@@ -0,0 +1,2 @@
+first-subtest
+exit:0 (0.014s)
runner/json_tests_data/unprintable-characters/0/out.txt new file +259 -0

259 lines not on this page · raw message

runner/json_tests_data/unprintable-characters/README.txt new file +2 -0
new file mode 100644
index 00000000..046605ea
@@ -0,0 +1,2 @@
+Any nonprintable output in stdout and stderr should yield a json file
+that is still valid UTF-8.
runner/json_tests_data/unprintable-characters/endtime.txt new file +1 -0
new file mode 100644
index 00000000..635f6ae9
@@ -0,0 +1 @@
+1539953735.172373
runner/json_tests_data/unprintable-characters/joblist.txt new file +1 -0
new file mode 100644
index 00000000..81f914a7
@@ -0,0 +1 @@
+successtest first-subtest
runner/json_tests_data/unprintable-characters/metadata.txt new file +12 -0
new file mode 100644
index 00000000..c501ae0e
@@ -0,0 +1,12 @@
+abort_mask : 0
+name : normal-run
+dry_run : 0
+sync : 0
+log_level : 0
+overwrite : 0
+multiple_mode : 0
+inactivity_timeout : 0
+use_watchdog : 0
+piglit_style_dmesg : 0
+test_root : /path/does/not/exist
+results_path : /path/does/not/exist
runner/json_tests_data/unprintable-characters/reference.json new file +72 -0

73 lines not on this page · raw message

runner/json_tests_data/unprintable-characters/starttime.txt new file +1 -0
new file mode 100644
index 00000000..ae038f18
@@ -0,0 +1 @@
+1539953735.111039
runner/json_tests_data/unprintable-characters/uname.txt new file +1 -0
new file mode 100644
index 00000000..a7aef6f7
@@ -0,0 +1 @@
+Linux hostname 4.18.0-1-amd64 #1 SMP Debian 4.18.6-1 (2018-09-06) x86_64
runner/runner_json_tests.c +1 -0
index 21e87a02..bf4c285b 100644
@@ -164,6 +164,7 @@ static const char *dirnames[] = {
 	"dmesg-warn-level-one-piglit-style",
 	"dynamic-subtests",
 	"dynamic-subtest-name-in-multiple-subtests",
+	"unprintable-characters",
 };
 
 igt_main
Signature · 1 line
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

Reviewed-by on v2 2/2
#7 lore raw

Re: [igt-dev] [PATCH i-g-t v2 2/2] runner/json_tests: Test handling of unprintable output from tests

Quoted 10 lines · Petri Latvala

A simple test output with numbers from 1 to 255, both in plain text form and as a single byte with that particular value.

Note that the json spec doesn't require \u-encoding for characters other than '"', '\' and the range U+0000 to U+001F, the raw non-\u-encoded UTF-8 in the reference.json file for bytes 128 and up is what libjson-c outputs for those codepoints and is valid.

The validity of the json file can be verified with iconv, i.e.

Quoted 7 lines
 $ iconv -f UTF-8 reference.json -o /dev/null && echo it is utf-8

v2: Rebase over dynamic subtest tests, trivial

still looks good, and patchwork still does not like it... someday I'll get to fixing the diff parsing logic and probably break other edge cases in the process :-P

since gitlab's pipeline is passing feel free to merge it

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev