Beispiel #1
0
/**
 * test_bidi_pipe:
 * @left: (out) (allow-none): used to return one #GIOStream
 * @right: (out) (allow-none): used to return the other #GIOStream
 * @error: used to raise an error
 *
 * Return two #GIOStream<!---->s connected to each other with pipes.
 * The "left" input stream is connected by a unidirectional pipe
 * to the "right" output stream, and vice versa. This can be used
 * as a bidirectional pipe to a child process, for instance.
 *
 * See test_pipe() if you only need a one-way pipe.
 *
 * Returns: %TRUE on success
 */
gboolean
test_bidi_pipe (GIOStream **left,
                GIOStream **right,
                GError    **error)
{
    GInputStream *left_in = NULL;
    GOutputStream *left_out = NULL;
    GInputStream *right_in = NULL;
    GOutputStream *right_out = NULL;
    gboolean ret = FALSE;

    if (!test_pipe (&left_in, &right_out, error))
        goto out;

    if (!test_pipe (&right_in, &left_out, error))
        goto out;

    if (left != NULL)
        *left = test_io_stream_new (left_in, left_out);

    if (right != NULL)
        *right = test_io_stream_new (right_in, right_out);

    ret = TRUE;

out:
    g_clear_object (&left_in);
    g_clear_object (&left_out);
    g_clear_object (&right_in);
    g_clear_object (&right_out);
    return ret;
}
Beispiel #2
0
int main(int argc, char ** argv)
{
	char ch;
	if (argc == 0) {
		test_domain();
		test_localtcp();
		test_pipe();
		test_memcpy();
	} else {
		ch = getopt(argc, argv, "mcsdanr");
		switch(ch) {
			case 'm':
				test_domain();
				test_localtcp();
				test_pipe();
				test_memcpy();
				break;
			case 'd': 
				test_seq_disk(0);
				test_random_disk(0);
				break;
			case 'n':
				test_seq_disk(1);
				test_random_disk(1);
				break;
			case 'a':
				test_domain();
				test_localtcp();
				test_pipe();
				test_memcpy();
				test_seq_disk(1);
				test_random_disk(1);
				break;
			case 'r':
				test_random_write();
				break;
			case 'c':
				printf("connect remote svr\n");
				test_remote();
				break;
			case 's':
				printf("start listen svr\n");
				start_svr();
				break;
			default:
				printf("should add param: -a all\n-d disk\n-n disk no sync");
				printf("\n-m memory\n");
				printf("-c tcp client\n-s tcp server\n");
				break;
		}
	}
	sleep(1);
	return 0;
}
Beispiel #3
0
int		process_command_line(t_parser **parserp, t_env *envs,
				     int *status, char *redir)
{
  pid_t		pid;
  t_parser	*tmp;

  tmp = *parserp;
  if (strcmp(tmp->data, "|") == 0
      && pipe(tmp->command->pipefd) == -1)
    return (-1);
  if (tmp->command->is_builtin == 1)
    return (select_builtin(tmp->command->new_argv, envs, status));
  if ((pid = fork()) == 0)
    {
      if (test_redir(&tmp, redir) == -1 ||
	  test_pipe(tmp, *redir) == -1 ||
	  exec_cmd(tmp, envs) == -1)
	return (-1);
    }
  else if (pid > 0)
    {
      get_only_cmd_custom(parserp);
      (*parserp)->command->pid = pid;
      return (0);
    }
  else
    perror("Fork Error");
  return (0);
}
Beispiel #4
0
int main(void) {
        sd_rtnl *rtnl;
        sd_rtnl_message *m;
        sd_rtnl_message *r;
        char *string_data;
        int if_loopback;
        uint16_t type;

        test_match();

        test_multiple();

        test_route();

        test_container();

        assert_se(sd_rtnl_open(&rtnl, 0) >= 0);
        assert_se(rtnl);

        if_loopback = (int) if_nametoindex("lo");
        assert_se(if_loopback > 0);

        test_async(if_loopback);

        test_pipe(if_loopback);

        test_event_loop(if_loopback);

        test_link_configure(rtnl, if_loopback);

        test_get_addresses(rtnl);

        assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, if_loopback) >= 0);
        assert_se(m);

        assert_se(sd_rtnl_message_get_type(m, &type) >= 0);
        assert_se(type == RTM_GETLINK);

        assert_se(sd_rtnl_message_read_string(m, IFLA_IFNAME, &string_data) == -EPERM);

        assert_se(sd_rtnl_call(rtnl, m, 0, &r) == 1);
        assert_se(sd_rtnl_message_get_type(r, &type) >= 0);
        assert_se(type == RTM_NEWLINK);

        assert_se((r = sd_rtnl_message_unref(r)) == NULL);

        assert_se(sd_rtnl_call(rtnl, m, -1, &r) == -EPERM);
        assert_se((m = sd_rtnl_message_unref(m)) == NULL);
        assert_se((r = sd_rtnl_message_unref(r)) == NULL);

        test_link_get(rtnl, if_loopback);
        test_address_get(rtnl, if_loopback);

        assert_se(sd_rtnl_flush(rtnl) >= 0);
        assert_se((m = sd_rtnl_message_unref(m)) == NULL);
        assert_se((r = sd_rtnl_message_unref(r)) == NULL);
        assert_se((rtnl = sd_rtnl_unref(rtnl)) == NULL);

        return EXIT_SUCCESS;
}
Beispiel #5
0
/* Run tests */
int main()
{
	test_standard();
	test_redirect();
	test_pipe();
//	direct_input();

	return 0;
}
Beispiel #6
0
ATF_TC_BODY(pipe_128k_8k, tc)
{
	/* 
	 * kern/185812 causes this test case to both fail and timeout.  The
	 * atf-c-api(3) doesn't have a way to set such an expectation.
	 * If you use atf_tc_expect_fail, then it will timeout.  If you use
	 * atf_tc_expect_timeout, then it will fail.  If you use both, then it
	 * will show up as an unexpected pass, which is much worse
	 *
	 * https://code.google.com/p/kyua/issues/detail?id=76
	 */
	atf_tc_expect_fail("PR kern/185812 send(2) on a UNIX domain SEQPACKET socket returns EMSGSIZE instead of EAGAIN");
	test_pipe(131072, 8192);
}
Beispiel #7
0
int			ft_apply_cmds(t_op *op)
{
	char	**envp;
	int		cmd;

	cmd = 0;
	envp = env_to_tab();
	while (op)
	{
		if (op->type == 0 || (cmd && op->type == 1) || (!cmd && op->type == 2))
		{
			term_reset();
			if (!test_alone(op->pipe, envp, &cmd))
				test_pipe(op->pipe, envp, &cmd);
			term_initiate();
		}
		op = op->next;
	}
	ft_delfulltab((void ***)&envp);
	return (1);
}
Beispiel #8
0
int
main (int argc, char *argv[])
{
  int test;
  int fd;

  set_program_name (argv[0]);

  if (argc != 3)
    {
      fprintf (stderr, "%s: need 2 arguments\n", argv[0]);
      return 2;
    }
  /* We might close fd 2 later, so save it in fd 10.  */
  if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO
      || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL)
    return 2;

  /* Selectively close various standard fds, to verify the child process is
     not impacted by this.  */
  test = atoi (argv[2]);
  switch (test)
    {
    case 0:
      break;
    case 1:
      close (0);
      break;
    case 2:
      close (1);
      break;
    case 3:
      close (0);
      close (1);
      break;
    case 4:
      close (2);
      break;
    case 5:
      close (0);
      close (2);
      break;
    case 6:
      close (1);
      close (2);
      break;
    case 7:
      close (0);
      close (1);
      close (2);
      break;
    default:
      ASSERT (false);
    }

  /* Plug any file descriptor leaks inherited from outside world before
     starting, so that child has a clean slate (at least for the fds that we
     might be manipulating).  */
  for (fd = 3; fd < 7; fd++)
    close (fd);

  test_pipe (argv[1], test >= 4);

  return 0;
}
Beispiel #9
0
ATF_TC_BODY(pipe_128k_128k, tc)
{
	atf_tc_expect_fail("PR kern/185812 send(2) on a UNIX domain SEQPACKET socket returns EMSGSIZE instead of EAGAIN");
	test_pipe(131072, 131072);
}
Beispiel #10
0
ATF_TC_BODY(pipe_128k_128k, tc)
{
	test_pipe(131072, 131072);
}
Beispiel #11
0
ATF_TC_BODY(pipe_128k_8k, tc)
{
	test_pipe(131072, 8192);
}
Beispiel #12
0
ATF_TC_BODY(pipe_8k_128k, tc)
{
	test_pipe(8192, 131072);
}
Beispiel #13
0
ATF_TC_BODY(pipe_8k_8k, tc)
{
	test_pipe(8192, 8192);
}
Beispiel #14
0
int main(void) {
        sd_rtnl *rtnl;
        sd_rtnl_message *m;
        sd_rtnl_message *r;
        void *data;
        int if_loopback;
        uint16_t type;
        unsigned int mtu = 0;
        unsigned int *mtu_reply;

        test_multiple();

        test_route();

        test_container();

        assert(sd_rtnl_open(0, &rtnl) >= 0);
        assert(rtnl);

        if_loopback = (int) if_nametoindex("lo");
        assert(if_loopback > 0);

        test_async(if_loopback);

        test_pipe(if_loopback);

        test_event_loop(if_loopback);

        test_link_configure(rtnl, if_loopback);

        assert(sd_rtnl_message_link_new(RTM_GETLINK, if_loopback, 0, 0, &m) >= 0);
        assert(m);

        assert(sd_rtnl_message_get_type(m, &type) >= 0);
        assert(type == RTM_GETLINK);

        assert(sd_rtnl_message_read(m, &type, &data) == 0);

        assert(sd_rtnl_call(rtnl, m, 0, &r) == 1);
        assert(sd_rtnl_message_get_type(r, &type) >= 0);
        assert(type == RTM_NEWLINK);

        assert(sd_rtnl_message_read(m, &type, &data) == 0);
        assert((r = sd_rtnl_message_unref(r)) == NULL);

        assert(sd_rtnl_call(rtnl, m, -1, &r) == -EPERM);
        assert((m = sd_rtnl_message_unref(m)) == NULL);
        assert((r = sd_rtnl_message_unref(r)) == NULL);

        assert(sd_rtnl_message_link_new(RTM_GETLINK, if_loopback, 0, 0, &m) >= 0);
        assert(m);

        assert(sd_rtnl_message_append(m, IFLA_MTU, &mtu) >= 0);
        assert(sd_rtnl_message_read(m, &type, (void **) &mtu_reply) == 1);

        assert(type == IFLA_MTU);
        assert(*mtu_reply == 0);

        assert(sd_rtnl_message_read(m, &type, &data) == 0);

        assert(sd_rtnl_call(rtnl, m, -1, &r) == 1);
        while (sd_rtnl_message_read(r, &type, &data) > 0) {
                switch (type) {
//                        case IFLA_MTU:
//                                assert(*(unsigned int *) data == 65536);
//                                break;
//                        case IFLA_QDISC:
//                                assert(streq((char *) data, "noqueue"));
//                                break;
                        case IFLA_IFNAME:
                                assert(streq((char *) data, "lo"));
                                break;
                }
        }

        assert(sd_rtnl_flush(rtnl) >= 0);

        assert((m = sd_rtnl_message_unref(m)) == NULL);
        assert((r = sd_rtnl_message_unref(r)) == NULL);
        assert((rtnl = sd_rtnl_unref(rtnl)) == NULL);

        return EXIT_SUCCESS;
}