/tests/virsystemdtest
/tests/virtimetest
/tests/viruritest
+/tests/vmwarevertest
/tests/vmx2xmltest
/tests/xencapstest
/tests/xmconfigtest
SYM_FILES += $(srcdir)/libvirt_vmx.syms
endif ! WITH_VMX
+if WITH_VMWARE
+USED_SYM_FILES += $(srcdir)/libvirt_vmware.syms
+else ! WITH_VMWARE
+SYM_FILES += $(srcdir)/libvirt_vmware.syms
+endif ! WITH_VMWARE
+
if WITH_XENXS
USED_SYM_FILES += $(srcdir)/libvirt_xenxs.syms
else ! WITH_XENXS
--- /dev/null
+#
+# These symbols are dependent upon --with-vmware via WITH_VMWARE.
+#
+
+# vmware/vmware_conf.h
+vmwareDriverTypeFromString;
+vmwareParseVersionStr;
+
+# Let emacs know we want case-insensitive sorting
+# Local Variables:
+# sort-fold-case: t
+# End:
}
}
+int
+vmwareParseVersionStr(int type, const char *verbuf, unsigned long *version)
+{
+ const char *pattern;
+ const char *tmp;
+
+ switch (type) {
+ case VMWARE_DRIVER_PLAYER:
+ pattern = "VMware Player ";
+ break;
+ case VMWARE_DRIVER_WORKSTATION:
+ pattern = "VMware Workstation ";
+ break;
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid driver type: %d"), type);
+ return -1;
+ }
+
+ if ((tmp = STRSKIP(verbuf, pattern)) == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to parse %sversion"), pattern);
+ return -1;
+ }
+
+ if (virParseVersionString(tmp, version, false) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("version parsing error"));
+ return -1;
+ }
+
+ return 0;
+}
+
int
vmwareExtractVersion(struct vmware_driver *driver)
{
unsigned long version = 0;
- char *tmp;
int ret = -1;
virCommandPtr cmd;
char * outbuf = NULL;
const char * bin = (driver->type == VMWARE_DRIVER_PLAYER) ?
"vmplayer" : "vmware";
- const char * pattern = (driver->type == VMWARE_DRIVER_PLAYER) ?
- "VMware Player " : "VMware Workstation ";
cmd = virCommandNewArgList(bin, "-v", NULL);
virCommandSetOutputBuffer(cmd, &outbuf);
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
- if ((tmp = STRSKIP(outbuf, pattern)) == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("failed to parse %s version"), bin);
+ if (vmwareParseVersionStr(driver->type, outbuf, &version) < 0)
goto cleanup;
- }
-
- if (virParseVersionString(tmp, &version, false) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("version parsing error"));
- goto cleanup;
- }
- driver->version = version;
ret = 0;
cleanup:
int vmwareExtractVersion(struct vmware_driver *driver);
+int vmwareParseVersionStr(int type, const char *buf, unsigned long *version);
+
int vmwareDomainConfigDisplay(vmwareDomainPtr domain, virDomainDefPtr vmdef);
int vmwareParsePath(char *path, char **directory, char **filename);
xmconfigdata \
xml2sexprdata \
xml2vmxdata \
+ vmwareverdata \
.valgrind.supp
test_helpers = commandhelper ssh test_conf
test_programs += vmx2xmltest xml2vmxtest
endif WITH_VMX
+if WITH_VMWARE
+test_programs += vmwarevertest
+endif WITH_VMWARE
+
if WITH_CIL
test_programs += object-locking
endif WITH_CIL
EXTRA_DIST += vmx2xmltest.c xml2vmxtest.c
endif ! WITH_VMX
+if WITH_VMWARE
+vmwarevertest_SOURCES = \
+ vmwarevertest.c \
+ testutils.c testutils.h
+vmwarevertest_LDADD = $(LDADDS)
+else ! WITH_VMWARE
+EXTRA_DIST += vmwarevertest.c
+endif ! WITH_VMWARE
+
networkxml2xmltest_SOURCES = \
networkxml2xmltest.c \
testutils.c testutils.h
--- /dev/null
+VMware Workstation 7.0.0 build-203739 Release
--- /dev/null
+/*
+ * Copyright (c) 2013. Doug Goldstein <cardoe@cardoe.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "testutils.h"
+
+#ifdef WITH_VMWARE
+
+# include <stdio.h>
+# include <stdlib.h>
+
+# include "vmware/vmware_conf.h"
+
+//# define VIR_FROM_THIS VIR_FROM_NONE
+
+struct testInfo {
+ const char *vmware_type;
+ const char *name;
+ unsigned long version;
+};
+
+static int
+testVerStrParse(const void *data)
+{
+ const struct testInfo *info = data;
+ int ret = -1;
+ char *path = NULL;
+ char *databuf = NULL;
+ unsigned long version;
+ int vmware_type;
+
+ if (virAsprintf(&path, "%s/vmwareverdata/%s.txt", abs_srcdir,
+ info->name) < 0)
+ return -1;
+
+ if (virtTestLoadFile(path, &databuf) < 0)
+ goto cleanup;
+
+ if ((vmware_type = vmwareDriverTypeFromString(info->vmware_type)) < 0)
+ goto cleanup;
+
+ if (vmwareParseVersionStr(vmware_type, databuf, &version) < 0)
+ goto cleanup;
+
+ if (version != info->version) {
+ fprintf(stderr, "%s: parsed versions do not match: got %lu, "
+ "expected %lu\n", info->name, version, info->version);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(path);
+ VIR_FREE(databuf);
+ return ret;
+}
+
+static int
+mymain(void)
+{
+ int ret = 0;
+
+# define DO_TEST(vmware_type, name, version) \
+ do { \
+ struct testInfo info = { \
+ vmware_type, name, version \
+ }; \
+ if (virtTestRun("VMware Version String Parsing " name, \
+ 1, testVerStrParse, &info) < 0) \
+ ret = -1; \
+ } while (0)
+
+ DO_TEST("ws", "workstation-7.0.0", 7000000);
+
+ return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+VIRT_TEST_MAIN(mymain)
+
+#else
+
+int
+main(void)
+{
+ return EXIT_AM_SKIP;
+}
+
+#endif /* WITH_VMWARE */