7a3408
From eddb74776301338b7066555076740689bb69e950 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <eddb74776301338b7066555076740689bb69e950@dist-git>
7a3408
From: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
7a3408
Date: Wed, 5 Aug 2015 18:18:36 +0200
7a3408
Subject: [PATCH] tests: Prepare for subcore tests
7a3408
7a3408
The nodeGetThreadsPerSubcore() function is mocked to return 8 for
7a3408
ppc64 tests, which corresponds to the default subcore mode.
7a3408
7a3408
Update the expected output for the deconfigured-cpus nodeinfo
7a3408
test to account for this change.
7a3408
7a3408
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
7a3408
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7a3408
(cherry picked from commit 3020f550cad1f928f6e98308453d00cd68fa0d86)
7a3408
7a3408
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1213713
7a3408
7a3408
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 tests/Makefile.am                                  |  6 ++++
7a3408
 .../nodeinfodata/linux-ppc64-deconf-cpus.expected  |  2 +-
7a3408
 tests/nodeinfomock.c                               | 35 ++++++++++++++++++++++
7a3408
 tests/nodeinfotest.c                               |  2 +-
7a3408
 4 files changed, 43 insertions(+), 2 deletions(-)
7a3408
 create mode 100644 tests/nodeinfomock.c
7a3408
7a3408
diff --git a/tests/Makefile.am b/tests/Makefile.am
7a3408
index b202195..bde7f5b 100644
7a3408
--- a/tests/Makefile.am
7a3408
+++ b/tests/Makefile.am
7a3408
@@ -412,6 +412,7 @@ test_libraries = libshunload.la \
7a3408
 		vircgroupmock.la \
7a3408
 		virpcimock.la \
7a3408
 		virnetdevmock.la \
7a3408
+		nodeinfomock.la \
7a3408
 		$(NULL)
7a3408
 if WITH_QEMU
7a3408
 test_libraries += libqemumonitortestutils.la \
7a3408
@@ -1048,6 +1049,11 @@ virpcimock_la_LIBADD = $(GNULIB_LIBS) \
7a3408
 					   ../src/libvirt.la
7a3408
 virpcimock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
7a3408
 
7a3408
+nodeinfomock_la_SOURCES = \
7a3408
+	nodeinfomock.c
7a3408
+nodeinfomock_la_CFLAGS = $(AM_CFLAGS)
7a3408
+nodeinfomock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
7a3408
+
7a3408
 virnetdevtest_SOURCES = \
7a3408
 	virnetdevtest.c testutils.h testutils.c
7a3408
 virnetdevtest_CFLAGS = $(AM_CFLAGS) $(LIBNL_CFLAGS)
7a3408
diff --git a/tests/nodeinfodata/linux-ppc64-deconf-cpus.expected b/tests/nodeinfodata/linux-ppc64-deconf-cpus.expected
7a3408
index 304f423..113bfa8 100644
7a3408
--- a/tests/nodeinfodata/linux-ppc64-deconf-cpus.expected
7a3408
+++ b/tests/nodeinfodata/linux-ppc64-deconf-cpus.expected
7a3408
@@ -1 +1 @@
7a3408
-CPUs: 10/80, MHz: 3690, Nodes: 1, Sockets: 1, Cores: 80, Threads: 1
7a3408
+CPUs: 80/80, MHz: 3690, Nodes: 1, Sockets: 1, Cores: 80, Threads: 1
7a3408
diff --git a/tests/nodeinfomock.c b/tests/nodeinfomock.c
7a3408
new file mode 100644
7a3408
index 0000000..b9c0152
7a3408
--- /dev/null
7a3408
+++ b/tests/nodeinfomock.c
7a3408
@@ -0,0 +1,35 @@
7a3408
+/*
7a3408
+ * Copyright (C) 2015 Red Hat, Inc.
7a3408
+ *
7a3408
+ * This library is free software; you can redistribute it and/or
7a3408
+ * modify it under the terms of the GNU Lesser General Public
7a3408
+ * License as published by the Free Software Foundation; either
7a3408
+ * version 2.1 of the License, or (at your option) any later version.
7a3408
+ *
7a3408
+ * This library is distributed in the hope that it will be useful,
7a3408
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7a3408
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
7a3408
+ * Lesser General Public License for more details.
7a3408
+ *
7a3408
+ * You should have received a copy of the GNU Lesser General Public
7a3408
+ * License along with this library.  If not, see
7a3408
+ * <http://www.gnu.org/licenses/>.
7a3408
+ *
7a3408
+ */
7a3408
+
7a3408
+#include <config.h>
7a3408
+
7a3408
+#include "internal.h"
7a3408
+#include "nodeinfo.h"
7a3408
+
7a3408
+int
7a3408
+nodeGetThreadsPerSubcore(virArch arch)
7a3408
+{
7a3408
+    int threads_per_subcore = 0;
7a3408
+
7a3408
+    // Emulate SMT=8 on POWER hardware
7a3408
+    if (ARCH_IS_PPC64(arch))
7a3408
+        threads_per_subcore = 8;
7a3408
+
7a3408
+    return threads_per_subcore;
7a3408
+}
7a3408
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
7a3408
index 3fffdb2..ccef4a9 100644
7a3408
--- a/tests/nodeinfotest.c
7a3408
+++ b/tests/nodeinfotest.c
7a3408
@@ -256,6 +256,6 @@ mymain(void)
7a3408
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
7a3408
 }
7a3408
 
7a3408
-VIRT_TEST_MAIN(mymain)
7a3408
+VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/nodeinfomock.so")
7a3408
 
7a3408
 #endif /* __linux__ */
7a3408
-- 
7a3408
2.5.0
7a3408