From nobody Wed May 15 09:28:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1711459613; cv=none; d=zohomail.com; s=zohoarc; b=cMYHZenQHUV2fp3mdcJIhnhFT/P+eej262mKkexG0DKKb9dEjKcQlmNVuOER1SSmdVbQH2CrNl6PMnlV6YEhThDNh/K21vu0Mxl8UaQqBHUnrvggVDr3k2wwn28BABDw7SJU+Sjtoph8FUNedicRHRAyrNgQU6w18nwfQZ5ffL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711459613; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QgrS4ttSycuJ4qqEHqxmJzoOkmMPczj0AzC2izbEKKo=; b=RwDi2BxFR4KogB7wVEjgMZsAct8WRgVIM1TsgKiInIojtMvQterkYACElupxIWQ+qx71nuZ192ufwDIogq4f+lCLPpL3ZNF3l/IUczgrkLM6UW8rVWA7BbKvQU6rwBptGrapHsbEjlwoXKxKXqcAPCCVKf6I4JtiZ9AMDlgcXGs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711459613656408.76609239579443; Tue, 26 Mar 2024 06:26:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp6on-0006n7-1q; Tue, 26 Mar 2024 09:26:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rp6ol-0006mR-By for qemu-devel@nongnu.org; Tue, 26 Mar 2024 09:26:19 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp6oj-0002Wo-3j for qemu-devel@nongnu.org; Tue, 26 Mar 2024 09:26:19 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6e74aa08d15so3741991b3a.1 for ; Tue, 26 Mar 2024 06:26:16 -0700 (PDT) Received: from grind.. ([177.45.186.241]) by smtp.gmail.com with ESMTPSA id v10-20020aa799ca000000b006e9afb31e4bsm6080236pfi.12.2024.03.26.06.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 06:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1711459574; x=1712064374; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QgrS4ttSycuJ4qqEHqxmJzoOkmMPczj0AzC2izbEKKo=; b=ckvE1hACyEJZDHJYIAMQrwF6DM4iHy9rQmnOPEQWvVuozuechEyMwb4cauwn00lzSP 7/qBUKTv04BueqrD0ZcRLfSP/QRpv8cOxJ3vbwspt3fe0HDFoFdV3r1oV53w+ip/fXvG TVSiCEisrQAzUKTYefeJrsDvQmfhJiKtXp0XcYCOFgl+rNFBLKys9SY6Vr+h7xLuc9MU oR7LnN06wNk+ccVuZPV95ZCbCUJhn/NT5BTfG/SSFZxvXYEq0PjO7/b7UM3YTZ621Jqx CV4A5cIPkUz4dKsJs72c5bS6g95XgL203RtrJfBEYlasyWXMlB8CbjOElE7nYOeT8xsH Dg9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711459574; x=1712064374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QgrS4ttSycuJ4qqEHqxmJzoOkmMPczj0AzC2izbEKKo=; b=Kkm58LYxdGFIjjQvbbRnaaGMxy4lHGJmZAAamMReAxnoRWDRSIS11MPxYGfHdLQlZ9 BhvOSWk3hOq8Z3VO565eoT+Nk2CSNrEq4Cz5FZRd6dejor7DXtjS22Tjrv9TV+sDpyjg zIqzIOPpVY8bSdUNHSXrD1BJqSdrQvz//E3aeoi5jeCdr07xrvJn2juJLRzKm6VOgICb 0MlqOElsy6SSg9kkFoEQy6pEEFTy13zHIf+BLhl9tXCR0VBFg1i5RjviOemPR9wYWuH+ QfroFOEp/wG/z6p/g722O9BkEE1xepdUGyZ8aKA32W6yHap6Jf7Bi8Jzf3+X3tMu/Frx Au/Q== X-Gm-Message-State: AOJu0YzMM2aD2zRGR6bNvFkToMIN2z7Pyb22hVidi9RndHWfD8DxYOll ZS52rAlTGT6hPd12Idb0szlBwpHz+SWMBMpk9v7Px5Br8K1dHR6Z3H3KkO+sJNm2C3MzcaiVxWl P X-Google-Smtp-Source: AGHT+IHFQvrcfeuCLEUD73/40GJvHgDRigVOTDPc1EhyOkcVqoA5CWE4l9Z2yKZ7p41Xx02fsnHMHw== X-Received: by 2002:a05:6a20:5043:b0:1a3:572b:d4e3 with SMTP id o3-20020a056a20504300b001a3572bd4e3mr9407774pza.27.1711459574510; Tue, 26 Mar 2024 06:26:14 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: thuth@redhat.com, alistair.francis@wdc.com, groug@kaod.org, peter.maydell@linaro.org, qemu_oss@crudebyte.com, Daniel Henrique Barboza Subject: [PATCH for-9.0 1/3] qtest/virtio-9p-test.c: consolidate create dir, file and symlink tests Date: Tue, 26 Mar 2024 10:26:04 -0300 Message-ID: <20240326132606.686025-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326132606.686025-1-dbarboza@ventanamicro.com> References: <20240326132606.686025-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1711459615767100003 Content-Type: text/plain; charset="utf-8" The local 9p driver in virtio-9p-test.c its temporary dir right at the start of qos-test (via virtio_9p_create_local_test_dir()) and only deletes it after qos-test is finished (via virtio_9p_remove_local_test_dir()). This means that any qos-test machine that ends up running virtio-9p-test lo= cal tests more than once will end up re-using the same temp dir. This is what's happening in [1] after we introduced the riscv machine nodes: if we enable slow tests with the '-m slow' flag using qemu-system-riscv64, this is what happens: - a temp dir is created, e.g. qtest-9p-local-WZLDL2; - virtio-9p-device tests will run virtio-9p-test successfully; - virtio-9p-pci tests will run virtio-9p-test, and fail right at the first slow test at fs_create_dir() because the "01" file was already created by fs_create_dir() test when running with the virtio-9p-device. We can fix it by making every test clean up their changes in the filesystem after they're done. But we don't need every test either: what fs_create_file() does is already exercised in fs_unlinkat_dir(), i.e. a dir is created, verified to be created, and then removed. Fixing fs_create_file() would turn it into fs_unlikat_dir(), so we don't need both. The same theme follows every test in virtio-9p-test.c, where the 'unlikat' variant does the same thing the 'create' does but with some cleaning in the end. Consolide some tests as follows: - fs_create_dir() is removed. fs_unlinkat_dir() is renamed to fs_create_unlinkat_dir(); - fs_create_file() is removed. fs_unlinkat_file() is renamed to fs_create_unlinkat_file(). The "04" dir it uses is now being removed; - fs_symlink_file() is removed. fs_unlinkat_symlink() is renamed to fs_create_unlinkat_symlink(). Both "real_file" and the "06" dir it creates is now being removed. We're still missing the 'hardlink' tests. We'll do it in the next patch since it's less trivial to consolidate than these. [1] https://mail.gnu.org/archive/html/qemu-devel/2024-03/msg05807.html Reported-by: Thomas Huth Signed-off-by: Daniel Henrique Barboza Tested-by: Thomas Huth --- tests/qtest/virtio-9p-test.c | 97 +++++++++++------------------------- 1 file changed, 29 insertions(+), 68 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 65e69491e5..cdbe3e78ea 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -506,26 +506,8 @@ static void fs_readdir_split_512(void *obj, void *data, =20 /* tests using the 9pfs 'local' fs driver */ =20 -static void fs_create_dir(void *obj, void *data, QGuestAllocator *t_alloc) -{ - QVirtio9P *v9p =3D obj; - v9fs_set_allocator(t_alloc); - struct stat st; - g_autofree char *root_path =3D virtio_9p_test_path(""); - g_autofree char *new_dir =3D virtio_9p_test_path("01"); - - g_assert(root_path !=3D NULL); - - tattach({ .client =3D v9p }); - tmkdir({ .client =3D v9p, .atPath =3D "/", .name =3D "01" }); - - /* check if created directory really exists now ... */ - g_assert(stat(new_dir, &st) =3D=3D 0); - /* ... and is actually a directory */ - g_assert((st.st_mode & S_IFMT) =3D=3D S_IFDIR); -} - -static void fs_unlinkat_dir(void *obj, void *data, QGuestAllocator *t_allo= c) +static void fs_create_unlinkat_dir(void *obj, void *data, + QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; v9fs_set_allocator(t_alloc); @@ -551,28 +533,13 @@ static void fs_unlinkat_dir(void *obj, void *data, QG= uestAllocator *t_alloc) g_assert(stat(new_dir, &st) !=3D 0); } =20 -static void fs_create_file(void *obj, void *data, QGuestAllocator *t_alloc) -{ - QVirtio9P *v9p =3D obj; - v9fs_set_allocator(t_alloc); - struct stat st; - g_autofree char *new_file =3D virtio_9p_test_path("03/1st_file"); - - tattach({ .client =3D v9p }); - tmkdir({ .client =3D v9p, .atPath =3D "/", .name =3D "03" }); - tlcreate({ .client =3D v9p, .atPath =3D "03", .name =3D "1st_file" }); - - /* check if created file exists now ... */ - g_assert(stat(new_file, &st) =3D=3D 0); - /* ... and is a regular file */ - g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); -} - -static void fs_unlinkat_file(void *obj, void *data, QGuestAllocator *t_all= oc) +static void fs_create_unlinkat_file(void *obj, void *data, + QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; v9fs_set_allocator(t_alloc); struct stat st; + g_autofree char *new_dir =3D virtio_9p_test_path("04"); g_autofree char *new_file =3D virtio_9p_test_path("04/doa_file"); =20 tattach({ .client =3D v9p }); @@ -587,37 +554,22 @@ static void fs_unlinkat_file(void *obj, void *data, Q= GuestAllocator *t_alloc) tunlinkat({ .client =3D v9p, .atPath =3D "04", .name =3D "doa_file" }); /* file should be gone now */ g_assert(stat(new_file, &st) !=3D 0); -} - -static void fs_symlink_file(void *obj, void *data, QGuestAllocator *t_allo= c) -{ - QVirtio9P *v9p =3D obj; - v9fs_set_allocator(t_alloc); - struct stat st; - g_autofree char *real_file =3D virtio_9p_test_path("05/real_file"); - g_autofree char *symlink_file =3D virtio_9p_test_path("05/symlink_file= "); =20 - tattach({ .client =3D v9p }); - tmkdir({ .client =3D v9p, .atPath =3D "/", .name =3D "05" }); - tlcreate({ .client =3D v9p, .atPath =3D "05", .name =3D "real_file" }); - g_assert(stat(real_file, &st) =3D=3D 0); - g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); - - tsymlink({ - .client =3D v9p, .atPath =3D "05", .name =3D "symlink_file", - .symtgt =3D "real_file" + /* also cleanup dir*/ + tunlinkat({ + .client =3D v9p, .atPath =3D "/", .name =3D "04", + .flags =3D P9_DOTL_AT_REMOVEDIR }); - - /* check if created link exists now */ - g_assert(stat(symlink_file, &st) =3D=3D 0); + g_assert(stat(new_dir, &st) !=3D 0); } =20 -static void fs_unlinkat_symlink(void *obj, void *data, - QGuestAllocator *t_alloc) +static void fs_create_unlinkat_symlink(void *obj, void *data, + QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; v9fs_set_allocator(t_alloc); struct stat st; + g_autofree char *new_dir =3D virtio_9p_test_path("06"); g_autofree char *real_file =3D virtio_9p_test_path("06/real_file"); g_autofree char *symlink_file =3D virtio_9p_test_path("06/symlink_file= "); =20 @@ -636,6 +588,16 @@ static void fs_unlinkat_symlink(void *obj, void *data, tunlinkat({ .client =3D v9p, .atPath =3D "06", .name =3D "symlink_file= " }); /* symlink should be gone now */ g_assert(stat(symlink_file, &st) !=3D 0); + + /* remove real file and dir */ + tunlinkat({ .client =3D v9p, .atPath =3D "06", .name =3D "real_file" }= ); + g_assert(stat(real_file, &st) !=3D 0); + + tunlinkat({ + .client =3D v9p, .atPath =3D "/", .name =3D "06", + .flags =3D P9_DOTL_AT_REMOVEDIR + }); + g_assert(stat(new_dir, &st) !=3D 0); } =20 static void fs_hardlink_file(void *obj, void *data, QGuestAllocator *t_all= oc) @@ -746,13 +708,12 @@ static void register_virtio_9p_test(void) =20 opts.before =3D assign_9p_local_driver; qos_add_test("local/config", "virtio-9p", pci_config, &opts); - qos_add_test("local/create_dir", "virtio-9p", fs_create_dir, &opts); - qos_add_test("local/unlinkat_dir", "virtio-9p", fs_unlinkat_dir, &opts= ); - qos_add_test("local/create_file", "virtio-9p", fs_create_file, &opts); - qos_add_test("local/unlinkat_file", "virtio-9p", fs_unlinkat_file, &op= ts); - qos_add_test("local/symlink_file", "virtio-9p", fs_symlink_file, &opts= ); - qos_add_test("local/unlinkat_symlink", "virtio-9p", fs_unlinkat_symlin= k, - &opts); + qos_add_test("local/create_unlinkat_dir", "virtio-9p", + fs_create_unlinkat_dir, &opts); + qos_add_test("local/create_unlinkat_file", "virtio-9p", + fs_create_unlinkat_file, &opts); + qos_add_test("local/create_unlinkat_symlink", "virtio-9p", + fs_create_unlinkat_symlink, &opts); qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &op= ts); qos_add_test("local/unlinkat_hardlink", "virtio-9p", fs_unlinkat_hardl= ink, &opts); --=20 2.44.0 From nobody Wed May 15 09:28:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1711459616; cv=none; d=zohomail.com; s=zohoarc; b=lBDGOjWKDAC2pyh6QABSlSU26gy1iLZAKjAFcvxeBxtNudbfSWuBM+/XLubOx3TvnXhXGzF03dRkkqCEuU8LzjXg90REzJe9o5C/Bw/dFKX+Xd1wpObA3rMB6KkhOq+3I19BlIV5EKXhNxjdw9TkZvyfdBx7KvaxBzZord1HYOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711459616; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zU4PLNWr9Y5kmuUeI681/wzuHnnzvhor10cjhySqMEU=; b=XTcNMR46QkLSlWZ5kfngeAyAF6l2NmxXsl31dZKFzvP85Pi3aiF1XCJkKRJbiim2GLWzWTwAQZGnBSxylbSC7NsLXRz2QY8EmfzXSK1Bmu+MviqvpmxMrvWVGAPfT9faQ03P8kBfPLObhQ4HNJq77kn4rxkLhGvcizhf/85VFkI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711459616169532.1964068285288; Tue, 26 Mar 2024 06:26:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp6oy-0006ri-C1; Tue, 26 Mar 2024 09:26:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rp6ou-0006oB-1g for qemu-devel@nongnu.org; Tue, 26 Mar 2024 09:26:28 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp6op-0002X5-Ou for qemu-devel@nongnu.org; Tue, 26 Mar 2024 09:26:27 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6e74bd85f26so4353580b3a.1 for ; Tue, 26 Mar 2024 06:26:19 -0700 (PDT) Received: from grind.. ([177.45.186.241]) by smtp.gmail.com with ESMTPSA id v10-20020aa799ca000000b006e9afb31e4bsm6080236pfi.12.2024.03.26.06.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 06:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1711459577; x=1712064377; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zU4PLNWr9Y5kmuUeI681/wzuHnnzvhor10cjhySqMEU=; b=dJN8Uk2SBHlskefWYNd92zTys0ht3YxKBlSNw5xL4FTs1/bGDlisf/uIgWSkTtdQP2 usjx3oSX5K4FDkPM3iat29/DQzUHa89xLDJcTei1x8vrg8RTD6raet/Ryow6TBi2Tw/Q 4kHXsBI2oj2rXZuT2LO+1kMVDCj/D3q8gr0bqZZsANbRk7PUeGD6sHGUJnvBb1z1yCQ2 D3BV0yIvs4/V2G1NgWhOJXzGi9bxrLRU40UuaHf0PYtZDL65mMt4aN1iRmqbaEEQNOee e63Ltx9rvhJ3GEf2xyCaMdtKDlE1KTVLNJ7WQemKgW/nC0JUJMmOlvXI/LBR1fDCpxX0 tBvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711459577; x=1712064377; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zU4PLNWr9Y5kmuUeI681/wzuHnnzvhor10cjhySqMEU=; b=luHUb8r98mn7wpLdodxviVHpP1rC7yYcmJswTSNzkP4Gl20so3WuH1QIUJ4kReh7N1 ISJtFSvrhtZtI2UfgnoJjQrieZfzQdDdHRhctt6PPw10v6lBBe7kKafmcnBt9bogHuDJ FnS5L+yroaIUUXzAEZst7IuLoFk58f5Bcd1GcLTazkRXh0GmdtEkdkabeQ7rqGYCcTpH xozkEl7Shh+y/J7AMdOvKCJI5B8SMBt1Y3ofWJutp6XRuSghjVKYMCciiki5E7xfjGYW 0v+j9l7M45gYOEgRJT3FNJPE1zldHss3ZTz1dmGtxLdGR9jZnUr69cF2YExoWMKMSf3H paQQ== X-Gm-Message-State: AOJu0YycUV+kObhjImwzjrccyeZeXZXzfRbxdrQhlxGPcxjqsdBXlPoH IoyhNO51RH4xPfcQb89GbaVrWRT32EvHJLLiHQMtHDoOOYhC3hMrEQRFPqw2oeI+UAyEBNtuMOA t X-Google-Smtp-Source: AGHT+IFWZg07qfccz89Fgv6W+C13Ck3eMW9Ms3d25xlda22VX0Sdy1SorRO5CgwDcgI/WQ+2S8Jtdg== X-Received: by 2002:a05:6a20:aa83:b0:1a3:ac30:100b with SMTP id ck3-20020a056a20aa8300b001a3ac30100bmr7391677pzb.62.1711459577218; Tue, 26 Mar 2024 06:26:17 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: thuth@redhat.com, alistair.francis@wdc.com, groug@kaod.org, peter.maydell@linaro.org, qemu_oss@crudebyte.com, Daniel Henrique Barboza Subject: [PATCH for-9.0 2/3] qtest/virtio-9p-test.c: consolidate hardlink tests Date: Tue, 26 Mar 2024 10:26:05 -0300 Message-ID: <20240326132606.686025-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326132606.686025-1-dbarboza@ventanamicro.com> References: <20240326132606.686025-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1711459617778100007 Content-Type: text/plain; charset="utf-8" We need all virtio-9p-test.c tests to clean themselves up after being executed to avoid an issue where multiple test runs of this same test will find remains of the previous run. See [1] to see the side effects of that. Previous patch dealt with most tests in this file. We're now consolidating the 'hardlink' tests: - copy the asserts that checks if the created link is a hard link from fs_hardlink_file() to fs_unlinkat_hardlink(). This will make fs_unlinkat_hardlink() do exactly what fs_hardlink_file() is doing; - remove fs_hardlink_file(); - fs_unlinkat_hardlink() is renamed to fs_create_unlinkat_hardlink(). We'll also remove 'real_file' and the '08' dir it creates. With this last change all local 9p tests of the file are not leaving files or dirs behind in the temporary dir, allowing multiple runs in the same session to succeed. [1] https://mail.gnu.org/archive/html/qemu-devel/2024-03/msg05807.html Reported-by: Thomas Huth Signed-off-by: Daniel Henrique Barboza Tested-by: Thomas Huth --- tests/qtest/virtio-9p-test.c | 55 +++++++++++++++--------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index cdbe3e78ea..9938516fe7 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -600,39 +600,13 @@ static void fs_create_unlinkat_symlink(void *obj, voi= d *data, g_assert(stat(new_dir, &st) !=3D 0); } =20 -static void fs_hardlink_file(void *obj, void *data, QGuestAllocator *t_all= oc) +static void fs_create_unlinkat_hardlink(void *obj, void *data, + QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; v9fs_set_allocator(t_alloc); - struct stat st_real, st_link; - g_autofree char *real_file =3D virtio_9p_test_path("07/real_file"); - g_autofree char *hardlink_file =3D virtio_9p_test_path("07/hardlink_fi= le"); - - tattach({ .client =3D v9p }); - tmkdir({ .client =3D v9p, .atPath =3D "/", .name =3D "07" }); - tlcreate({ .client =3D v9p, .atPath =3D "07", .name =3D "real_file" }); - g_assert(stat(real_file, &st_real) =3D=3D 0); - g_assert((st_real.st_mode & S_IFMT) =3D=3D S_IFREG); - - tlink({ - .client =3D v9p, .atPath =3D "07", .name =3D "hardlink_file", - .toPath =3D "07/real_file" - }); - - /* check if link exists now ... */ - g_assert(stat(hardlink_file, &st_link) =3D=3D 0); - /* ... and it's a hard link, right? */ - g_assert((st_link.st_mode & S_IFMT) =3D=3D S_IFREG); - g_assert(st_link.st_dev =3D=3D st_real.st_dev); - g_assert(st_link.st_ino =3D=3D st_real.st_ino); -} - -static void fs_unlinkat_hardlink(void *obj, void *data, - QGuestAllocator *t_alloc) -{ - QVirtio9P *v9p =3D obj; - v9fs_set_allocator(t_alloc); - struct stat st_real, st_link; + struct stat st_real, st_link, st; + g_autofree char *new_dir =3D virtio_9p_test_path("08"); g_autofree char *real_file =3D virtio_9p_test_path("08/real_file"); g_autofree char *hardlink_file =3D virtio_9p_test_path("08/hardlink_fi= le"); =20 @@ -646,13 +620,29 @@ static void fs_unlinkat_hardlink(void *obj, void *dat= a, .client =3D v9p, .atPath =3D "08", .name =3D "hardlink_file", .toPath =3D "08/real_file" }); + + /* check if link exists now ... */ g_assert(stat(hardlink_file, &st_link) =3D=3D 0); + /* ... and it's a hard link, right? */ + g_assert((st_link.st_mode & S_IFMT) =3D=3D S_IFREG); + g_assert(st_link.st_dev =3D=3D st_real.st_dev); + g_assert(st_link.st_ino =3D=3D st_real.st_ino); =20 tunlinkat({ .client =3D v9p, .atPath =3D "08", .name =3D "hardlink_fil= e" }); /* symlink should be gone now */ g_assert(stat(hardlink_file, &st_link) !=3D 0); /* and old file should still exist */ g_assert(stat(real_file, &st_real) =3D=3D 0); + + /* cleanup: remove old file and dir */ + tunlinkat({ .client =3D v9p, .atPath =3D "08", .name =3D "real_file" }= ); + g_assert(stat(real_file, &st_real) !=3D 0); + + tunlinkat({ + .client =3D v9p, .atPath =3D "/", .name =3D "08", + .flags =3D P9_DOTL_AT_REMOVEDIR + }); + g_assert(stat(new_dir, &st) !=3D 0); } =20 static void *assign_9p_local_driver(GString *cmd_line, void *arg) @@ -714,9 +704,8 @@ static void register_virtio_9p_test(void) fs_create_unlinkat_file, &opts); qos_add_test("local/create_unlinkat_symlink", "virtio-9p", fs_create_unlinkat_symlink, &opts); - qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &op= ts); - qos_add_test("local/unlinkat_hardlink", "virtio-9p", fs_unlinkat_hardl= ink, - &opts); + qos_add_test("local/create_unlinkat_hardlink", "virtio-9p", + fs_create_unlinkat_hardlink, &opts); } =20 libqos_init(register_virtio_9p_test); --=20 2.44.0 From nobody Wed May 15 09:28:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1711459634; cv=none; d=zohomail.com; s=zohoarc; b=bTkvhJJDWHkPJsfU3zTlrqTC9CvFnRxzMuVtos1oPCGhZ5lmQlquOZ9vYBzgvsog4Aw0TkgzcyTGUs50N9c/wLwBItHyIC16Ofh34wHlM+4SJ9B8GoKCp8AHzxYg4jbc6q55L4ofGKUggNZk+5/ScSw1ejIwM7XKxzKZgY5kRbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711459634; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/ka9NFSE33sd7QQnfjGucwwKtF99pg+u3ePlh0bct3o=; b=jbUncsRzQsJjiu9NAA440YjDRikkIOSb2l6YYip9uX7KRpey43pRHs2X/wZepX7Ld1bEjA9RUiU4G25wRixC3+dlDIf4kw0zv00KVhbof0DxOExE9E4R0lT6eD3EnooEgo6cAmtRpASzFmnLBu9EQvdOKEe44ZD0ibpUNT8RXD8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711459634963783.4294384954437; Tue, 26 Mar 2024 06:27:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp6p2-00072H-Fn; Tue, 26 Mar 2024 09:26:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rp6ou-0006oT-Lk for qemu-devel@nongnu.org; Tue, 26 Mar 2024 09:26:29 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp6os-0002XJ-3v for qemu-devel@nongnu.org; Tue, 26 Mar 2024 09:26:28 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6e6082eab17so4203546b3a.1 for ; Tue, 26 Mar 2024 06:26:21 -0700 (PDT) Received: from grind.. ([177.45.186.241]) by smtp.gmail.com with ESMTPSA id v10-20020aa799ca000000b006e9afb31e4bsm6080236pfi.12.2024.03.26.06.26.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 06:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1711459580; x=1712064380; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/ka9NFSE33sd7QQnfjGucwwKtF99pg+u3ePlh0bct3o=; b=nsa00xZ9GLKZ9L5lSflrB8ke+VXCwmp/mRVwVDPiLZK2v3yXjRa0+BzV+fISKf4z3N zWs7mCriLx4ew9gZorzceB5TaDhkP4t/JepnvKK5fJBXs0x/RlIhJ4T8/nlqoZJhsw4t V8YgwgB/9OzU4SAVatvE/XkSvDT25b8ZDLeDUrPSTP++k8c9yg+sE9apajlaPVAiCGjG HULQDbqUbIVXRniNIVrHQNeHvAk4rLEk6lU67icAZ8OAMIwUOHih/SUSxkGnAoi5cSug Ezvj+4tTHB7XxEsDzEi3ELmLtk9okB03zlDME50VwCeLpRSEo14BJcUWYiyXmJawTdj5 Zq4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711459580; x=1712064380; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ka9NFSE33sd7QQnfjGucwwKtF99pg+u3ePlh0bct3o=; b=k2+IHqpc6oZIbdS9n1BBnGNg0KSAykVVFbZ4p669Ksmp6e7fv4oI+L+1vZFgL8Vjng pu4yJaPqK4wnP7Z0pjvOH56KPY7TGMcpQhwu0UhxKB670i0W6v6cf/kkXQusCyQJo7H1 b9rPUduW/Bb5JA7lh8QCl36k6jIvxeWKSkd8aP1dugB52P7a+dQ3xCnP/xfcCV34SrQH jVDBZy6QJQhbIM63V19THBoxVdlyoyZldFqqOmaMPXXE2l6WyGQ6mhRyXfTCDCYoebqq C/0W8513MsTV40imYypmIFL8ksZUFn19F76KDoAPZwqZtz9h0gvgJn8rWgITdw9dQfsa V4wA== X-Gm-Message-State: AOJu0Yylvlgr164ZcJFRLZxsZ3BSY/tIylYZOFA7nSnYxY2CyCLin2a2 qm6DCmK9Nw6zq40qLUoi7x4fJ3gmTsOjZbnN59gTWUfW84aMW4XVUBikY28ML3d1ND1q0NJ60rm q X-Google-Smtp-Source: AGHT+IE2HgR9h3t4HmYyKYy19r4QOLfZ0ZPPV7Le0gye8GzUlo7vWfa6ROezPls2iKH7uRDu99dNUQ== X-Received: by 2002:a05:6a00:2394:b0:6e7:1d01:334c with SMTP id f20-20020a056a00239400b006e71d01334cmr2669370pfc.2.1711459579899; Tue, 26 Mar 2024 06:26:19 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: thuth@redhat.com, alistair.francis@wdc.com, groug@kaod.org, peter.maydell@linaro.org, qemu_oss@crudebyte.com, Daniel Henrique Barboza Subject: [PATCH for-9.0 3/3] qtest/virtio-9p-test.c: remove g_test_slow() gate Date: Tue, 26 Mar 2024 10:26:06 -0300 Message-ID: <20240326132606.686025-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326132606.686025-1-dbarboza@ventanamicro.com> References: <20240326132606.686025-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1711459635700100003 Content-Type: text/plain; charset="utf-8" Commit 558f5c42ef gated the local tests with g_test_slow() to skip them in 'make check'. The reported issue back then was this following CI problem: https://lists.nongnu.org/archive/html/qemu-devel/2020-11/msg05510.html This problem ended up being fixed when the recently added risc-v machine nodes faced the same issue [1]. We're now able to run these tests with 'make check' in the CI. This reverts commit 558f5c42efded3e0d0b20a90bce2a9a14580d824. [1] https://mail.gnu.org/archive/html/qemu-devel/2024-03/msg05807.html Signed-off-by: Daniel Henrique Barboza Tested-by: Thomas Huth --- tests/qtest/virtio-9p-test.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 9938516fe7..ff69eb334a 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -687,15 +687,6 @@ static void register_virtio_9p_test(void) =20 =20 /* 9pfs test cases using the 'local' filesystem driver */ - - /* - * XXX: Until we are sure that these tests can run everywhere, - * keep them as "slow" so that they aren't run with "make check". - */ - if (!g_test_slow()) { - return; - } - opts.before =3D assign_9p_local_driver; qos_add_test("local/config", "virtio-9p", pci_config, &opts); qos_add_test("local/create_unlinkat_dir", "virtio-9p", --=20 2.44.0