[PATCH] tests/uname.c: use print_quoted_string to print members of uname

Jay Joshi jay.r.joshi100 at gmail.com
Fri Mar 25 11:16:53 UTC 2016


On Fri, Mar 25, 2016 at 1:56 AM, Dmitry V. Levin <ldv at altlinux.org> wrote:
> On Thu, Mar 24, 2016 at 03:17:48PM +0530, Jay Joshi wrote:
>> Patch is attached.
>>
>> uname.test related question: When will uniq be required?
>
> It was discussed recently, see
> https://sourceforge.net/p/strace/mailman/message/34925661/
>

Wow.

>> Also, is a test for abbreviated output required?
>
> It surely won't harm. :)
>

I've seen in some tests like mmap.test, $ME_ is used in run_prog. I
think test scripts should not directly access them. What do you say?

Either,
init.sh should have method, which will pass "./${ME_%.test}" as first
parameter and rest of them as provided to itself.
or
introduce flag in run_prog which will decide whether to set $0 or not.

Which one should be preferred, if any?

Also, for abbrev output
>> From 05e69fac85562ec3541866caec727d2cf3446590 Mon Sep 17 00:00:00 2001
>> From: JayRJoshi <jay.r.joshi100 at gmail.com>
>> Date: Thu, 24 Mar 2016 12:39:32 +0530
>> Subject: [PATCH 2/2] tests/uname.c: use print_quoted_string
>>
>> * tests/uname.c: Use print_quoted_string to print members of utsname.
>> ---
>>  tests/uname.c | 28 +++++++++++++++-------------
>>  1 file changed, 15 insertions(+), 13 deletions(-)
>>
>> diff --git a/tests/uname.c b/tests/uname.c
>> index 0f1b5f3..6d7e572 100644
>> --- a/tests/uname.c
>> +++ b/tests/uname.c
>> @@ -11,21 +11,23 @@ int main()
>>  {
>>       struct utsname *const uname = tail_alloc(sizeof(struct utsname));
>>       int rc = syscall(__NR_uname, uname);
>> -     printf("uname({sysname=\"%s\", nodename=\"%s\", release=\"%s\""
>> -            ", version=\"%s\", machine=\"%s\""
>> +     printf("uname({sysname=\"");
>> +             print_quoted_string(uname->sysname);
>> +     printf("\", nodename=\"");
>> +             print_quoted_string(uname->nodename);
>> +     printf("\", release=\"");
>> +             print_quoted_string(uname->release);
>> +     printf("\", version=\"");
>> +             print_quoted_string(uname->version);
>> +     printf("\", machine=\"");
>> +             print_quoted_string(uname->machine);
>
> Why these print_quoted_string calls are indented this way?
>

I think it looks more readable this way, it's like the're nested inside quotes.

>> +     printf("\""
>>  # ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
>> -            ", domainname=\"%s\""
>> +             ", domainname=\"");
>
> Note the (unintended?) change of indentation here...
>
>> +             print_quoted_string(uname->domainname);
>> +             printf("\""
>>  # endif
>> -            "}) = %d\n",
>> -            uname->sysname,
>> -            uname->nodename,
>> -            uname->release,
>> -            uname->version,
>> -            uname->machine,
>> -# ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
>> -            uname->domainname,
>> -# endif
>> -            rc);
>> +             "}) = %d\n", rc);
>
> ... and here.

Yes, they're indented wrongly.




More information about the Strace-devel mailing list