Просмотр исходного кода

libdpkg: Add test case for command_exec

Guillem Jover лет назад: 16
Родитель
Сommit
4cb6ae5d9e
1 измененных файлов с 21 добавлено и 0 удалено
  1. 21 0
      lib/dpkg/test/t-command.c

+ 21 - 0
lib/dpkg/test/t-command.c

@@ -22,6 +22,7 @@
 #include <compat.h>
 
 #include <dpkg/test.h>
+#include <dpkg/subproc.h>
 #include <dpkg/command.h>
 
 static void
@@ -132,6 +133,25 @@ test_command_add_args(void)
 	command_destroy(&cmd);
 }
 
+static void
+test_command_exec(void)
+{
+	struct command cmd;
+	pid_t pid;
+
+	command_init(&cmd, "/bin/true", "exec test");
+
+	command_add_arg(&cmd, "arg 0");
+	command_add_arg(&cmd, "arg 1");
+
+	pid = subproc_fork();
+
+	if (pid == 0)
+		command_exec(&cmd);
+
+	subproc_wait_check(pid, "command exec test", 0);
+}
+
 static void
 test(void)
 {
@@ -139,5 +159,6 @@ test(void)
 	test_command_add_arg();
 	test_command_add_argl();
 	test_command_add_args();
+	test_command_exec();
 }