Use Jansson instead of json-c in igt_runner
cover Use Jansson instead of json-c in igt_runner
The json-c library has a hard limit of 2GB of its output. While normally it's not a problem, some very verbose edge cases make the results.json output go past that limit.
This series converts igt_runner's json-c usage to Jansson.
PATCH 1/3 runner: Use Jansson in resultgen instead of json-c
The json-c library has a hard limit of 2GB of its output. While normally it's not a problem, some very verbose edge cases make the results.json output go past that limit.
Jansson has a similar API, can work with files over 2GB and, according to JSON library and benchmarks, is slightly slower but uses less RAM to serialize its output. Jansson 2.12+ (released in 2018) is required.
This commit also updates tests to use Jansson, but they need data fixups to pass (in the next commit).
--- runner/meson.build | 12 +- runner/resultgen.c | 349 +++++++++++++++++-------------------- runner/resultgen.h | 2 +- runner/runner_json_tests.c | 129 +++++--------- runner/runner_tests.c | 60 +++---- 5 files changed, 247 insertions(+), 305 deletions(-)
runner/meson.build +6 -6
@@ -13,8 +13,8 @@ results_sources = [ 'results.c' ] runner_test_sources = [ 'runner_tests.c' ] runner_json_test_sources = [ 'runner_json_tests.c' ] -jsonc = dependency('json-c', required: build_runner) -runner_deps = [jsonc, glib] +jansson = dependency('jansson', required: build_runner, version: '>=2.12') +runner_deps = [jansson, glib] runner_c_args = [] liboping = dependency('liboping', required: get_option('oping'))
@@ -23,11 +23,11 @@ if liboping.found() runner_c_args += '-DHAVE_OPING=1' endif -if not build_tests and jsonc.found() +if not build_tests and jansson.found() error('Building test runner requires building tests') endif -if jsonc.found() +if jansson.found() subdir('testdata') runnerlib = static_library('igt_runner', runnerlib_sources,
@@ -60,14 +60,14 @@ if jsonc.found() c_args : '-DTESTDATA_DIRECTORY="@0@"'.format(testdata_dir), link_with : runnerlib, install : false, - dependencies : [igt_deps, jsonc]) + dependencies : [igt_deps, jansson]) test('runner', runner_test, timeout : 300) runner_json_test = executable('runner_json_test', runner_json_test_sources, c_args : '-DJSON_TESTS_DIRECTORY="@0@"'.format(join_paths(meson.current_source_dir(), 'json_tests_data')), link_with : runnerlib, install : false, - dependencies : [igt_deps, jsonc]) + dependencies : [igt_deps, jansson]) test('runner_json', runner_json_test, timeout : 300) build_info += 'Build test runner: true'
runner/resultgen.c +163 -186
742 lines not on this page · raw message
runner/resultgen.h +1 -1
@@ -6,6 +6,6 @@bool generate_results (int dirfd);bool generate_results_path (char *resultspath); -struct json_object *generate_results_json (int dirfd); +struct json_t *generate_results_json (int dirfd);#endif
runner/runner_json_tests.c +47 -82
190 lines not on this page · raw message
runner/runner_tests.c +30 -30
198 lines not on this page · raw message
Signature · 1 line
2.37.1
PATCH 2/3 runner/tests: Fix JSON test data
In reply to Ryszard KnopJSON files contained extra (invalid) commas which json-c was able to handle, but Jansson, Firefox and Python parsers are unhappy with.
--- .../json_tests_data/aborted-after-a-test/reference.json | 6 +++--- runner/json_tests_data/aborted-on-boot/reference.json | 4 ++-- runner/json_tests_data/dmesg-escapes/reference.json | 8 ++++---- runner/json_tests_data/empty-result-files/reference.json | 4 ++-- runner/json_tests_data/graceful-notrun/reference.json | 6 +++--- .../incomplete-before-any-subtests/reference.json | 2 +- .../notrun-results-multiple-mode/reference.json | 2 +- runner/json_tests_data/notrun-results/reference.json | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-)
runner/json_tests_data/aborted-after-a-test/reference.json +3 -3
@@ -49,7 +49,7 @@ "out":"Aborted after: successtest (first-subtest)\n\nKernel tainted (0x200)\n", "result":"fail", "err":"", - "dmesg":"", + "dmesg":"" } }, "totals":{
@@ -130,7 +130,7 @@ "notrun":0, "fail":1, "warn":0 - }, + } }, "runtimes":{ "igt@successtest":{
@@ -139,6 +139,6 @@ "start":0, "end":0.014 } - }, + } } }
runner/json_tests_data/aborted-on-boot/reference.json +2 -2
@@ -43,7 +43,7 @@ "out":"Aborted after: startup\n\nKernel tainted (0x200)\n", "result":"fail", "err":"", - "dmesg":"", + "dmesg":"" } }, "totals":{
@@ -124,7 +124,7 @@ "notrun":0, "fail":1, "warn":0 - }, + } }, "runtimes":{ }
runner/json_tests_data/dmesg-escapes/reference.json +4 -4
@@ -19,8 +19,8 @@ "end":0 }, "err":"Starting subtest: first-subtest\nSubtest first-subtest: SUCCESS (0.000s)\n", - "dmesg":"<6> [3216186.095083] Console: switching to colour dummy device 80x25\n<6> [3216186.095097] [IGT] successtest: executing\n<6> [3216186.101115] [IGT] successtest: starting subtest first-subtest\n<6> [3216186.101159] String with a\nnewline\n<6> [3216186.101159] String with a\ttab\n<6> [3216186.101159] String with an explicit\\x00NUL\n<6> [3216186.101159] The character \\x13 should be nonprintable\n<6> [3216186.101159] Escaped backslash is \\\n<6> [3216186.101159] Kernel shouldn't output this but cutoff escape \\x1\n<6> [3216186.101159] More cutoff \\x\n<6> [3216186.101159] One more \\\n<6> [3216186.101160] [IGT] successtest: exiting, ret=0\n<6> [3216186.101299] Console: switching to colour frame buffer device 240x75\n", - }, + "dmesg":"<6> [3216186.095083] Console: switching to colour dummy device 80x25\n<6> [3216186.095097] [IGT] successtest: executing\n<6> [3216186.101115] [IGT] successtest: starting subtest first-subtest\n<6> [3216186.101159] String with a\nnewline\n<6> [3216186.101159] String with a\ttab\n<6> [3216186.101159] String with an explicit\\x00NUL\n<6> [3216186.101159] The character \\x13 should be nonprintable\n<6> [3216186.101159] Escaped backslash is \\\n<6> [3216186.101159] Kernel shouldn't output this but cutoff escape \\x1\n<6> [3216186.101159] More cutoff \\x\n<6> [3216186.101159] One more \\\n<6> [3216186.101160] [IGT] successtest: exiting, ret=0\n<6> [3216186.101299] Console: switching to colour frame buffer device 240x75\n" + } }, "totals":{ "":{
@@ -61,7 +61,7 @@ "notrun":0, "fail":0, "warn":0 - }, + } }, "runtimes":{ "igt@successtest":{
@@ -70,6 +70,6 @@ "start":0, "end":0.014 } - }, + } } }
runner/json_tests_data/empty-result-files/reference.json +2 -2
@@ -14,7 +14,7 @@ "err":"", "dmesg":"", "result":"incomplete" - }, + } }, "totals":{ "":{
@@ -55,7 +55,7 @@ "notrun":0, "fail":0, "warn":0 - }, + } }, "runtimes":{ }
runner/json_tests_data/graceful-notrun/reference.json +3 -3
@@ -39,7 +39,7 @@ "err":"", "dmesg":"", "result":"notrun" - }, + } }, "totals":{ "":{
@@ -106,7 +106,7 @@ "notrun":2, "fail":0, "warn":0 - }, + } }, "runtimes":{ "igt@successtest":{
@@ -115,6 +115,6 @@ "start":0, "end":0.014 } - }, + } } }
runner/json_tests_data/incomplete-before-any-subtests/reference.json +1 -1
@@ -39,7 +39,7 @@ "err":"", "dmesg":"", "result":"notrun" - }, + } }, "totals":{ "":{
runner/json_tests_data/notrun-results-multiple-mode/reference.json +1 -1
@@ -101,6 +101,6 @@ "start":0, "end":0.014 } - }, + } } }
runner/json_tests_data/notrun-results/reference.json +1 -1
@@ -120,6 +120,6 @@ "start":0, "end":0.014 } - }, + } } }
Signature · 1 line
2.37.1
PATCH 3/3 runner: Add an on-demand test for large files
In reply to Ryszard KnopThe test in question does not carry large files, as that would require adding massive files to Git. The tested logic is not any different for large files, it's just a check if the JSON library can handle them.
To run this test, use generate_data.py. You'll need around 13GB of free space and 10+ minutes to run this test successfully. The test will be skipped by default if the SKIP_ME marker exists.
--- .../really-large-files/.gitignore | 3 + .../really-large-files/0/dmesg.txt | 0 .../really-large-files/0/err.txt | 0 .../really-large-files/0/journal.txt | 0 .../really-large-files/0/out.txt | 1 + .../really-large-files/README.txt | 7 +++ .../really-large-files/SKIP_ME | 1 + .../really-large-files/endtime.txt | 1 + .../really-large-files/generate_data.py | 20 ++++++ .../really-large-files/joblist.txt | 1 + .../really-large-files/metadata.txt | 12 ++++ .../really-large-files/reference.json | 62 +++++++++++++++++++ .../really-large-files/starttime.txt | 1 + .../really-large-files/uname.txt | 1 + runner/runner_json_tests.c | 8 ++- 15 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 runner/json_tests_data/really-large-files/.gitignore create mode 100644 runner/json_tests_data/really-large-files/0/dmesg.txt create mode 100644 runner/json_tests_data/really-large-files/0/err.txt create mode 100644 runner/json_tests_data/really-large-files/0/journal.txt create mode 100644 runner/json_tests_data/really-large-files/0/out.txt create mode 100644 runner/json_tests_data/really-large-files/README.txt create mode 100644 runner/json_tests_data/really-large-files/SKIP_ME create mode 100644 runner/json_tests_data/really-large-files/endtime.txt create mode 100644 runner/json_tests_data/really-large-files/generate_data.py create mode 100644 runner/json_tests_data/really-large-files/joblist.txt create mode 100644 runner/json_tests_data/really-large-files/metadata.txt create mode 100644 runner/json_tests_data/really-large-files/reference.json create mode 100644 runner/json_tests_data/really-large-files/starttime.txt create mode 100644 runner/json_tests_data/really-large-files/uname.txt
runner/json_tests_data/really-large-files/.gitignore new file +3 -0
@@ -0,0 +1,3 @@ +reference.json +0/out.txt +SKIP_ME
runner/json_tests_data/really-large-files/0/dmesg.txt new file +0 -0
runner/json_tests_data/really-large-files/0/err.txt new file +0 -0
runner/json_tests_data/really-large-files/0/journal.txt new file +0 -0
runner/json_tests_data/really-large-files/0/out.txt new file +1 -0
@@ -0,0 +1 @@ +This test requires massive files generated with generate_data.py to actually test stuff.
runner/json_tests_data/really-large-files/README.txt new file +7 -0
@@ -0,0 +1,7 @@ +Check if an incredibly large JSON is generated and tested properly. +This requires a large out.txt file to be available - it's not in +the repo directly, run generate_data.py to test that properly. +The SKIP_ME marker file exists to skip this test by default. + +The logic for small/large files does not change, testing this for each +commit takes a long time and does not really check anything special.
runner/json_tests_data/really-large-files/SKIP_ME new file +1 -0
@@ -0,0 +1 @@ +This marker file exists to skip this test by default.
runner/json_tests_data/really-large-files/endtime.txt new file +1 -0
@@ -0,0 +1 @@ +1539953735.172373
runner/json_tests_data/really-large-files/generate_data.py new file +20 -0
@@ -0,0 +1,20 @@ +import json + +print("Hope you've got enough memory for this! Generating text...") +PREFIX = "it's time for " + ("A" * 1024 * 1024 * 1024 * 4) + +print("Writing to out.txt...") +with open('0/out.txt', 'w') as f: + f.write(PREFIX) + +print("Loading reference.json...") +with open('reference.json', 'r') as f: + data = json.load(f) + +print("Writing new reference.json...") +with open('reference.json', 'w') as f: + data['tests']['igt@successtest@first-subtest']['out'] = PREFIX + json.dump(data, f) + +print("Removing SKIP_ME...") +os.unlink("SKIP_ME")
runner/json_tests_data/really-large-files/joblist.txt new file +1 -0
@@ -0,0 +1 @@ +successtest first-subtest
runner/json_tests_data/really-large-files/metadata.txt new file +12 -0
@@ -0,0 +1,12 @@ +abort_mask : 0 +name : really-large-files +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/really-large-files/reference.json new file +62 -0
62 lines not on this page · raw message
runner/json_tests_data/really-large-files/starttime.txt new file +1 -0
@@ -0,0 +1 @@ +1539953735.111039
runner/json_tests_data/really-large-files/uname.txt new file +1 -0
@@ -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 +7 -1
@@ -89,12 +89,17 @@ static void compare(struct json_t *one,static void run_results_and_compare (int dirfd,const char *dirname) {int testdirfd =openat (dirfd, dirname,O_RDONLY |O_DIRECTORY ); -int reference; +int skipfd, reference;struct json_t *resultsobj, *referenceobj;struct json_error_t error;igt_assert_fd (testdirfd); + skipfd =openat (testdirfd,"SKIP_ME" ,O_RDONLY ); +igt_skip_on_f (skipfd !=-1 ,"SKIP_ME marker exists - see the README " +"for this test for more information.\n" ); +close (skipfd); +igt_assert ((resultsobj =generate_results_json (testdirfd)) !=NULL ); reference =openat (testdirfd,"reference.json" ,O_RDONLY );
@@ -134,6 +139,7 @@ static const char *dirnames[] = {"dynamic-subtest-name-in-multiple-subtests" ,"unprintable-characters" ,"empty-result-files" , +"really-large-files" , "graceful-notrun", };
Signature · 1 line
2.37.1
Patchwork
CI[igt-dev] ✗ Fi.CI.BUILD: failure for Use Jansson instead of json-c in igt_runner
In reply to Ryszard Knop== Series Details ==
== Series Details ==
Series: Use Jansson instead of json-c in igt_runner
URL : https://patchwork.freedesktop.org/series/107123/
State : failure
== Summary ==
Applying: runner: Use Jansson in resultgen instead of json-c Using index info to reconstruct a base tree...
M runner/resultgen.c
Falling back to patching base and 3-way merge... Auto-merging runner/resultgen.c
CONFLICT (content): Merge conflict in runner/resultgen.c Patch failed at 0001 runner: Use Jansson in resultgen instead of json-c When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
Quoted 7 lines · Ryszard Knop
The json-c library has a hard limit of 2GB of its output. While normally it's not a problem, some very verbose edge cases make the results.json output go past that limit.
This series converts igt_runner's json-c usage to Jansson.
I haven't been able to review this thoroughly yet, but an initial comment can be made:
Absolute blockers for this series are having gitlab CI correctly set up so it builds there (should be just a matter of adding the packages to the dockerfiles), and having the required libs installed in our CI. Latter we're able to see fully done by having a successful premerge on this series.
Signature · 1 line
Petri Latvala