From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi0ex-0003ji-VN for qemu-devel@nongnu.org; Fri, 02 Oct 2015 09:46:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi0eu-0000tS-PB for qemu-devel@nongnu.org; Fri, 02 Oct 2015 09:46:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi0eu-0000tN-Kt for qemu-devel@nongnu.org; Fri, 02 Oct 2015 09:46:00 -0400 Date: Fri, 2 Oct 2015 16:45:55 +0300 From: "Michael S. Tsirkin" Message-ID: <1443793405-15190-15-git-send-email-mst@redhat.com> References: <1443793405-15190-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1443793405-15190-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 14/15] vhost-user-test: use tmpfs by default List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Yuanhan Liu , Paolo Bonzini , =?us-ascii?B?PT9VVEYtOD9xP01hcmMtQW5kcj1DMz1BOT0yMEx1cmVhdT89?= Most people don't run make check by default, so they skip vhost-user unit tests. Solve this by using tmpfs instead, unless hugetlbfs is specified (using an environment variable). Signed-off-by: Michael S. Tsirkin Reviewed-by: Marc-Andr=E9 Lureau --- tests/vhost-user-test.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 87281b9..5e63cbc 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -272,17 +272,11 @@ static void chr_read(void *opaque, const uint8_t *b= uf, int size) g_mutex_unlock(&data_mutex); } =20 -static const char *init_hugepagefs(void) +static const char *init_hugepagefs(const char *path) { - const char *path; struct statfs fs; int ret; =20 - path =3D getenv("QTEST_HUGETLBFS_PATH"); - if (!path) { - path =3D "/hugetlbfs"; - } - if (access(path, R_OK | W_OK | X_OK)) { g_test_message("access on path (%s): %s\n", path, strerror(errno= )); return NULL; @@ -309,19 +303,31 @@ int main(int argc, char **argv) { QTestState *s =3D NULL; CharDriverState *chr =3D NULL; - const char *hugefs =3D 0; + const char *hugefs; char *socket_path =3D 0; char *qemu_cmd =3D 0; char *chr_path =3D 0; int ret; + char template[] =3D "/tmp/vhost-test-XXXXXX"; + const char *tmpfs; + const char *root; =20 g_test_init(&argc, &argv, NULL); =20 module_call_init(MODULE_INIT_QOM); =20 - hugefs =3D init_hugepagefs(); - if (!hugefs) { - return 0; + tmpfs =3D mkdtemp(template); + if (!tmpfs) { + g_test_message("mkdtemp on path (%s): %s\n", template, strerro= r(errno)); + } + g_assert(tmpfs); + + hugefs =3D getenv("QTEST_HUGETLBFS_PATH"); + if (hugefs) { + root =3D init_hugepagefs(hugefs); + g_assert(root); + } else { + root =3D tmpfs; } =20 socket_path =3D g_strdup_printf("/tmp/vhost-%d.sock", getpid()); @@ -338,7 +344,7 @@ int main(int argc, char **argv) g_cond_init(&data_cond); g_thread_new(NULL, thread_function, NULL); =20 - qemu_cmd =3D g_strdup_printf(QEMU_CMD, hugefs, socket_path); + qemu_cmd =3D g_strdup_printf(QEMU_CMD, root, socket_path); s =3D qtest_start(qemu_cmd); g_free(qemu_cmd); =20 @@ -354,5 +360,12 @@ int main(int argc, char **argv) unlink(socket_path); g_free(socket_path); =20 + ret =3D rmdir(tmpfs); + if (ret !=3D 0) { + g_test_message("unable to rmdir: path (%s): %s\n", + tmpfs, strerror(errno)); + } + g_assert_cmpint(ret, =3D=3D, 0); + return ret; } --=20 MST