qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 3/3] tests/migration:fix unreachable path in stress test


From: Mao Zhongyi
Subject: [PATCH v3 3/3] tests/migration:fix unreachable path in stress test
Date: Fri, 4 Oct 2019 11:43:48 +0800

If stressone() or stress() exits it's because of a failure
because the test runs forever otherwise, so change stressone
type to void and stress should always return -1 to make the
path of 'if (stress(ramsizeGB, ncpus) < 0)' can be reached.

Signed-off-by: Mao Zhongyi <address@hidden>
---
 tests/migration/stress.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/tests/migration/stress.c b/tests/migration/stress.c
index debf34359f..b0df1323bb 100644
--- a/tests/migration/stress.c
+++ b/tests/migration/stress.c
@@ -167,7 +167,7 @@ static unsigned long long now(void)
     return (tv.tv_sec * 1000ull) + (tv.tv_usec / 1000ull);
 }
 
-static int stressone(unsigned long long ramsizeMB)
+static void stressone(unsigned long long ramsizeMB)
 {
     size_t pagesPerMB = 1024 * 1024 / PAGE_SIZE;
     g_autofree char *ram = g_malloc(ramsizeMB * 1024 * 1024);
@@ -181,12 +181,12 @@ static int stressone(unsigned long long ramsizeMB)
     if (!ram) {
         fprintf(stderr, "%s (%05d): ERROR: cannot allocate %llu MB of RAM: 
%s\n",
                 argv0, gettid(), ramsizeMB, strerror(errno));
-        return -1;
+        return;
     }
     if (!data) {
         fprintf(stderr, "%s (%d): ERROR: cannot allocate %d bytes of RAM: 
%s\n",
                 argv0, gettid(), PAGE_SIZE, strerror(errno));
-        return -1;
+        return;
     }
 
     /* We don't care about initial state, but we do want
@@ -197,7 +197,7 @@ static int stressone(unsigned long long ramsizeMB)
     memset(ram, 0xfe, ramsizeMB * 1024 * 1024);
 
     if (random_bytes(data, PAGE_SIZE) < 0) {
-        return -1;
+        return;
     }
 
     before = now();
@@ -250,7 +250,7 @@ static int stress(unsigned long long ramsizeGB, int ncpus)
 
     stressone(ramsizeMB);
 
-    return 0;
+    return -1;
 }
 
 
@@ -348,6 +348,4 @@ int main(int argc, char **argv)
 
     if (stress(ramsizeGB, ncpus) < 0)
         exit_failure();
-
-    exit_success();
 }
-- 
2.17.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]