The following commit has been merged in the master branch:
commit 7e26acd008d38f6d56c26e6a595430636ea40211
Author: Guillem Jover <[email protected]>
Date: Sat Sep 17 05:07:13 2011 +0200
libdpkg: Add missing test cases for the command and varbuf modules
diff --git a/lib/dpkg/test/t-command.c b/lib/dpkg/test/t-command.c
index a1b543c..6cbd7f8 100644
--- a/lib/dpkg/test/t-command.c
+++ b/lib/dpkg/test/t-command.c
@@ -2,7 +2,7 @@
* libdpkg - Debian packaging suite library routines
* t-command.c - test command implementation
*
- * Copyright © 2010 Guillem Jover <[email protected]>
+ * Copyright © 2010-2011 Guillem Jover <[email protected]>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -153,6 +153,25 @@ test_command_exec(void)
}
static void
+test_command_shell(void)
+{
+ pid_t pid;
+ int ret;
+
+ pid = subproc_fork();
+ if (pid == 0)
+ command_shell("true", "command shell pass test");
+ ret = subproc_wait_check(pid, "command shell pass test", 0);
+ test_pass(ret == 0);
+
+ pid = subproc_fork();
+ if (pid == 0)
+ command_shell("false", "command shell fail test");
+ ret = subproc_wait_check(pid, "command shell fail test", PROCNOERR);
+ test_fail(ret == 0);
+}
+
+static void
test(void)
{
test_command_init();
@@ -160,4 +179,5 @@ test(void)
test_command_add_argl();
test_command_add_args();
test_command_exec();
+ test_command_shell();
}
diff --git a/lib/dpkg/test/t-varbuf.c b/lib/dpkg/test/t-varbuf.c
index 0eb22bd..6ae5d37 100644
--- a/lib/dpkg/test/t-varbuf.c
+++ b/lib/dpkg/test/t-varbuf.c
@@ -200,6 +200,29 @@ test_varbuf_map_char(void)
}
static void
+test_varbuf_end_str(void)
+{
+ struct varbuf vb;
+
+ varbuf_init(&vb, 10);
+
+ varbuf_add_buf(&vb, "1234567890X", 11);
+ test_pass(vb.used == 11);
+ test_pass(vb.size >= vb.used);
+ test_mem(vb.buf, ==, "1234567890X", 11);
+
+ varbuf_trunc(&vb, 10);
+
+ varbuf_end_str(&vb);
+ test_pass(vb.used == 10);
+ test_pass(vb.size >= vb.used + 1);
+ test_pass(vb.buf[10] == '\0');
+ test_str(vb.buf, ==, "1234567890");
+
+ varbuf_destroy(&vb);
+}
+
+static void
test_varbuf_printf(void)
{
struct varbuf vb;
@@ -276,6 +299,7 @@ test(void)
test_varbuf_add_char();
test_varbuf_dup_char();
test_varbuf_map_char();
+ test_varbuf_end_str();
test_varbuf_printf();
test_varbuf_reset();
test_varbuf_detach();
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]