実験

実験 — 実験的なAPI

概要

#define             cut_user_data
#define             cut_fork                            ()
#define             cut_wait_process                    (pid, usec_timeout)
#define             cut_fork_get_stdout_message         (pid)
#define             cut_fork_get_stderr_message         (pid)

説明

将来、このAPIは変更されるかもしれません。

詳細

cut_user_data

#define             cut_user_data

cutterコマンドのようなテスト起動コマンドを独自に作ったときにだけ役にたちます。独自のテスト起動コマンドからテストプログラムにデータを渡すことができます。テストプログラムはこのマクロを使ってデータを受け取ることができます。

戻り値 :

テストを実行したプログラムからのデータ。

cut_fork()

#define             cut_fork()

子プロセスを生成します。

例:

int pid;
pid = cut_fork();
cut_assert_errno();

if (pid == 0) {
  do_something_for_child_process();
  _exit(EXIT_SUCCESS);
}

do_something_for_parent_process();

戻り値 :

プロセスID。

0.8から


cut_wait_process()

#define             cut_wait_process(pid, usec_timeout)

pidで指定されたプロセスの終了を待ちます。

例:

int pid;
pid = cut_fork();
cut_assert_errno();

if (pid == 0) {
  do_something_for_child_process();
  _exit(EXIT_SUCCESS);
}

do_something_for_parent_process();
cut_assert_equal_int(EXIT_SUCCESS, cut_wait_process(pid, 100));

pid :

終了を待つプロセスのID。

usec_timeout :

タイムアウトする時間。100万分の1秒単位で指定。

0.8から


cut_fork_get_stdout_message()

#define             cut_fork_get_stdout_message(pid)

pidで指定されたプロセスからメッセージを読みます。

例:

int pid;
pid = cut_fork();
cut_assert_errno();

if (pid == 0) {
  g_print("I'm a child.");
  _exit(EXIT_SUCCESS);
}

cut_assert_equal_string("I'm a child.", cut_fork_get_stdout_message(pid));
cut_assert_equal_int(EXIT_SUCCESS, cut_wait_process(pid, 100));

pid :

プロセスID。

0.8から


cut_fork_get_stderr_message()

#define             cut_fork_get_stderr_message(pid)

pidで指定されたプロセスからメッセージを読みます。

例:

int pid;
pid = cut_fork();
cut_assert_errno();

if (pid == 0) {
  g_print("I'm a child.");
  _exit(EXIT_SUCCESS);
}

cut_assert_equal_string("I'm a child.", cut_fork_get_stderr_message(pid));
cut_assert_equal_int(EXIT_SUCCESS, cut_wait_process(pid, 100));

pid :

プロセスID。

0.8から