[PATCH] test: Fix testNodeGetFreePages

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

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

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

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
participants (3)
-
Ján Tomko
-
Martin Kletzander
-
Michal Prívozník