1 Star 0 Fork 71

jokenzhang/src-libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
virbuftest-Increase-coverage.patch 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
Jiangjiacheng 提交于 2023-01-04 12:02 . Backport patches from upstream
From 23f96f11539b13cee88563d8c670036b4868787b Mon Sep 17 00:00:00 2001
From: liumengqiu <liumengqiu1@huawei.com>
Date: Wed, 24 Aug 2022 16:22:15 +0800
Subject: [PATCH 11/13] virbuftest: Increase coverage
Test the behavior of virBufferEscapeShell for different types of
quotes as well as the empty string.
Signed-off-by: Andrea Bolognani abologna@redhat.com
Reviewed-by: Michal Privoznik mprivozn@redhat.com
Signed-off-by: liumengqiu <liumengqiu1@huawei.com>
---
tests/virbuftest.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
index f9d19ff1a1..26e344feab 100644
--- a/tests/virbuftest.c
+++ b/tests/virbuftest.c
@@ -20,7 +20,8 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
virBuffer bufinit = VIR_BUFFER_INITIALIZER;
virBufferPtr buf = &bufinit;
const char expected[] =
- " 1\n 2\n 3\n 4\n 5\n 6\n 7\n &amp;\n 8\n 9\n 10\n ' 11'\n";
+ " 1\n 2\n 3\n 4\n 5\n 6\n 7\n &amp;\n 8\n 9\n 10\n"
+ " ' 11'\n ''\\''12'\n '\"13'\n ''\n";
g_autofree char *result = NULL;
int ret = 0;
@@ -85,6 +86,12 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
virBufferAddChar(buf, '\n');
virBufferEscapeShell(buf, " 11");
virBufferAddChar(buf, '\n');
+ virBufferEscapeShell(buf, "'12");
+ virBufferAddChar(buf, '\n');
+ virBufferEscapeShell(buf, "\"13");
+ virBufferAddChar(buf, '\n');
+ virBufferEscapeShell(buf, "");
+ virBufferAddChar(buf, '\n');
result = virBufferContentAndReset(buf);
if (!result || STRNEQ(result, expected)) {
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/omnihorizon/src-libvirt.git
git@gitee.com:omnihorizon/src-libvirt.git
omnihorizon
src-libvirt
src-libvirt
master

搜索帮助