qemu-devel
[Top][All Lists]
Advanced

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

[PATCH for-9.0 v2 1/7] qtest/virtio-9p-test.c: add '_path' in path vars


From: Daniel Henrique Barboza
Subject: [PATCH for-9.0 v2 1/7] qtest/virtio-9p-test.c: add '_path' in path vars
Date: Wed, 27 Mar 2024 06:31:38 -0300

Add a '_path' call in all variables that are receiving a full path via
virtio_9p_test_path().

Aside from being more accurate with what the variable represents, this
will allow us to use 'new_dir' and 'real_path' and so on to parametrize
test values in the next patch.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
 tests/qtest/virtio-9p-test.c | 64 ++++++++++++++++++++----------------
 1 file changed, 35 insertions(+), 29 deletions(-)

diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 65e69491e5..23edca05c5 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -512,7 +512,7 @@ static void fs_create_dir(void *obj, void *data, 
QGuestAllocator *t_alloc)
     v9fs_set_allocator(t_alloc);
     struct stat st;
     g_autofree char *root_path = virtio_9p_test_path("");
-    g_autofree char *new_dir = virtio_9p_test_path("01");
+    g_autofree char *new_dir_path = virtio_9p_test_path("01");
 
     g_assert(root_path != NULL);
 
@@ -520,7 +520,7 @@ static void fs_create_dir(void *obj, void *data, 
QGuestAllocator *t_alloc)
     tmkdir({ .client = v9p, .atPath = "/", .name = "01" });
 
     /* check if created directory really exists now ... */
-    g_assert(stat(new_dir, &st) == 0);
+    g_assert(stat(new_dir_path, &st) == 0);
     /* ... and is actually a directory */
     g_assert((st.st_mode & S_IFMT) == S_IFDIR);
 }
@@ -531,7 +531,7 @@ static void fs_unlinkat_dir(void *obj, void *data, 
QGuestAllocator *t_alloc)
     v9fs_set_allocator(t_alloc);
     struct stat st;
     g_autofree char *root_path = virtio_9p_test_path("");
-    g_autofree char *new_dir = virtio_9p_test_path("02");
+    g_autofree char *new_dir_path = virtio_9p_test_path("02");
 
     g_assert(root_path != NULL);
 
@@ -539,7 +539,7 @@ static void fs_unlinkat_dir(void *obj, void *data, 
QGuestAllocator *t_alloc)
     tmkdir({ .client = v9p, .atPath = "/", .name = "02" });
 
     /* check if created directory really exists now ... */
-    g_assert(stat(new_dir, &st) == 0);
+    g_assert(stat(new_dir_path, &st) == 0);
     /* ... and is actually a directory */
     g_assert((st.st_mode & S_IFMT) == S_IFDIR);
 
@@ -548,7 +548,7 @@ static void fs_unlinkat_dir(void *obj, void *data, 
QGuestAllocator *t_alloc)
         .flags = P9_DOTL_AT_REMOVEDIR
     });
     /* directory should be gone now */
-    g_assert(stat(new_dir, &st) != 0);
+    g_assert(stat(new_dir_path, &st) != 0);
 }
 
 static void fs_create_file(void *obj, void *data, QGuestAllocator *t_alloc)
@@ -556,14 +556,14 @@ static void fs_create_file(void *obj, void *data, 
QGuestAllocator *t_alloc)
     QVirtio9P *v9p = obj;
     v9fs_set_allocator(t_alloc);
     struct stat st;
-    g_autofree char *new_file = virtio_9p_test_path("03/1st_file");
+    g_autofree char *new_file_path = virtio_9p_test_path("03/1st_file");
 
     tattach({ .client = v9p });
     tmkdir({ .client = v9p, .atPath = "/", .name = "03" });
     tlcreate({ .client = v9p, .atPath = "03", .name = "1st_file" });
 
     /* check if created file exists now ... */
-    g_assert(stat(new_file, &st) == 0);
+    g_assert(stat(new_file_path, &st) == 0);
     /* ... and is a regular file */
     g_assert((st.st_mode & S_IFMT) == S_IFREG);
 }
@@ -573,20 +573,20 @@ static void fs_unlinkat_file(void *obj, void *data, 
QGuestAllocator *t_alloc)
     QVirtio9P *v9p = obj;
     v9fs_set_allocator(t_alloc);
     struct stat st;
-    g_autofree char *new_file = virtio_9p_test_path("04/doa_file");
+    g_autofree char *new_file_path = virtio_9p_test_path("04/doa_file");
 
     tattach({ .client = v9p });
     tmkdir({ .client = v9p, .atPath = "/", .name = "04" });
     tlcreate({ .client = v9p, .atPath = "04", .name = "doa_file" });
 
     /* check if created file exists now ... */
-    g_assert(stat(new_file, &st) == 0);
+    g_assert(stat(new_file_path, &st) == 0);
     /* ... and is a regular file */
     g_assert((st.st_mode & S_IFMT) == S_IFREG);
 
     tunlinkat({ .client = v9p, .atPath = "04", .name = "doa_file" });
     /* file should be gone now */
-    g_assert(stat(new_file, &st) != 0);
+    g_assert(stat(new_file_path, &st) != 0);
 }
 
 static void fs_symlink_file(void *obj, void *data, QGuestAllocator *t_alloc)
@@ -594,13 +594,13 @@ static void fs_symlink_file(void *obj, void *data, 
QGuestAllocator *t_alloc)
     QVirtio9P *v9p = obj;
     v9fs_set_allocator(t_alloc);
     struct stat st;
-    g_autofree char *real_file = virtio_9p_test_path("05/real_file");
-    g_autofree char *symlink_file = virtio_9p_test_path("05/symlink_file");
+    g_autofree char *real_file_path = virtio_9p_test_path("05/real_file");
+    g_autofree char *symlink_file_path = 
virtio_9p_test_path("05/symlink_file");
 
     tattach({ .client = v9p });
     tmkdir({ .client = v9p, .atPath = "/", .name = "05" });
     tlcreate({ .client = v9p, .atPath = "05", .name = "real_file" });
-    g_assert(stat(real_file, &st) == 0);
+    g_assert(stat(real_file_path, &st) == 0);
     g_assert((st.st_mode & S_IFMT) == S_IFREG);
 
     tsymlink({
@@ -609,7 +609,7 @@ static void fs_symlink_file(void *obj, void *data, 
QGuestAllocator *t_alloc)
     });
 
     /* check if created link exists now */
-    g_assert(stat(symlink_file, &st) == 0);
+    g_assert(stat(symlink_file_path, &st) == 0);
 }
 
 static void fs_unlinkat_symlink(void *obj, void *data,
@@ -618,24 +618,24 @@ static void fs_unlinkat_symlink(void *obj, void *data,
     QVirtio9P *v9p = obj;
     v9fs_set_allocator(t_alloc);
     struct stat st;
-    g_autofree char *real_file = virtio_9p_test_path("06/real_file");
-    g_autofree char *symlink_file = virtio_9p_test_path("06/symlink_file");
+    g_autofree char *real_file_path = virtio_9p_test_path("06/real_file");
+    g_autofree char *symlink_file_path = 
virtio_9p_test_path("06/symlink_file");
 
     tattach({ .client = v9p });
     tmkdir({ .client = v9p, .atPath = "/", .name = "06" });
     tlcreate({ .client = v9p, .atPath = "06", .name = "real_file" });
-    g_assert(stat(real_file, &st) == 0);
+    g_assert(stat(real_file_path, &st) == 0);
     g_assert((st.st_mode & S_IFMT) == S_IFREG);
 
     tsymlink({
         .client = v9p, .atPath = "06", .name = "symlink_file",
         .symtgt = "real_file"
     });
-    g_assert(stat(symlink_file, &st) == 0);
+    g_assert(stat(symlink_file_path, &st) == 0);
 
     tunlinkat({ .client = v9p, .atPath = "06", .name = "symlink_file" });
     /* symlink should be gone now */
-    g_assert(stat(symlink_file, &st) != 0);
+    g_assert(stat(symlink_file_path, &st) != 0);
 }
 
 static void fs_hardlink_file(void *obj, void *data, QGuestAllocator *t_alloc)
@@ -643,13 +643,16 @@ static void fs_hardlink_file(void *obj, void *data, 
QGuestAllocator *t_alloc)
     QVirtio9P *v9p = obj;
     v9fs_set_allocator(t_alloc);
     struct stat st_real, st_link;
-    g_autofree char *real_file = virtio_9p_test_path("07/real_file");
-    g_autofree char *hardlink_file = virtio_9p_test_path("07/hardlink_file");
+    g_autofree char *real_file_path = NULL;
+    g_autofree char *hardlink_file_path = NULL;
+
+    real_file_path = virtio_9p_test_path("07/real_file");
+    hardlink_file_path = virtio_9p_test_path("07/hardlink_file");
 
     tattach({ .client = v9p });
     tmkdir({ .client = v9p, .atPath = "/", .name = "07" });
     tlcreate({ .client = v9p, .atPath = "07", .name = "real_file" });
-    g_assert(stat(real_file, &st_real) == 0);
+    g_assert(stat(real_file_path, &st_real) == 0);
     g_assert((st_real.st_mode & S_IFMT) == S_IFREG);
 
     tlink({
@@ -658,7 +661,7 @@ static void fs_hardlink_file(void *obj, void *data, 
QGuestAllocator *t_alloc)
     });
 
     /* check if link exists now ... */
-    g_assert(stat(hardlink_file, &st_link) == 0);
+    g_assert(stat(hardlink_file_path, &st_link) == 0);
     /* ... and it's a hard link, right? */
     g_assert((st_link.st_mode & S_IFMT) == S_IFREG);
     g_assert(st_link.st_dev == st_real.st_dev);
@@ -671,26 +674,29 @@ static void fs_unlinkat_hardlink(void *obj, void *data,
     QVirtio9P *v9p = obj;
     v9fs_set_allocator(t_alloc);
     struct stat st_real, st_link;
-    g_autofree char *real_file = virtio_9p_test_path("08/real_file");
-    g_autofree char *hardlink_file = virtio_9p_test_path("08/hardlink_file");
+    g_autofree char *real_file_path = NULL;
+    g_autofree char *hardlink_file_path = NULL;
+
+    real_file_path = virtio_9p_test_path("08/real_file");
+    hardlink_file_path = virtio_9p_test_path("08/hardlink_file");
 
     tattach({ .client = v9p });
     tmkdir({ .client = v9p, .atPath = "/", .name = "08" });
     tlcreate({ .client = v9p, .atPath = "08", .name = "real_file" });
-    g_assert(stat(real_file, &st_real) == 0);
+    g_assert(stat(real_file_path, &st_real) == 0);
     g_assert((st_real.st_mode & S_IFMT) == S_IFREG);
 
     tlink({
         .client = v9p, .atPath = "08", .name = "hardlink_file",
         .toPath = "08/real_file"
     });
-    g_assert(stat(hardlink_file, &st_link) == 0);
+    g_assert(stat(hardlink_file_path, &st_link) == 0);
 
     tunlinkat({ .client = v9p, .atPath = "08", .name = "hardlink_file" });
     /* symlink should be gone now */
-    g_assert(stat(hardlink_file, &st_link) != 0);
+    g_assert(stat(hardlink_file_path, &st_link) != 0);
     /* and old file should still exist */
-    g_assert(stat(real_file, &st_real) == 0);
+    g_assert(stat(real_file_path, &st_real) == 0);
 }
 
 static void *assign_9p_local_driver(GString *cmd_line, void *arg)
-- 
2.44.0




reply via email to

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