[PATCH] test: Fix testNodeGetFreePages

Martin Kletzander posted 1 patch 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1f950458efc1032186d1c0285ab0afa212556ccb.1695730843.git.mkletzan@redhat.com
src/test/test_driver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] test: Fix testNodeGetFreePages
Posted by Martin Kletzander 7 months ago
The function is supposed to return the number of items filled into the
array and not zero.  Also change the initialization of the "randomness"
to be based on the startCell so that the values are different for each
cell even for separate calls.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 src/test/test_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index c962aa74786e..998d102ddc5a 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -4503,7 +4503,7 @@ testNodeGetFreePages(virConnectPtr conn G_GNUC_UNUSED,
                      unsigned int flags)
 {
     size_t i = 0, j = 0;
-    int x = 6;
+    int x = startCell * 6;
 
     virCheckFlags(0, -1);
 
@@ -4514,7 +4514,7 @@ testNodeGetFreePages(virConnectPtr conn G_GNUC_UNUSED,
         }
     }
 
-    return 0;
+    return cellCount * npages;
 }
 
 static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
-- 
2.42.0
Re: [PATCH] test: Fix testNodeGetFreePages
Posted by Ján Tomko 7 months ago
On a Tuesday in 2023, Martin Kletzander wrote:
>The function is supposed to return the number of items filled into the
>array and not zero.  Also change the initialization of the "randomness"
>to be based on the startCell so that the values are different for each
>cell even for separate calls.
>
>Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
>---
> src/test/test_driver.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
Re: [PATCH] test: Fix testNodeGetFreePages
Posted by Michal Prívozník 7 months ago
On 9/26/23 14:20, Martin Kletzander wrote:
> The function is supposed to return the number of items filled into the
> array and not zero.  Also change the initialization of the "randomness"
> to be based on the startCell so that the values are different for each
> cell even for separate calls.
> 
> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
> ---
>  src/test/test_driver.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index c962aa74786e..998d102ddc5a 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -4503,7 +4503,7 @@ testNodeGetFreePages(virConnectPtr conn G_GNUC_UNUSED,
>                       unsigned int flags)
>  {
>      size_t i = 0, j = 0;
> -    int x = 6;
> +    int x = startCell * 6;

So startCell is now used within the function and thus its G_GNUC_UNUSED
annotation should be dropped.

>  
>      virCheckFlags(0, -1);
>  
> @@ -4514,7 +4514,7 @@ testNodeGetFreePages(virConnectPtr conn G_GNUC_UNUSED,
>          }
>      }
>  
> -    return 0;
> +    return cellCount * npages;
>  }
>  
>  static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal
Re: [PATCH] test: Fix testNodeGetFreePages
Posted by Martin Kletzander 7 months ago
On Tue, Sep 26, 2023 at 02:20:43PM +0200, Martin Kletzander wrote:
>The function is supposed to return the number of items filled into the
>array and not zero.  Also change the initialization of the "randomness"
>to be based on the startCell so that the values are different for each
>cell even for separate calls.
>

And for this to be really true consider the following also squashed in
(already done locally):

diff --git c/src/test/test_driver.c i/src/test/test_driver.c
index 998d102ddc5a..a352fcb7b070 100644
--- c/src/test/test_driver.c
+++ i/src/test/test_driver.c
@@ -4503,11 +4503,12 @@ testNodeGetFreePages(virConnectPtr conn G_GNUC_UNUSED,
                       unsigned int flags)
  {
      size_t i = 0, j = 0;
-    int x = startCell * 6;

      virCheckFlags(0, -1);

      for (i = 0; i < cellCount; i++) {
+        int x = (startCell + i) * 6;
+
          for (j = 0; j < npages; j++) {
              x = x * 2 + 7;
              counts[(i * npages) +  j] = x;
--

>Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
>---
> src/test/test_driver.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/src/test/test_driver.c b/src/test/test_driver.c
>index c962aa74786e..998d102ddc5a 100644
>--- a/src/test/test_driver.c
>+++ b/src/test/test_driver.c
>@@ -4503,7 +4503,7 @@ testNodeGetFreePages(virConnectPtr conn G_GNUC_UNUSED,
>                      unsigned int flags)
> {
>     size_t i = 0, j = 0;
>-    int x = 6;
>+    int x = startCell * 6;
>
>     virCheckFlags(0, -1);
>
>@@ -4514,7 +4514,7 @@ testNodeGetFreePages(virConnectPtr conn G_GNUC_UNUSED,
>         }
>     }
>
>-    return 0;
>+    return cellCount * npages;
> }
>
> static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
>-- 
>2.42.0
>