Skip to contentSkip to conversation

qtests: avoid printing comments before g_test_init()

PATCH Applied Daniel P. Berrangé 5 participants 8 messages Mar 17, 2023 – Mar 24, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qtests: avoid printing comments before g_test_init()

The TAP protocol version line must be the first thing printed on stdout. The migration test failed that requirement in certain scenarios:

# Skipping test: Userfault not available (builtdtime) TAP version 13

  # random seed: R02Sc120c807f11053eb90bfea845ba1e368
  1..32
  # Start of x86_64 tests
  # Start of migration tests
  ....

The TAP version is printed by g_test_init(), so we need to make sure that any methods which print are run after that.

---
 tests/qtest/migration-test.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tests/qtest/migration-test.c +7 -3
index 75d4f1d4a9..3b615b0da9 100644
@@ -2462,14 +2462,18 @@ static bool kvm_dirty_ring_supported(void)
 
 int main(int argc, char **argv)
 {
-    const bool has_kvm = qtest_has_accel("kvm");
-    const bool has_uffd = ufd_version_check();
-    const char *arch = qtest_get_arch();
+    bool has_kvm;
+    bool has_uffd;
+    const char *arch;
     g_autoptr(GError) err = NULL;
     int ret;
 
     g_test_init(&argc, &argv, NULL);
 
+    has_kvm = qtest_has_accel("kvm");
+    has_uffd = ufd_version_check();
+    arch = qtest_get_arch();
+
     /*
      * On ppc64, the test only works with kvm-hv, but not with kvm-pr and TCG
      * is touchy due to race conditions on dirty bits (especially on PPC for
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Daniel P. Berrangé

The TAP protocol version line must be the first thing printed on stdout. The migration test failed that requirement in certain scenarios:

# Skipping test: Userfault not available (builtdtime) TAP version 13

  # random seed: R02Sc120c807f11053eb90bfea845ba1e368
  1..32
  # Start of x86_64 tests
  # Start of migration tests
  ....
Quoted 4 lines

The TAP version is printed by g_test_init(), so we need to make sure that any methods which print are run after that.

Yep, that's exactly the same as the patch I wrote but hadn't quite got as far as sending :-)

thanks
-- PMM

Applied
#2 lore raw
In reply to Daniel P. Berrangé
Quoted 12 lines · Daniel P. Berrangé

The TAP protocol version line must be the first thing printed on stdout. The migration test failed that requirement in certain scenarios:

# Skipping test: Userfault not available (builtdtime) TAP version 13

  # random seed: R02Sc120c807f11053eb90bfea845ba1e368
  1..32
  # Start of x86_64 tests
  # Start of migration tests
  ....
Quoted 4 lines

The TAP version is printed by g_test_init(), so we need to make sure that any methods which print are run after that.

Queued to pr/170323-for-8.0-1, thanks.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
Reviewed-by on v1 1/1
#3 lore raw
In reply to Daniel P. Berrangé
Quoted 12 lines · Daniel P. Berrangé

The TAP protocol version line must be the first thing printed on stdout. The migration test failed that requirement in certain scenarios:

   # Skipping test: Userfault not available (builtdtime)
   TAP version 13
   # random seed: R02Sc120c807f11053eb90bfea845ba1e368
   1..32
   # Start of x86_64 tests
   # Start of migration tests
   ....
Quoted 7 lines

The TAP version is printed by g_test_init(), so we need to make sure that any methods which print are run after that.

---
  tests/qtest/migration-test.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
Reviewed-by on v1 1/1
#4 lore raw
In reply to Daniel P. Berrangé
Quoted 12 lines · Daniel P. Berrangé

The TAP protocol version line must be the first thing printed on stdout. The migration test failed that requirement in certain scenarios:

# Skipping test: Userfault not available (builtdtime) TAP version 13

  # random seed: R02Sc120c807f11053eb90bfea845ba1e368
  1..32
  # Start of x86_64 tests
  # Start of migration tests
  ....
Quoted 5 lines

The TAP version is printed by g_test_init(), so we need to make sure that any methods which print are run after that.

---

tests/qtest/migration-test.c static bool kvm_dirty_ring_supported(void) · line 2467

Quoted 6 lines
tests/qtest/migration-test.c +3 -3
-    const bool has_kvm = qtest_has_accel("kvm");
-    const bool has_uffd = ufd_version_check();
-    const char *arch = qtest_get_arch();
+    bool has_kvm;
+    bool has_uffd;
+    const char *arch;

Why don't you move also the declarations of the variables?
I think that one of the biggest troubles of C is variables that are not initialized.

All compilers that we support are C99 or later, so we can do that (and we already do in lot of places.)

And yeap, I know that CodingStyle says otherwise, but I think that what is wrong is CodingStyle.

https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg03836.html

Later, Juan.

#5 lore raw
Quoted 28 lines · Juan Quintela
Quoted 12 lines · Daniel P. Berrangé

The TAP protocol version line must be the first thing printed on stdout. The migration test failed that requirement in certain scenarios:

   # Skipping test: Userfault not available (builtdtime)
   TAP version 13
   # random seed: R02Sc120c807f11053eb90bfea845ba1e368
   1..32
   # Start of x86_64 tests
   # Start of migration tests
   ....
Quoted 5 lines

The TAP version is printed by g_test_init(), so we need to make sure that any methods which print are run after that.

---

tests/qtest/migration-test.c static bool kvm_dirty_ring_supported(void) · line 2467

Quoted 6 lines
tests/qtest/migration-test.c +3 -3
-    const bool has_kvm = qtest_has_accel("kvm");
-    const bool has_uffd = ufd_version_check();
-    const char *arch = qtest_get_arch();
+    bool has_kvm;
+    bool has_uffd;
+    const char *arch;
Quoted 6 lines

Why don't you move also the declarations of the variables?
I think that one of the biggest troubles of C is variables that are not initialized.

All compilers that we support are C99 or later, so we can do that (and we already do in lot of places.)

I think the coding style has been created before we switched to -std=gnu99 for compiling QEMU, so a lot of GCCs were still using C89 by default?

Quoted 4 lines

And yeap, I know that CodingStyle says otherwise, but I think that what is wrong is CodingStyle.

https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg03836.html

Please use proper prefixes in the subject when sending patches ("docs/devel:" here), otherwise your patches might not get the right attention (at least on my side, it was filtered away as a patch that was relevant to me) - and also put some recent contributors on CC:

Thanks,
Thomas

#6 lore raw
Quoted 34 lines · Thomas Huth
Quoted 26 lines · Juan Quintela
Quoted 12 lines · Daniel P. Berrangé

The TAP protocol version line must be the first thing printed on stdout. The migration test failed that requirement in certain scenarios:

   # Skipping test: Userfault not available (builtdtime)
   TAP version 13
   # random seed: R02Sc120c807f11053eb90bfea845ba1e368
   1..32
   # Start of x86_64 tests
   # Start of migration tests
   ....
Quoted 5 lines

The TAP version is printed by g_test_init(), so we need to make sure that any methods which print are run after that.

---

tests/qtest/migration-test.c static bool kvm_dirty_ring_supported(void) · line 2467

Quoted 6 lines
tests/qtest/migration-test.c +3 -3
-    const bool has_kvm = qtest_has_accel("kvm");
-    const bool has_uffd = ufd_version_check();
-    const char *arch = qtest_get_arch();
+    bool has_kvm;
+    bool has_uffd;
+    const char *arch;
Quoted 6 lines

Why don't you move also the declarations of the variables?
I think that one of the biggest troubles of C is variables that are not initialized.
All compilers that we support are C99 or later, so we can do that (and
we already do in lot of places.)

Quoted 3 lines

I think the coding style has been created before we switched to -std=gnu99 for compiling QEMU, so a lot of GCCs were still using C89 by default?

Yes, that is the actitude.

I got sick when I see new code that still does:

char *foo = (char *)malloc(...);

It is is C89, it has been enough to know that it is not needed.

And yes, that particular one is not used in qemu anymore, but:

void *opaque;

....

Foo *foo = (Foo *)opaque;

Is still introduced in new code, and it is not needed since C89.

Quoted 8 lines
Quoted 3 lines

And yeap, I know that CodingStyle says otherwise, but I think that what is wrong is CodingStyle.
https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg03836.html

Please use proper prefixes in the subject when sending patches ("docs/devel:" here), otherwise your patches might not get the right attention (at least on my side, it was filtered away as a patch that was relevant to me) - and also put some recent contributors on CC:

I didn't knew the docs/devel preffix.

About the CC'd, I expected that git-publish be good enough at doing that, but it appears not.

Anyways, thanks.

Later, Juan.

#7 lore raw
Quoted 66 lines · Juan Quintela
Quoted 34 lines · Thomas Huth
Quoted 26 lines · Juan Quintela
Quoted 12 lines · Daniel P. Berrangé

The TAP protocol version line must be the first thing printed on stdout. The migration test failed that requirement in certain scenarios:

   # Skipping test: Userfault not available (builtdtime)
   TAP version 13
   # random seed: R02Sc120c807f11053eb90bfea845ba1e368
   1..32
   # Start of x86_64 tests
   # Start of migration tests
   ....
Quoted 5 lines

The TAP version is printed by g_test_init(), so we need to make sure that any methods which print are run after that.

---

tests/qtest/migration-test.c static bool kvm_dirty_ring_supported(void) · line 2467

Quoted 6 lines
tests/qtest/migration-test.c +3 -3
-    const bool has_kvm = qtest_has_accel("kvm");
-    const bool has_uffd = ufd_version_check();
-    const char *arch = qtest_get_arch();
+    bool has_kvm;
+    bool has_uffd;
+    const char *arch;
Quoted 6 lines

Why don't you move also the declarations of the variables?
I think that one of the biggest troubles of C is variables that are not initialized.
All compilers that we support are C99 or later, so we can do that (and
we already do in lot of places.)

Quoted 3 lines

I think the coding style has been created before we switched to -std=gnu99 for compiling QEMU, so a lot of GCCs were still using C89 by default?

Yes, that is the actitude.

I got sick when I see new code that still does:

char *foo = (char *)malloc(...);

It is is C89, it has been enough to know that it is not needed.

And yes, that particular one is not used in qemu anymore, but:

void *opaque;

....

Foo *foo = (Foo *)opaque;

Is still introduced in new code, and it is not needed since C89.

Quoted 8 lines
Quoted 3 lines

And yeap, I know that CodingStyle says otherwise, but I think that what is wrong is CodingStyle.
https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg03836.html

Please use proper prefixes in the subject when sending patches ("docs/devel:" here), otherwise your patches might not get the right attention (at least on my side, it was filtered away as a patch that was relevant to me) - and also put some recent contributors on CC:

Quoted 4 lines

I didn't knew the docs/devel preffix.

About the CC'd, I expected that git-publish be good enough at doing that, but it appears not.

I've just sent:

Subject: [RFC PATCH] MAINTAINERS: add a section for policy documents
Date: Fri, 24 Mar 2023 17:38:36 +0000
Message-Id: <[email protected]>

to collect willing victims^H^H^H^H^H^H volunteers who want to track project related discussions like this.

Quoted 4 lines

Anyways, thanks.

Later, Juan.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro