2 * Copyright (c) 2013. Doug Goldstein <cardoe@cardoe.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see
16 * <http://www.gnu.org/licenses/>.
21 #include "testutils.h"
26 # include "vmware/vmware_conf.h"
28 //# define VIR_FROM_THIS VIR_FROM_NONE
31 const char *vmware_type
;
33 unsigned long version
;
37 testVerStrParse(const void *data
)
39 const struct testInfo
*info
= data
;
40 g_autofree
char *path
= NULL
;
41 g_autofree
char *databuf
= NULL
;
42 unsigned long version
;
45 path
= g_strdup_printf("%s/vmwareverdata/%s.txt", abs_srcdir
, info
->name
);
47 if (virTestLoadFile(path
, &databuf
) < 0)
50 if ((vmware_type
= vmwareDriverTypeFromString(info
->vmware_type
)) < 0)
53 if (vmwareParseVersionStr(vmware_type
, databuf
, &version
) < 0)
56 if (version
!= info
->version
) {
57 fprintf(stderr
, "%s: parsed versions do not match: got %lu, "
58 "expected %lu\n", info
->name
, version
, info
->version
);
70 # define DO_TEST(vmware_type, name, version) \
72 struct testInfo info = { \
73 vmware_type, name, version \
75 if (virTestRun("VMware Version String Parsing " name, \
76 testVerStrParse, &info) < 0) \
80 DO_TEST("ws", "workstation-7.0.0", 7000000);
81 DO_TEST("ws", "workstation-7.0.0-with-garbage", 7000000);
82 DO_TEST("fusion", "fusion-5.0.3", 5000003);
84 return ret
== 0 ? EXIT_SUCCESS
: EXIT_FAILURE
;
97 #endif /* WITH_VMWARE */