Tree @debian/5.1.0-1 (Download .tar.gz)
- ..
- bhyveargv2xmldata
- bhyvexml2argvdata
- bhyvexml2xmloutdata
- capabilityschemadata
- commanddata
- cputestdata
- domaincapsschemadata
- domainconfdata
- domainschemadata
- domainsnapshotxml2xmlin
- domainsnapshotxml2xmlout
- fchostdata
- genericxml2xmlindata
- genericxml2xmloutdata
- interfaceschemadata
- libxlxml2domconfigdata
- lxcconf2xmldata
- lxcxml2xmldata
- lxcxml2xmloutdata
- networkxml2confdata
- networkxml2firewalldata
- networkxml2xmlin
- networkxml2xmlout
- networkxml2xmlupdatein
- networkxml2xmlupdateout
- nodedevschemadata
- nssdata
- nwfilterxml2firewalldata
- nwfilterxml2xmlin
- nwfilterxml2xmlout
- qemuagentdata
- qemuargv2xmldata
- qemublocktestdata
- qemucapabilitiesdata
- qemucaps2xmloutdata
- qemuhotplugtestcpus
- qemuhotplugtestdevices
- qemuhotplugtestdomains
- qemumemlockdata
- qemumigparamsdata
- qemumonitorjsondata
- qemustatusxml2xmldata
- qemuxml2argvdata
- qemuxml2xmloutdata
- secretxml2xmlin
- securityselinuxhelperdata
- securityselinuxlabeldata
- sexpr2xmldata
- storagepoolschemadata
- storagepoolxml2argvdata
- storagepoolxml2xmlin
- storagepoolxml2xmlout
- storagevolschemadata
- storagevolxml2argvdata
- storagevolxml2xmlin
- storagevolxml2xmlout
- sysinfodata
- vboxsnapshotxmldata
- vircaps2xmldata
- vircgroupdata
- virconfdata
- virfilecachedata
- virfiledata
- virhostcpudata
- virjsondata
- virmacmaptestdata
- virnetdaemondata
- virnetdevtestdata
- virnwfilterbindingxml2xmldata
- virpcitestdata
- virresctrldata
- virscsidata
- virstorageutildata
- virusbtestdata
- vmwareverdata
- vmx2xmldata
- xlconfigdata
- xmconfigdata
- xml2sexprdata
- xml2vmxdata
- .valgrind.supp
- bhyveargv2xmlmock.c
- bhyveargv2xmltest.c
- bhyvexml2argvmock.c
- bhyvexml2argvtest.c
- bhyvexml2xmltest.c
- check-file-access.pl
- commandhelper.c
- commandtest.c
- cputest.c
- domaincapsmock.c
- domaincapstest.c
- domainconftest.c
- domainsnapshotxml2xmltest.c
- esxutilstest.c
- eventtest.c
- fchosttest.c
- fdstreamtest.c
- file_access_whitelist.txt
- genericxml2xmltest.c
- interfacexml2xmltest.c
- libvirtd-fail
- libvirtd-pool
- libxlmock.c
- libxlxml2domconfigtest.c
- lxcconf2xmltest.c
- lxcxml2xmltest.c
- Makefile.am
- Makefile.in
- metadatatest.c
- networkxml2conftest.c
- networkxml2firewalltest.c
- networkxml2xmltest.c
- networkxml2xmlupdatetest.c
- nodedevxml2xmltest.c
- nsslinktest.c
- nssmock.c
- nsstest.c
- nwfilterebiptablestest.c
- nwfilterxml2firewalltest.c
- nwfilterxml2xmltest.c
- objecteventtest.c
- objectlocking.ml
- oomtrace.pl
- openvzutilstest.c
- openvzutilstest.conf
- pkix_asn1_tab.c
- qemuagenttest.c
- qemuargv2xmltest.c
- qemublocktest.c
- qemucapabilitiestest.c
- qemucaps2xmlmock.c
- qemucaps2xmltest.c
- qemucapsprobe.c
- qemucapsprobemock.c
- qemucommandutiltest.c
- qemucpumock.c
- qemuhotplugtest.c
- qemumemlocktest.c
- qemumigparamstest.c
- qemumonitorjsontest.c
- qemumonitortestutils.c
- qemumonitortestutils.h
- qemusecuritymock.c
- qemusecuritytest.c
- qemusecuritytest.h
- qemuxml2argvmock.c
- qemuxml2argvtest.c
- qemuxml2xmltest.c
- scsihosttest.c
- seclabeltest.c
- secretxml2xmltest.c
- securityselinuxhelper.c
- securityselinuxlabeltest.c
- securityselinuxtest.c
- sexpr2xmltest.c
- shunloadhelper.c
- shunloadtest.c
- sockettest.c
- ssh.c
- storagebackendsheepdogtest.c
- storagepoolxml2argvtest.c
- storagepoolxml2xmltest.c
- storagevolxml2argvtest.c
- storagevolxml2xmltest.c
- sysinfotest.c
- test-lib.sh
- testutils.c
- testutils.h
- testutilshostcpus.h
- testutilslxc.c
- testutilslxc.h
- testutilsqemu.c
- testutilsqemu.h
- testutilsqemuschema.c
- testutilsqemuschema.h
- testutilsxen.c
- testutilsxen.h
- utiltest.c
- vboxsnapshotxmltest.c
- viralloctest.c
- viratomictest.c
- virauthconfigtest.c
- virbitmaptest.c
- virbuftest.c
- vircaps2xmltest.c
- vircapstest.c
- vircgroupmock.c
- vircgrouptest.c
- virconftest.c
- vircryptotest.c
- virdbusmock.c
- virdbustest.c
- virdeterministichashmock.c
- virdrivermoduletest.c
- virendiantest.c
- virerrortest.c
- virfilecachemock.c
- virfilecachetest.c
- virfilemock.c
- virfiletest.c
- virfilewrapper.c
- virfilewrapper.h
- virfirewalltest.c
- virhashdata.h
- virhashtest.c
- virhostcpumock.c
- virhostcputest.c
- virhostdevtest.c
- viridentitytest.c
- viriscsitest.c
- virjsontest.c
- virkeycodetest.c
- virkeyfiletest.c
- virkmodtest.c
- virlockspacetest.c
- virlogtest.c
- virmacmaptest.c
- virmock.h
- virnetdaemonmock.c
- virnetdaemontest.c
- virnetdevbandwidthmock.c
- virnetdevbandwidthtest.c
- virnetdevmock.c
- virnetdevtest.c
- virnetmessagetest.c
- virnetserverclientmock.c
- virnetserverclienttest.c
- virnetsockettest.c
- virnettlscontexttest.c
- virnettlshelpers.c
- virnettlshelpers.h
- virnettlssessiontest.c
- virnumamock.c
- virnwfilterbindingxml2xmltest.c
- virpcimock.c
- virpcitest.c
- virpolkittest.c
- virportallocatormock.c
- virportallocatortest.c
- virrandommock.c
- virresctrltest.c
- virrotatingfiletest.c
- virschematest.c
- virscsitest.c
- virsh-cpuset
- virsh-define-dev-segfault
- virsh-int-overflow
- virsh-optparse
- virsh-read-bufsiz
- virsh-read-non-seekable
- virsh-schedinfo
- virsh-self-test
- virsh-start
- virsh-undefine
- virsh-uriprecedence
- virsh-vcpupin
- virshtest.c
- virstoragetest.c
- virstorageutiltest.c
- virstringtest.c
- virsystemdtest.c
- virt-aa-helper-test
- virt-admin-self-test
- virtestmock.c
- virtimetest.c
- virtypedparamtest.c
- viruritest.c
- virusbmock.c
- virusbtest.c
- vmwarevertest.c
- vmx2xmltest.c
- vshtabletest.c
- xlconfigtest.c
- xmconfigtest.c
- xml2sexprtest.c
- xml2vmxtest.c
storagebackendsheepdogtest.c @debian/5.1.0-1 — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | /* * storagebackendsheepdogtest.c: storage backend for Sheepdog handling * * Copyright (C) 2014 Red Hat, Inc. * Copyright (C) 2012 Sebastian Wiedenroth * * 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 <unistd.h> #include <fcntl.h> #include "internal.h" #include "testutils.h" #define LIBVIRT_STORAGE_BACKEND_SHEEPDOG_PRIV_H_ALLOW #include "storage/storage_backend_sheepdog_priv.h" #include "virstring.h" #define VIR_FROM_THIS VIR_FROM_NONE typedef struct { const char *output; int expected_return; uint64_t expected_capacity; uint64_t expected_allocation; } collie_test; struct testNodeInfoParserData { collie_test data; const char *poolxml; }; struct testVDIListParserData { collie_test data; const char *poolxml; const char *volxml; }; static int test_node_info_parser(const void *opaque) { const struct testNodeInfoParserData *data = opaque; collie_test test = data->data; VIR_AUTOFREE(char *) output = NULL; VIR_AUTOPTR(virStoragePoolDef) pool = NULL; if (!(pool = virStoragePoolDefParseFile(data->poolxml))) return -1; if (VIR_STRDUP(output, test.output) < 0) return -1; if (virStorageBackendSheepdogParseNodeInfo(pool, output) != test.expected_return) return -1; if (test.expected_return) return 0; if (pool->capacity == test.expected_capacity && pool->allocation == test.expected_allocation) return 0; return -1; } static int test_vdi_list_parser(const void *opaque) { const struct testVDIListParserData *data = opaque; collie_test test = data->data; VIR_AUTOFREE(char *) output = NULL; VIR_AUTOPTR(virStoragePoolDef) pool = NULL; VIR_AUTOPTR(virStorageVolDef) vol = NULL; if (!(pool = virStoragePoolDefParseFile(data->poolxml))) return -1; if (!(vol = virStorageVolDefParseFile(pool, data->volxml, 0))) return -1; if (VIR_STRDUP(output, test.output) < 0) return -1; if (virStorageBackendSheepdogParseVdiList(vol, output) != test.expected_return) return -1; if (test.expected_return) return 0; if (vol->target.capacity == test.expected_capacity && vol->target.allocation == test.expected_allocation) return 0; return -1; } static int mymain(void) { int ret = 0; VIR_AUTOFREE(char *) poolxml = NULL; VIR_AUTOFREE(char *) volxml = NULL; collie_test node_info_tests[] = { {"", -1, 0, 0}, {"Total 15245667872 117571104 0% 20972341\n", 0, 15245667872, 117571104}, {"To", -1, 0, 0}, {"asdf\nasdf", -1, 0, 0}, {"Total ", -1, 0, 0}, {"Total 1", -1, 0, 0}, {"Total 1\n", -1, 0, 0}, {"Total 1 ", -1, 0, 0}, {"Total 1 2", -1, 0, 0}, {"Total 1 2 ", -1, 0, 0}, {"Total 1 2\n", 0, 1, 2}, {"Total 1 2 \n", 0, 1, 2}, {"Total a 2 \n", -1, 0, 0}, {"Total 1 b \n", -1, 0, 0}, {"Total a b \n", -1, 0, 0}, {"stuff\nTotal 1 2 \n", 0, 1, 2}, {"0 1 2 3\nTotal 1 2 \n", 0, 1, 2}, {NULL, 0, 0, 0} }; collie_test vdi_list_tests[] = { {"", -1, 0, 0}, {"= test 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20}, {"= test\\ with\\ spaces 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20}, {"= backslashattheend\\\\ 3 10 20 0 1336557216 7c2b27\n", 0, 10, 20}, {"s test 1 10 20 0 1336556634 7c2b25\n= test 3 50 60 0 1336557216 7c2b27\n", 0, 50, 60}, {"=", -1, 0, 0}, {"= test", -1, 0, 0}, {"= test ", -1, 0, 0}, {"= test 1", -1, 0, 0}, {"= test 1 ", -1, 0, 0}, {"= test 1 2", -1, 0, 0}, {"= test 1 2 ", -1, 0, 0}, {"= test 1 2 3", -1, 0, 0}, {NULL, 0, 0, 0} }; collie_test *test = node_info_tests; if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/pool-sheepdog.xml", abs_srcdir) < 0) goto cleanup; if (virAsprintf(&volxml, "%s/storagevolxml2xmlin/vol-sheepdog.xml", abs_srcdir) < 0) goto cleanup; #define DO_TEST_NODE(collie) \ do { \ struct testNodeInfoParserData data = { \ .data = collie, \ .poolxml = poolxml, \ }; \ if (virTestRun("node_info_parser", test_node_info_parser, \ &data) < 0) \ ret = -1; \ } while (0) while (test->output != NULL) { DO_TEST_NODE(*test); ++test; } #define DO_TEST_VDI(collie) \ do { \ struct testVDIListParserData data = { \ .data = collie, \ .poolxml = poolxml, \ .volxml = volxml, \ }; \ if (virTestRun("vdi_list_parser", test_vdi_list_parser, \ &data) < 0) \ ret = -1; \ } while (0) test = vdi_list_tests; while (test->output != NULL) { DO_TEST_VDI(*test); ++test; } cleanup: return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } VIR_TEST_MAIN(mymain) |