[PATCH i-g-t v2 6/7] runner/settings: Serialize command line

Lucas De Marchi lucas.demarchi at intel.com
Thu Jan 23 06:43:55 UTC 2025


On Wed, Jan 22, 2025 at 03:55:34PM -0300, Gustavo Sousa wrote:
>Quoting Peter Senna Tschudin (2025-01-22 15:35:30-03:00)
>>
>>
>>On 22.01.2025 19:26, Gustavo Sousa wrote:
>>> Quoting Peter Senna Tschudin (2025-01-22 15:16:59-03:00)
>>>>
>>>>
>>>> On 22.01.2025 13:40, Gustavo Sousa wrote:
>>>>> Quoting Lucas De Marchi (2025-01-21 19:57:32-03:00)
>>>>>> Serialize the command line to metadata.txt. The expected format in the
>>>>>> metadata.txt is like below:
>>>>>>
>>>>>>        cmdline.argc : 6
>>>>>>        cmdline.argv[0] : ./build/runner/igt_runner
>>>>>>        cmdline.argv[1] : -o
>>>>>>        cmdline.argv[2] : --test-list
>>>>>>        cmdline.argv[3] : /tmp/testlist.txt
>>>>>>        cmdline.argv[4] : build/tests/
>>>>>>        cmdline.argv[5] : /tmp/results
>>>>>
>>>>> One limitation here is that we would run into problems if one of the
>>>>> arguments contains a newline character. We need to have a proper way of
>>>>> handling that.
>>>>
>>>> I tested this by adding -t '(?m)\b\w*exec\w*\b\n', is that what you mean?
>>>
>>> If you are using bash, I'm afraid '\n' in '(?m)\b\w*exec\w*\b\n' is not
>>> turned into a real newline character. Something like $'foo\nbar'
>>> would.
>>>
>>> Example:
>>>
>>>   $ echo 'foo\nbar'
>>>   foo\nbar
>>>
>>>   $ echo $'foo\nbar'
>>>   foo
>>>   bar
>>
>>No no, I am looking for an example that I can pass to igt_runner.

sudo ./build/runner/igt_runner -e FOO='this is a
very
weird
env
var
with 
newlines' -o --test-list /tmp/testlist.txt build/tests/ /tmp/results

it crashes for me when generating the json with:

Program received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:76
warning: 76     ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory
(gdb) bt
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:76
#1  0x00007ffff7cfcd95 in json_object_new_string () from /lib/x86_64-linux-gnu/libjson-c.so.5
#2  0x00005555555659a5 in generate_results_json (dirfd=dirfd at entry=3) at ../runner/resultgen.c:2324
#3  0x0000555555567e81 in generate_results (dirfd=3) at ../runner/resultgen.c:2408
#4  0x0000555555567ff3 in generate_results_path (resultspath=<optimized out>) at ../runner/resultgen.c:2447
#5  0x00005555555593d2 in main (argc=<optimized out>, argv=0x7fffffffe3c8) at ../runner/runner.c:48


metadata.txt:
cmdline.argv[2] : FOO=this is a
very
weirld
env
var
with 
newlines
cmdline.argv[3] : -o
cmdline.argv[4] : --test-list
cmdline.argv[5] : /tmp/testlist.txt
cmdline.argv[6] : build/tests/
cmdline.argv[7] : /tmp/results

>
>Perhaps that would be possible for --hook and --env, since the user is
>free to pass anything there, so I would prefer that we are prepared for
>that.
>
>> If there
>>is no way to pass a newline character to igt_runner, then there is no
>>problem. :-) At least not a blocker for this patch, and we can create a
>>Jira for improving special character handling.
>
>If the majority thinks not supporting newlines right now is okay, then
>I won't object. :-)

well... we should at least no crash :)

thanks
Lucas De Marchi

>
>--
>Gustavo Sousa


More information about the igt-dev mailing list