source: web/old/remctl-2.14/tests/client/large-t.c @ f6f3e91

web
Last change on this file since f6f3e91 was f6f3e91, checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago

Preserve directory hierarchy (not sure what happened to it)

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * Test suite for over-large commands.
3 *
4 * Written by Russ Allbery <rra@stanford.edu>
5 * Copyright 2007, 2009 Board of Trustees, Leland Stanford Jr. University
6 *
7 * See LICENSE for licensing terms.
8 */
9
10#include <config.h>
11#include <portable/system.h>
12
13#include <signal.h>
14#ifdef HAVE_SYS_SELECT_H
15# include <sys/select.h>
16#endif
17#include <sys/time.h>
18#include <sys/uio.h>
19#include <sys/wait.h>
20
21#include <client/remctl.h>
22#include <tests/tap/basic.h>
23#include <tests/tap/kerberos.h>
24#include <tests/tap/remctl.h>
25#include <util/util.h>
26
27
28int
29main(void)
30{
31    char *principal, *config, *path;
32    pid_t remctld;
33    struct remctl *r;
34    struct remctl_output *output;
35    struct iovec command[7];
36
37    if (chdir(getenv("SOURCE")) < 0)
38        bail("can't chdir to SOURCE");
39    principal = kerberos_setup();
40    if (principal == NULL)
41        skip_all("Kerberos tests not configured");
42    plan(6);
43    config = concatpath(getenv("SOURCE"), "data/conf-simple");
44    path = concatpath(getenv("BUILD"), "../server/remctld");
45    remctld = remctld_start(path, principal, config);
46
47    command[0].iov_len = strlen("test");
48    command[0].iov_base = (char *) "test";
49    command[1].iov_len = strlen("noauth");
50    command[1].iov_base = (char *) "noauth";
51    command[2].iov_len = TOKEN_MAX_DATA - 31;
52    command[2].iov_base = xmalloc(command[2].iov_len);
53    memset(command[2].iov_base, 'A', command[2].iov_len);
54    command[3].iov_len = TOKEN_MAX_DATA;
55    command[3].iov_base = xmalloc(command[3].iov_len);
56    memset(command[3].iov_base, 'B', command[3].iov_len);
57    command[4].iov_len = TOKEN_MAX_DATA - 20;
58    command[4].iov_base = xmalloc(command[4].iov_len);
59    memset(command[4].iov_base, 'C', command[4].iov_len);
60    command[5].iov_len = 1;
61    command[5].iov_base = (char *) "D";
62    command[6].iov_len = 0;
63    command[6].iov_base = (char *) "";
64
65    r = remctl_new();
66    ok(r != NULL, "remctl_new");
67    ok(remctl_open(r, "localhost", 14373, principal), "remctl_open");
68    ok(remctl_commandv(r, command, 7), "sending extra large command");
69    output = remctl_output(r);
70    printf("\n");
71    ok(output != NULL, "...and got a response");
72    if (output != NULL) {
73        is_int(REMCTL_OUT_ERROR, output->type, "...with the right type");
74        is_int(ERROR_ACCESS, output->error, "...and the right error");
75    } else {
76        ok(0, "...with the right type");
77        ok(0, "...and the right error");
78    }
79    remctl_close(r);
80
81    remctld_stop(remctld);
82    kerberos_cleanup();
83    return 0;
84}
Note: See TracBrowser for help on using the repository browser.