Patchwork [for-4.0,1/5] tests/boot-serial: Get rid of global_qtest variable

login
register
mail settings
Submitter Thomas Huth
Date Dec. 6, 2018, 4:49 p.m.
Message ID <1544114998-1513-2-git-send-email-thuth@redhat.com>
Download mbox | patch
Permalink /patch/674351/
State New
Headers show

Comments

Thomas Huth - Dec. 6, 2018, 4:49 p.m.
The test does not use any of the functions that require global_qtest,
so we can simply get rid of this global variable here.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/boot-serial-test.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
Eric Blake - Dec. 6, 2018, 6:42 p.m.
On 12/6/18 10:49 AM, Thomas Huth wrote:
> The test does not use any of the functions that require global_qtest,
> so we can simply get rid of this global variable here.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   tests/boot-serial-test.c | 13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
> 

> -    global_qtest = qtest_initf("%s %s -M %s,accel=tcg:kvm "
> -                               "-chardev file,id=serial0,path=%s "
> -                               "-no-shutdown -serial chardev:serial0 %s",
> -                               codeparam, code ? codetmp : "",
> -                               test->machine, serialtmp, test->extra);
> +    qts = qtest_initf("%s %s -M %s,accel=tcg:kvm -no-shutdown "
> +                      "-chardev file,id=serial0,path=%s "
> +                      " -serial chardev:serial0 %s",

What happened to -no-shutdown?

> +                      codeparam, code ? codetmp : "", test->machine,
> +                      serialtmp, test->extra);
>       if (code) {
Thomas Huth - Dec. 6, 2018, 7:34 p.m.
On 2018-12-06 19:42, Eric Blake wrote:
> On 12/6/18 10:49 AM, Thomas Huth wrote:
>> The test does not use any of the functions that require global_qtest,
>> so we can simply get rid of this global variable here.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   tests/boot-serial-test.c | 13 +++++++------
>>   1 file changed, 7 insertions(+), 6 deletions(-)
>>
> 
>> -    global_qtest = qtest_initf("%s %s -M %s,accel=tcg:kvm "
>> -                               "-chardev file,id=serial0,path=%s "
>> -                               "-no-shutdown -serial chardev:serial0
>> %s",
>> -                               codeparam, code ? codetmp : "",
>> -                               test->machine, serialtmp, test->extra);
>> +    qts = qtest_initf("%s %s -M %s,accel=tcg:kvm -no-shutdown "
>> +                      "-chardev file,id=serial0,path=%s "
>> +                      " -serial chardev:serial0 %s",
> 
> What happened to -no-shutdown?

Moved to the first line (since there was some more space there now).

 Thomas
Eric Blake - Dec. 6, 2018, 7:56 p.m.
On 12/6/18 1:34 PM, Thomas Huth wrote:
> On 2018-12-06 19:42, Eric Blake wrote:
>> On 12/6/18 10:49 AM, Thomas Huth wrote:
>>> The test does not use any of the functions that require global_qtest,
>>> so we can simply get rid of this global variable here.
>>>
>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>> ---
>>>    tests/boot-serial-test.c | 13 +++++++------
>>>    1 file changed, 7 insertions(+), 6 deletions(-)
>>>
>>
>>> -    global_qtest = qtest_initf("%s %s -M %s,accel=tcg:kvm "
>>> -                               "-chardev file,id=serial0,path=%s "
>>> -                               "-no-shutdown -serial chardev:serial0
>>> %s",
>>> -                               codeparam, code ? codetmp : "",
>>> -                               test->machine, serialtmp, test->extra);
>>> +    qts = qtest_initf("%s %s -M %s,accel=tcg:kvm -no-shutdown "
>>> +                      "-chardev file,id=serial0,path=%s "
>>> +                      " -serial chardev:serial0 %s",
>>
>> What happened to -no-shutdown?
> 
> Moved to the first line (since there was some more space there now).

Aha - serves me right for thinking you just reindented, rather than 
spotting that you also rearranged in order to reflow the breaks.

You still have a minor issue of a double space (one to end the -chardev 
fragment, another to start the -serial fragment); with that fixed,

Reviewed-by: Eric Blake <eblake@redhat.com>

Patch

diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c
index 8ec6aed..f085165 100644
--- a/tests/boot-serial-test.c
+++ b/tests/boot-serial-test.c
@@ -161,6 +161,7 @@  static void test_machine(const void *data)
     char codetmp[] = "/tmp/qtest-boot-serial-cXXXXXX";
     const char *codeparam = "";
     const uint8_t *code = NULL;
+    QTestState *qts;
     int ser_fd;
 
     ser_fd = mkstemp(serialtmp);
@@ -189,11 +190,11 @@  static void test_machine(const void *data)
      * Make sure that this test uses tcg if available: It is used as a
      * fast-enough smoketest for that.
      */
-    global_qtest = qtest_initf("%s %s -M %s,accel=tcg:kvm "
-                               "-chardev file,id=serial0,path=%s "
-                               "-no-shutdown -serial chardev:serial0 %s",
-                               codeparam, code ? codetmp : "",
-                               test->machine, serialtmp, test->extra);
+    qts = qtest_initf("%s %s -M %s,accel=tcg:kvm -no-shutdown "
+                      "-chardev file,id=serial0,path=%s "
+                      " -serial chardev:serial0 %s",
+                      codeparam, code ? codetmp : "", test->machine,
+                      serialtmp, test->extra);
     if (code) {
         unlink(codetmp);
     }
@@ -204,7 +205,7 @@  static void test_machine(const void *data)
     }
     unlink(serialtmp);
 
-    qtest_quit(global_qtest);
+    qtest_quit(qts);
 
     close(ser_fd);
 }