testutils: Remove unused virTestClearCommandPath

virCommand(ToString) now provides the functionality internally so we
don't have to keep the string-munging function around.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2021-04-06 11:24:47 +02:00
parent cf32c7d8c0
commit 3b0e264aa8
2 changed files with 0 additions and 53 deletions

View File

@ -854,57 +854,6 @@ int virTestMain(int argc,
}
/*
* @cmdset contains a list of command line args, eg
*
* "/usr/sbin/iptables --table filter --insert INPUT --in-interface virbr0 --protocol tcp --destination-port 53 --jump ACCEPT
* /usr/sbin/iptables --table filter --insert INPUT --in-interface virbr0 --protocol udp --destination-port 53 --jump ACCEPT
* /usr/sbin/iptables --table filter --insert FORWARD --in-interface virbr0 --jump REJECT
* /usr/sbin/iptables --table filter --insert FORWARD --out-interface virbr0 --jump REJECT
* /usr/sbin/iptables --table filter --insert FORWARD --in-interface virbr0 --out-interface virbr0 --jump ACCEPT"
*
* And we're munging it in-place to strip the path component
* of the command line, to produce
*
* "iptables --table filter --insert INPUT --in-interface virbr0 --protocol tcp --destination-port 53 --jump ACCEPT
* iptables --table filter --insert INPUT --in-interface virbr0 --protocol udp --destination-port 53 --jump ACCEPT
* iptables --table filter --insert FORWARD --in-interface virbr0 --jump REJECT
* iptables --table filter --insert FORWARD --out-interface virbr0 --jump REJECT
* iptables --table filter --insert FORWARD --in-interface virbr0 --out-interface virbr0 --jump ACCEPT"
*/
void virTestClearCommandPath(char *cmdset)
{
size_t offset = 0;
char *lineStart = cmdset;
char *lineEnd = strchr(lineStart, '\n');
while (lineStart) {
char *dirsep;
char *movestart;
size_t movelen;
dirsep = strchr(lineStart, ' ');
if (dirsep) {
while (dirsep > lineStart && *dirsep != '/')
dirsep--;
if (*dirsep == '/')
dirsep++;
movestart = dirsep;
} else {
movestart = lineStart;
}
movelen = lineEnd ? lineEnd - movestart : strlen(movestart);
if (movelen) {
memmove(cmdset + offset, movestart, movelen + 1);
offset += movelen + 1;
}
lineStart = lineEnd ? lineEnd + 1 : NULL;
lineEnd = lineStart ? strchr(lineStart, '\n') : NULL;
}
cmdset[offset] = '\0';
}
virCapsPtr virTestGenericCapsInit(void)
{
g_autoptr(virCaps) caps = NULL;

View File

@ -46,8 +46,6 @@ char *virTestLoadFilePath(const char *p, ...)
virJSONValuePtr virTestLoadFileJSON(const char *p, ...)
G_GNUC_NULL_TERMINATED;
void virTestClearCommandPath(char *cmdset);
int virTestDifference(FILE *stream,
const char *expect,
const char *actual);