source: tester.c @ 03fbf66

Last change on this file since 03fbf66 was 03fbf66, checked in by Jason Gross <jasongross9@gmail.com>, 7 years ago
Moved the last of the logging-related variables to perl We seem to have picked logpath as the string variable we test in tester.c. Since this is no longer in C, I've replaced it with personalbell (no particular reason for that choice).
  • Property mode set to 100644
File size: 36.9 KB
Line 
1#define OWL_PERL
2#define WINDOW FAKE_WINDOW
3#include "owl.h"
4#undef WINDOW
5#include "filterproc.h"
6
7#include <stdio.h>
8
9#undef instr
10#include <ncursesw/curses.h>
11
12owl_global g;
13
14int numtests;
15
16int owl_regtest(void);
17int owl_util_regtest(void);
18int owl_dict_regtest(void);
19int owl_variable_regtest(void);
20int owl_filter_regtest(void);
21int owl_obarray_regtest(void);
22int owl_editwin_regtest(void);
23int owl_fmtext_regtest(void);
24int owl_smartfilter_regtest(void);
25int owl_history_regtest(void);
26int call_filter_regtest(void);
27int owl_smartstrip_regtest(void);
28
29extern void owl_perl_xs_init(pTHX);
30
31int main(int argc, char **argv, char **env)
32{
33  FILE *rnull;
34  FILE *wnull;
35  char *perlerr;
36  int status = 0;
37  SCREEN *screen;
38
39  if (argc <= 1) {
40    fprintf(stderr, "Usage: %s --builtin|TEST.t|-le CODE\n", argv[0]);
41    return 1;
42  }
43
44  /* initialize a fake ncurses, detached from std{in,out} */
45  wnull = fopen("/dev/null", "w");
46  rnull = fopen("/dev/null", "r");
47  screen = newterm("xterm", wnull, rnull);
48  /* initialize global structures */
49  owl_global_init(&g);
50
51  perlerr = owl_perlconfig_initperl(NULL, &argc, &argv, &env);
52  if (perlerr) {
53    endwin();
54    fprintf(stderr, "Internal perl error: %s\n", perlerr);
55    status = 1;
56    goto out;
57  }
58
59  owl_global_complete_setup(&g);
60  owl_global_setup_default_filters(&g);
61
62  owl_view_create(owl_global_get_current_view(&g), "main",
63                  owl_global_get_filter(&g, "all"),
64                  owl_global_get_style_by_name(&g, "default"));
65
66  owl_function_firstmsg();
67
68  ENTER;
69  SAVETMPS;
70
71  if (strcmp(argv[1], "--builtin") == 0) {
72    status = owl_regtest();
73  } else if (strcmp(argv[1], "-le") == 0 && argc > 2) {
74    /*
75     * 'prove' runs its harness perl with '-le CODE' to get some
76     * information out.
77     */
78    moreswitches("l");
79    eval_pv(argv[2], true);
80  } else {
81    sv_setpv(get_sv("0", false), argv[1]);
82    sv_setpv(get_sv("main::test_prog", TRUE), argv[1]);
83
84    eval_pv("do $main::test_prog; die($@) if($@)", true);
85  }
86
87  status = 0;
88
89  FREETMPS;
90  LEAVE;
91
92 out:
93  perl_destruct(owl_global_get_perlinterp(&g));
94  perl_free(owl_global_get_perlinterp(&g));
95  /* probably not necessary, but tear down the screen */
96  endwin();
97  delscreen(screen);
98  fclose(rnull);
99  fclose(wnull);
100  return status;
101}
102
103int owl_regtest(void) {
104  numtests = 0;
105  int numfailures=0;
106  /*
107    printf("1..%d\n", OWL_UTIL_NTESTS+OWL_DICT_NTESTS+OWL_VARIABLE_NTESTS
108    +OWL_FILTER_NTESTS+OWL_OBARRAY_NTESTS);
109  */
110  numfailures += owl_util_regtest();
111  numfailures += owl_dict_regtest();
112  numfailures += owl_variable_regtest();
113  numfailures += owl_filter_regtest();
114  numfailures += owl_editwin_regtest();
115  numfailures += owl_fmtext_regtest();
116  numfailures += owl_smartfilter_regtest();
117  numfailures += owl_history_regtest();
118  numfailures += call_filter_regtest();
119  numfailures += owl_smartstrip_regtest();
120  if (numfailures) {
121      fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
122  }
123  printf("1..%d\n", numtests);
124
125  return(numfailures);
126}
127
128#define FAIL_UNLESS(desc,pred) do { int __pred = (pred);                \
129    numtests++;                                                         \
130    printf("%s %d %s", (__pred) ? "ok" : (numfailed++, "not ok"), numtests, desc); \
131    if(!(__pred)) printf("\t(%s:%d)", __FILE__, __LINE__); printf("%c", '\n'); } while(0)
132
133
134int owl_util_regtest(void)
135{
136  int numfailed=0;
137  char *path, *home;
138
139  printf("# BEGIN testing owl_util\n");
140
141#define CHECK_STR_AND_FREE(desc, expected, expr)         \
142    do {                                                 \
143      char *__value = (expr);                            \
144      FAIL_UNLESS((desc), !strcmp((expected), __value)); \
145      g_free(__value);                                 \
146    } while (0)
147
148  CHECK_STR_AND_FREE("owl_text_substitute 2", "fYZYZ",
149                     owl_text_substitute("foo", "o", "YZ"));
150  CHECK_STR_AND_FREE("owl_text_substitute 3", "foo",
151                     owl_text_substitute("fYZYZ", "YZ", "o"));
152  CHECK_STR_AND_FREE("owl_text_substitute 4", "/u/foo/meep",
153                     owl_text_substitute("~/meep", "~", "/u/foo"));
154
155  FAIL_UNLESS("skiptokens 1", 
156              !strcmp("bar quux", skiptokens("foo bar quux", 1)));
157  FAIL_UNLESS("skiptokens 2", 
158              !strcmp("meep", skiptokens("foo 'bar quux' meep", 2)));
159
160  CHECK_STR_AND_FREE("expand_tabs 1", "        hi", owl_text_expand_tabs("\thi"));
161
162  CHECK_STR_AND_FREE("expand_tabs 2", "        hi\nword    tab",
163                     owl_text_expand_tabs("\thi\nword\ttab"));
164
165  CHECK_STR_AND_FREE("expand_tabs 3", "                2 tabs",
166                     owl_text_expand_tabs("\t\t2 tabs"));
167  CHECK_STR_AND_FREE("expand_tabs 4", "α       ααααααα!        ",
168                     owl_text_expand_tabs(\tααααααα!\t"));
169  CHECK_STR_AND_FREE("expand_tabs 5", "A      AAA!!        ",
170                     owl_text_expand_tabs("A\tAAA!!\t"));
171
172  FAIL_UNLESS("skiptokens 1",
173              !strcmp("world", skiptokens("hello world", 1)));
174
175  FAIL_UNLESS("skiptokens 2",
176              !strcmp("c d e", skiptokens("a   b c d e", 2)));
177
178  FAIL_UNLESS("skiptokens 3",
179              !strcmp("\"b\" c d e", skiptokens("a \"b\" c d e", 1)));
180
181  FAIL_UNLESS("skiptokens 4",
182              !strcmp("c d e", skiptokens("a \"b\" c d e", 2)));
183
184  FAIL_UNLESS("skiptokens 5",
185              !strcmp("c d e", skiptokens("a \"'\" c d e", 2)));
186
187#define CHECK_QUOTING(desc, unquoted, quoted)           \
188  do {                                                  \
189      int __argc;                                       \
190      char *__quoted = owl_arg_quote(unquoted);         \
191      char **__argv;                                    \
192      FAIL_UNLESS(desc, !strcmp(quoted, __quoted));     \
193      __argv = owl_parseline(__quoted, &__argc);        \
194      FAIL_UNLESS(desc " - arg count", __argc == 1);    \
195      FAIL_UNLESS(desc " - null-terminated",            \
196                  __argv[__argc] == NULL);              \
197      FAIL_UNLESS(desc " - parsed",                     \
198                  !strcmp(__argv[0], unquoted));        \
199      g_strfreev(__argv);                               \
200      g_free(__quoted);                         \
201    } while (0)
202
203  CHECK_QUOTING("boring text", "mango", "mango");
204  CHECK_QUOTING("spaces", "mangos are tasty", "'mangos are tasty'");
205  CHECK_QUOTING("single quotes", "mango's", "\"mango's\"");
206  CHECK_QUOTING("double quotes", "he said \"mangos are tasty\"",
207                "'he said \"mangos are tasty\"'");
208  CHECK_QUOTING("both quotes",
209                "he said \"mango's are tasty even when you put in "
210                "a random apostrophe\"",
211                "\"he said \"'\"'\"mango's are tasty even when you put in "
212                "a random apostrophe\"'\"'\"\"");
213  CHECK_QUOTING("quote monster", "'\"\"'\"'''\"",
214                "\""
215                "'"
216                "\"'\"'\""
217                "\"'\"'\""
218                "'"
219                "\"'\"'\""
220                "'"
221                "'"
222                "'"
223                "\"'\"'\""
224                "\"");
225
226  GString *quoted = g_string_new("");
227  owl_string_appendf_quoted(quoted, "%q foo %q%q %s %", "hello", "world is", "can't");
228  FAIL_UNLESS("owl_string_appendf",
229              !strcmp(quoted->str, "hello foo 'world is'\"can't\" %s %"));
230  g_string_free(quoted, true);
231
232
233  CHECK_STR_AND_FREE("baseclass barnowl",
234                     "barnowl", owl_util_baseclass("barnowl"));
235  CHECK_STR_AND_FREE("baseclass unbarnowl",
236                     "barnowl", owl_util_baseclass("unbarnowl"));
237  CHECK_STR_AND_FREE("baseclass unununbarnowl.d.d",
238                     "barnowl", owl_util_baseclass("unununbarnowl.d.d"));
239  CHECK_STR_AND_FREE("baseclass ununun.d.d",
240                     "", owl_util_baseclass("ununun.d.d"));
241  CHECK_STR_AND_FREE("baseclass d.d.d.d",
242                     "d", owl_util_baseclass("d.d.d.d"));
243  CHECK_STR_AND_FREE("baseclass n.d.d.d",
244                     "n", owl_util_baseclass("n.d.d.d"));
245  CHECK_STR_AND_FREE("baseclass ununun.",
246                     ".", owl_util_baseclass("ununun."));
247  CHECK_STR_AND_FREE("baseclass unununu",
248                     "u", owl_util_baseclass("unununu"));
249
250
251  CHECK_STR_AND_FREE("makepath foo/bar",
252                     "foo/bar", owl_util_makepath("foo/bar"));
253  CHECK_STR_AND_FREE("makepath //foo///bar",
254                     "/foo/bar", owl_util_makepath("//foo///bar"));
255  CHECK_STR_AND_FREE("makepath foo/~//bar/",
256                     "foo/~/bar/", owl_util_makepath("foo/~//bar/"));
257  CHECK_STR_AND_FREE("makepath ~thisuserhadreallybetternotexist/foobar/",
258                     "~thisuserhadreallybetternotexist/foobar/",
259                     owl_util_makepath("~thisuserhadreallybetternotexist/foobar/"));
260
261  home = g_strdup(owl_global_get_homedir(&g));
262  CHECK_STR_AND_FREE("makepath ~",
263                     home, owl_util_makepath("~"));
264
265  path = g_build_filename(home, "foo/bar/baz", NULL);
266  CHECK_STR_AND_FREE("makepath ~///foo/bar//baz",
267                     path, owl_util_makepath("~///foo/bar//baz"));
268  g_free(path);
269  g_free(home);
270
271  home = owl_util_homedir_for_user("root");
272  if (home == NULL) {
273    /* Just make some noise so we notice. */
274    home = g_strdup("<WHAT>");
275    fprintf(stderr, "owl_util_homedir_for_user failed");
276  }
277
278  CHECK_STR_AND_FREE("makepath ~root",
279                     home, owl_util_makepath("~root"));
280
281  path = g_build_filename(home, "foo/bar/baz", NULL);
282  CHECK_STR_AND_FREE("makepath ~root///foo/bar//baz",
283                     path, owl_util_makepath("~root///foo/bar//baz"));
284  g_free(path);
285  g_free(home);
286
287  /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */
288  printf("# END testing owl_util (%d failures)\n", numfailed);
289  return(numfailed);
290}
291
292int owl_dict_regtest(void) {
293  owl_dict d;
294  GPtrArray *l;
295  int numfailed=0;
296  char *av = g_strdup("aval"), *bv = g_strdup("bval"), *cv = g_strdup("cval"),
297    *dv = g_strdup("dval");
298
299  printf("# BEGIN testing owl_dict\n");
300  owl_dict_create(&d);
301  FAIL_UNLESS("insert b", 0==owl_dict_insert_element(&d, "b", bv, owl_dict_noop_delete));
302  FAIL_UNLESS("insert d", 0==owl_dict_insert_element(&d, "d", dv, owl_dict_noop_delete));
303  FAIL_UNLESS("insert a", 0==owl_dict_insert_element(&d, "a", av, owl_dict_noop_delete));
304  FAIL_UNLESS("insert c", 0==owl_dict_insert_element(&d, "c", cv, owl_dict_noop_delete));
305  FAIL_UNLESS("reinsert d (no replace)", -2==owl_dict_insert_element(&d, "d", dv, 0));
306  FAIL_UNLESS("find a", av==owl_dict_find_element(&d, "a"));
307  FAIL_UNLESS("find b", bv==owl_dict_find_element(&d, "b"));
308  FAIL_UNLESS("find c", cv==owl_dict_find_element(&d, "c"));
309  FAIL_UNLESS("find d", dv==owl_dict_find_element(&d, "d"));
310  FAIL_UNLESS("find e (non-existent)", NULL==owl_dict_find_element(&d, "e"));
311  FAIL_UNLESS("remove d", dv==owl_dict_remove_element(&d, "d"));
312  FAIL_UNLESS("find d (post-removal)", NULL==owl_dict_find_element(&d, "d"));
313
314  FAIL_UNLESS("get_size", 3==owl_dict_get_size(&d));
315  l = owl_dict_get_keys(&d);
316  FAIL_UNLESS("get_keys result size", 3 == l->len);
317 
318  /* these assume the returned keys are sorted */
319  FAIL_UNLESS("get_keys result val", 0 == strcmp("a", l->pdata[0]));
320  FAIL_UNLESS("get_keys result val", 0 == strcmp("b", l->pdata[1]));
321  FAIL_UNLESS("get_keys result val", 0 == strcmp("c", l->pdata[2]));
322
323  owl_ptr_array_free(l, g_free);
324  owl_dict_cleanup(&d, NULL);
325
326  g_free(av);
327  g_free(bv);
328  g_free(cv);
329  g_free(dv);
330
331  /*  if (numfailed) printf("*** WARNING: failures encountered with owl_dict\n"); */
332  printf("# END testing owl_dict (%d failures)\n", numfailed);
333  return(numfailed);
334}
335
336int owl_variable_regtest(void) {
337  owl_vardict vd;
338  owl_variable *var;
339  int numfailed=0;
340  char *value;
341
342  printf("# BEGIN testing owl_variable\n");
343  owl_variable_dict_setup(&vd);
344
345  FAIL_UNLESS("get bool var", NULL != (var = owl_variable_get_var(&vd, "rxping")));
346  FAIL_UNLESS("get bool", 0 == owl_variable_get_bool(var));
347  FAIL_UNLESS("get bool (no such)", NULL == owl_variable_get_var(&vd, "mumble"));
348  FAIL_UNLESS("get bool as string",
349              !strcmp((value = owl_variable_get_tostring(var)), "off"));
350  g_free(value);
351  FAIL_UNLESS("set bool 1", 0 == owl_variable_set_bool_on(var));
352  FAIL_UNLESS("get bool 2", 1 == owl_variable_get_bool(var));
353  FAIL_UNLESS("set bool 3", 0 == owl_variable_set_fromstring(var, "off", 0));
354  FAIL_UNLESS("get bool 4", 0 == owl_variable_get_bool(var));
355  FAIL_UNLESS("set bool 5", -1 == owl_variable_set_fromstring(var, "xxx", 0));
356  FAIL_UNLESS("get bool 6", 0 == owl_variable_get_bool(var));
357
358
359  FAIL_UNLESS("get string var", NULL != (var = owl_variable_get_var(&vd, "personalbell")));
360  FAIL_UNLESS("get string", 0 == strcmp("off", owl_variable_get_string(var)));
361  FAIL_UNLESS("set string 7", 0 == owl_variable_set_string(var, "whee"));
362  FAIL_UNLESS("get string", !strcmp("whee", owl_variable_get_string(var)));
363
364  FAIL_UNLESS("get int var", NULL != (var = owl_variable_get_var(&vd, "typewinsize")));
365  FAIL_UNLESS("get int", 8 == owl_variable_get_int(var));
366  FAIL_UNLESS("get int (no such)", NULL == owl_variable_get_var(&vd, "mumble"));
367  FAIL_UNLESS("get int as string",
368              !strcmp((value = owl_variable_get_tostring(var)), "8"));
369  g_free(value);
370  FAIL_UNLESS("set int 1", 0 == owl_variable_set_int(var, 12));
371  FAIL_UNLESS("get int 2", 12 == owl_variable_get_int(var));
372  FAIL_UNLESS("set int 1b", -1 == owl_variable_set_int(var, -3));
373  FAIL_UNLESS("get int 2b", 12 == owl_variable_get_int(var));
374  FAIL_UNLESS("set int 3", 0 == owl_variable_set_fromstring(var, "9", 0));
375  FAIL_UNLESS("get int 4", 9 == owl_variable_get_int(var));
376  FAIL_UNLESS("set int 5", -1 == owl_variable_set_fromstring(var, "xxx", 0));
377  FAIL_UNLESS("set int 6", -1 == owl_variable_set_fromstring(var, "", 0));
378  FAIL_UNLESS("get int 7", 9 == owl_variable_get_int(var));
379
380  FAIL_UNLESS("get enum var", NULL != (var = owl_variable_get_var(&vd, "scrollmode")));
381  FAIL_UNLESS("get enum", OWL_SCROLLMODE_NORMAL == owl_variable_get_int(var));
382  FAIL_UNLESS("get enum as string",
383              !strcmp((value = owl_variable_get_tostring(var)), "normal"));
384  g_free(value);
385  FAIL_UNLESS("set enum 1", 0 == owl_variable_set_int(var, OWL_SCROLLMODE_TOP));
386  FAIL_UNLESS("get enum 1", OWL_SCROLLMODE_TOP == owl_variable_get_int(var));
387  FAIL_UNLESS("set enum 2a", -1 == owl_variable_set_int(var, -1));
388  FAIL_UNLESS("set enum 2b", -1 == owl_variable_set_int(var, OWL_SCROLLMODE_PAGEDCENTER + 1));
389  FAIL_UNLESS("get enum 2", OWL_SCROLLMODE_TOP == owl_variable_get_int(var));
390  FAIL_UNLESS("set enum 3", 0 == owl_variable_set_fromstring(var, "center", 0));
391  FAIL_UNLESS("get enum 4", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var));
392  FAIL_UNLESS("set enum 5", -1 == owl_variable_set_fromstring(var, "bogus", 0));
393  FAIL_UNLESS("set enum 6", -1 == owl_variable_set_fromstring(var, "", 0));
394  FAIL_UNLESS("get enum 7", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var));
395
396  owl_variable_dict_newvar_string(&vd, "stringvar", "testval", "", "");
397  FAIL_UNLESS("get new string var", NULL != (var = owl_variable_get_var(&vd, "stringvar")));
398  FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(var)));
399  owl_variable_set_string(var, "new val");
400  FAIL_UNLESS("update string val", !strcmp("new val", owl_variable_get_string(var)));
401
402  owl_variable_dict_newvar_int(&vd, "intvar", 47, "", "");
403  FAIL_UNLESS("get new int var", NULL != (var = owl_variable_get_var(&vd, "intvar")));
404  FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(var));
405  owl_variable_set_int(var, 17);
406  FAIL_UNLESS("update int val", 17 == owl_variable_get_int(var));
407
408  owl_variable_dict_newvar_bool(&vd, "boolvar", true, "", "");
409  FAIL_UNLESS("get new bool var", NULL != (var = owl_variable_get_var(&vd, "boolvar")));
410  FAIL_UNLESS("get new bool val", owl_variable_get_bool(var));
411  owl_variable_set_bool_off(var);
412  FAIL_UNLESS("update bool val", !owl_variable_get_bool(var));
413
414  owl_variable_dict_newvar_string(&vd, "nullstringvar", NULL, "", "");
415  FAIL_UNLESS("get new string (NULL) var", NULL != (var = owl_variable_get_var(&vd, "nullstringvar")));
416  FAIL_UNLESS("get string (NULL)", NULL == (value = owl_variable_get_tostring(var)));
417  g_free(value);
418  var = owl_variable_get_var(&vd, "zsigproc");
419  FAIL_UNLESS("get string (NULL) 2", NULL == (value = owl_variable_get_tostring(var)));
420  g_free(value);
421
422  owl_variable_dict_newvar_enum(&vd, "enumvar", 0, "", "", "a,b,c,d");
423  FAIL_UNLESS("get new enum var", NULL != (var = owl_variable_get_var(&vd, "enumvar")));
424  FAIL_UNLESS("get new enum val", 0 == owl_variable_get_int(var));
425  owl_variable_set_fromstring(var, "c", 0);
426  FAIL_UNLESS("update enum val", 2 == owl_variable_get_int(var));
427
428  owl_variable_dict_cleanup(&vd);
429
430  /* if (numfailed) printf("*** WARNING: failures encountered with owl_variable\n"); */
431  printf("# END testing owl_variable (%d failures)\n", numfailed);
432  return(numfailed);
433}
434
435static int owl_filter_test_string(const char *filt, const owl_message *m, int shouldmatch)
436{
437  owl_filter *f;
438  int ok;
439  int failed = 0;
440  if ((f = owl_filter_new_fromstring("test-filter", filt)) == NULL) {
441    printf("not ok can't parse %s\n", filt);
442    failed = 1;
443    goto out;
444  }
445  ok = owl_filter_message_match(f, m);
446  if((shouldmatch && !ok) || (!shouldmatch && ok)) {
447    printf("not ok match %s (got %d, expected %d)\n", filt, ok, shouldmatch);
448    failed = 1;
449  }
450 out:
451  owl_filter_delete(f);
452  if(!failed) {
453    printf("ok %s %s\n", shouldmatch ? "matches" : "doesn't match", filt);
454  }
455  return failed;
456}
457
458int owl_filter_regtest(void) {
459  int numfailed=0;
460  owl_message m;
461  owl_filter *f1, *f2, *f3, *f4, *f5;
462
463  owl_message_init(&m);
464  owl_message_set_type_zephyr(&m);
465  owl_message_set_direction_in(&m);
466  owl_message_set_class(&m, "owl");
467  owl_message_set_instance(&m, "tester");
468  owl_message_set_sender(&m, "owl-user");
469  owl_message_set_recipient(&m, "joe");
470  owl_message_set_attribute(&m, "foo", "bar");
471
472#define TEST_FILTER(f, e) do {                          \
473    numtests++;                                         \
474    numfailed += owl_filter_test_string(f, &m, e);      \
475      } while(0)
476
477  TEST_FILTER("true", 1);
478  TEST_FILTER("false", 0);
479  TEST_FILTER("( true )", 1);
480  TEST_FILTER("not false", 1);
481  TEST_FILTER("( true ) or ( false )", 1);
482  TEST_FILTER("true and false", 0);
483  TEST_FILTER("( true or true ) or ( ( false ) )", 1);
484
485  TEST_FILTER("class owl", 1);
486  TEST_FILTER("class ^owl$", 1);
487  TEST_FILTER("instance test", 1);
488  TEST_FILTER("instance ^test$", 0);
489  TEST_FILTER("instance ^tester$", 1);
490
491  TEST_FILTER("foo bar", 1);
492  TEST_FILTER("class owl and instance tester", 1);
493  TEST_FILTER("type ^zephyr$ and direction ^in$ and ( class ^owl$ or instance ^owl$ )", 1);
494
495  /* Order of operations and precedence */
496  TEST_FILTER("not true or false", 0);
497  TEST_FILTER("true or true and false", 0);
498  TEST_FILTER("true and true and false or true", 1);
499  TEST_FILTER("false and false or true", 1);
500  TEST_FILTER("true and false or false", 0);
501
502  f1 = owl_filter_new_fromstring("f1", "class owl");
503  owl_global_add_filter(&g, f1);
504  TEST_FILTER("filter f1", 1);
505  owl_global_remove_filter(&g, "f1");
506
507  /* Test recursion prevention */
508  FAIL_UNLESS("self reference", (f2 = owl_filter_new_fromstring("test", "filter test")) == NULL);
509  owl_filter_delete(f2);
510
511  /* mutual recursion */
512  f3 = owl_filter_new_fromstring("f3", "filter f4");
513  owl_global_add_filter(&g, f3);
514  FAIL_UNLESS("mutual recursion", (f4 = owl_filter_new_fromstring("f4", "filter f3")) == NULL);
515  owl_global_remove_filter(&g, "f3");
516  owl_filter_delete(f4);
517
518  /* support referencing a filter several times */
519  FAIL_UNLESS("DAG", (f5 = owl_filter_new_fromstring("dag", "filter f1 or filter f1")) != NULL);
520  owl_filter_delete(f5);
521
522  owl_message_cleanup(&m);
523
524  return 0;
525}
526
527int owl_editwin_regtest(void) {
528  int numfailed = 0;
529  const char *p;
530  owl_editwin *oe;
531  const char *autowrap_string = "we feel our owls should live "
532                                "closer to our ponies.";
533
534  printf("# BEGIN testing owl_editwin\n");
535
536  oe = owl_editwin_new(NULL, 80, 80, OWL_EDITWIN_STYLE_MULTILINE, NULL);
537
538  /* TODO: make the strings a little more lenient w.r.t trailing whitespace */
539
540  /* check paragraph fill */
541  owl_editwin_insert_string(oe, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.\n\nblah");
542  owl_editwin_move_to_top(oe);
543  owl_editwin_fill_paragraph(oe);
544  p = owl_editwin_get_text(oe);
545  FAIL_UNLESS("text was correctly wrapped", p && !strcmp(p, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n"
546                                                            "blah blah blah.\n"
547                                                            "\n"
548                                                            "blah"));
549
550  owl_editwin_unref(oe); oe = NULL;
551  oe = owl_editwin_new(NULL, 80, 80, OWL_EDITWIN_STYLE_MULTILINE, NULL);
552
553  /* check that lines ending with ". " correctly fill */
554  owl_editwin_insert_string(oe, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah. \n\nblah");
555  owl_editwin_move_to_top(oe);
556  owl_editwin_fill_paragraph(oe);
557  p = owl_editwin_get_text(oe);
558  FAIL_UNLESS("text was correctly wrapped", p && !strcmp(p, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n"
559                                                            "blah blah blah. \n"
560                                                            "\n"
561                                                            "blah"));
562
563  owl_editwin_unref(oe); oe = NULL;
564
565  /* Test owl_editwin_move_to_beginning_of_line. */
566  oe = owl_editwin_new(NULL, 80, 80, OWL_EDITWIN_STYLE_MULTILINE, NULL);
567  owl_editwin_insert_string(oe, "\n");
568  owl_editwin_insert_string(oe, "12345678\n");
569  owl_editwin_insert_string(oe, "\n");
570  owl_editwin_insert_string(oe, "abcdefg\n");
571  owl_editwin_move_to_top(oe);
572  FAIL_UNLESS("already at beginning of line",
573              owl_editwin_move_to_beginning_of_line(oe) == 0);
574  owl_editwin_line_move(oe, 1);
575  owl_editwin_point_move(oe, 5);
576  FAIL_UNLESS("find beginning of line after empty first line",
577              owl_editwin_move_to_beginning_of_line(oe) == -5);
578  owl_editwin_line_move(oe, 1);
579  FAIL_UNLESS("find beginning empty middle line",
580              owl_editwin_move_to_beginning_of_line(oe) == 0);
581  owl_editwin_line_move(oe, 1);
582  owl_editwin_point_move(oe, 2);
583  FAIL_UNLESS("find beginning of line after empty middle line",
584              owl_editwin_move_to_beginning_of_line(oe) == -2);
585  owl_editwin_unref(oe); oe = NULL;
586
587  /* Test automatic line-wrapping. */
588  owl_global_set_edit_maxwrapcols(&g, 10);
589  oe = owl_editwin_new(NULL, 80, 80, OWL_EDITWIN_STYLE_MULTILINE, NULL);
590  for (p = autowrap_string; *p; p++) {
591    owl_input j;
592    j.ch = *p;
593    j.uch = *p; /* Assuming ASCII. */
594    owl_editwin_process_char(oe, j);
595  }
596  p = owl_editwin_get_text(oe);
597  FAIL_UNLESS("text was automatically wrapped",
598              p && !strcmp(p, "we feel\n"
599                           "our owls\n"
600                           "should\n"
601                           "live\n"
602                           "closer to\n"
603                           "our\n"
604                           "ponies."));
605  owl_editwin_unref(oe); oe = NULL;
606  owl_global_set_edit_maxwrapcols(&g, 70);
607
608  /* Test owl_editwin_current_column. */
609  oe = owl_editwin_new(NULL, 80, 80, OWL_EDITWIN_STYLE_MULTILINE, NULL);
610  FAIL_UNLESS("initial column zero", owl_editwin_current_column(oe) == 0);
611  owl_editwin_insert_string(oe, "abcdef");
612  FAIL_UNLESS("simple insert", owl_editwin_current_column(oe) == 6);
613  owl_editwin_insert_string(oe, "\t");
614  FAIL_UNLESS("insert tabs", owl_editwin_current_column(oe) == 8);
615  owl_editwin_insert_string(oe, "123\n12\t3");
616  FAIL_UNLESS("newline with junk", owl_editwin_current_column(oe) == 9);
617  owl_editwin_move_to_beginning_of_line(oe);
618  FAIL_UNLESS("beginning of line", owl_editwin_current_column(oe) == 0);
619  owl_editwin_unref(oe); oe = NULL;
620
621  printf("# END testing owl_editwin (%d failures)\n", numfailed);
622
623  return numfailed;
624}
625
626int owl_fmtext_regtest(void) {
627  int numfailed = 0;
628  int start, end;
629  owl_fmtext fm1;
630  owl_fmtext fm2;
631  owl_regex re;
632  char *str;
633
634  printf("# BEGIN testing owl_fmtext\n");
635
636  owl_fmtext_init_null(&fm1);
637  owl_fmtext_init_null(&fm2);
638
639  /* Verify text gets correctly appended. */
640  owl_fmtext_append_normal(&fm1, "1234567898");
641  owl_fmtext_append_fmtext(&fm2, &fm1);
642  FAIL_UNLESS("string lengths correct",
643              owl_fmtext_num_bytes(&fm2) == strlen(owl_fmtext_get_text(&fm2)));
644
645  /* Test owl_fmtext_num_lines. */
646  owl_fmtext_clear(&fm1);
647  FAIL_UNLESS("empty line correct", owl_fmtext_num_lines(&fm1) == 0);
648  owl_fmtext_append_normal(&fm1, "12345\n67898");
649  FAIL_UNLESS("trailing chars correct", owl_fmtext_num_lines(&fm1) == 2);
650  owl_fmtext_append_normal(&fm1, "\n");
651  FAIL_UNLESS("trailing newline correct", owl_fmtext_num_lines(&fm1) == 2);
652  owl_fmtext_append_bold(&fm1, "");
653  FAIL_UNLESS("trailing attributes correct", owl_fmtext_num_lines(&fm1) == 2);
654
655  /* Test owl_fmtext_truncate_lines */
656  owl_fmtext_clear(&fm1);
657  owl_fmtext_append_normal(&fm1, "0\n1\n2\n3\n4\n");
658
659  owl_fmtext_clear(&fm2);
660  owl_fmtext_truncate_lines(&fm1, 1, 3, &fm2);
661  str = owl_fmtext_print_plain(&fm2);
662  FAIL_UNLESS("lines corrected truncated",
663              str && !strcmp(str, "1\n2\n3\n"));
664  g_free(str);
665
666  owl_fmtext_clear(&fm2);
667  owl_fmtext_truncate_lines(&fm1, 1, 5, &fm2);
668  str = owl_fmtext_print_plain(&fm2);
669  FAIL_UNLESS("lines corrected truncated",
670              str && !strcmp(str, "1\n2\n3\n4\n"));
671  g_free(str);
672
673  /* Test owl_fmtext_truncate_cols. */
674  owl_fmtext_clear(&fm1);
675  owl_fmtext_append_normal(&fm1, "123456789012345\n");
676  owl_fmtext_append_normal(&fm1, "123456789\n");
677  owl_fmtext_append_normal(&fm1, "1234567890\n");
678
679  owl_fmtext_clear(&fm2);
680  owl_fmtext_truncate_cols(&fm1, 4, 9, &fm2);
681  str = owl_fmtext_print_plain(&fm2);
682  FAIL_UNLESS("columns correctly truncated",
683              str && !strcmp(str, "567890"
684                                  "56789\n"
685                                  "567890"));
686  g_free(str);
687
688  owl_fmtext_clear(&fm1);
689  owl_fmtext_append_normal(&fm1, "12\t1234");
690  owl_fmtext_append_bold(&fm1, "56\n");
691  owl_fmtext_append_bold(&fm1, "12345678\t\n");
692
693  owl_fmtext_clear(&fm2);
694  owl_fmtext_truncate_cols(&fm1, 4, 13, &fm2);
695  str = owl_fmtext_print_plain(&fm2);
696  FAIL_UNLESS("columns correctly truncated",
697              str && !strcmp(str, "    123456"
698                                  "5678      "));
699  g_free(str);
700
701  /* Test owl_fmtext_expand_tabs. */
702  owl_fmtext_clear(&fm1);
703  owl_fmtext_append_normal(&fm1, "12\t1234");
704  owl_fmtext_append_bold(&fm1, "567\t1\n12345678\t1");
705  owl_fmtext_clear(&fm2);
706  owl_fmtext_expand_tabs(&fm1, &fm2, 0);
707  str = owl_fmtext_print_plain(&fm2);
708  FAIL_UNLESS("no tabs remaining", strchr(str, '\t') == NULL);
709  FAIL_UNLESS("tabs corrected expanded",
710              str && !strcmp(str, "12      1234567 1\n"
711                                  "12345678        1"));
712  g_free(str);
713
714  owl_fmtext_clear(&fm2);
715  owl_fmtext_expand_tabs(&fm1, &fm2, 1);
716  str = owl_fmtext_print_plain(&fm2);
717  FAIL_UNLESS("no tabs remaining", strchr(str, '\t') == NULL);
718  FAIL_UNLESS("tabs corrected expanded",
719              str && !strcmp(str, "12     1234567 1\n"
720                                  "12345678       1"));
721  g_free(str);
722
723  /* Test owl_fmtext_search. */
724  owl_fmtext_clear(&fm1);
725  owl_fmtext_append_normal(&fm1, "123123123123");
726  owl_regex_create(&re, "12");
727  {
728    int count = 0, offset;
729    offset = owl_fmtext_search(&fm1, &re, 0);
730    while (offset >= 0) {
731      FAIL_UNLESS("search matches",
732                  !strncmp("12", owl_fmtext_get_text(&fm1) + offset, 2));
733      count++;
734      offset = owl_fmtext_search(&fm1, &re, offset+1);
735    }
736    FAIL_UNLESS("exactly four matches", count == 4);
737  }
738  owl_regex_cleanup(&re);
739
740  /* Test owl_fmtext_line_number. */
741  owl_fmtext_clear(&fm1);
742  owl_fmtext_append_normal(&fm1, "123\n456\n");
743  owl_fmtext_append_bold(&fm1, "");
744  FAIL_UNLESS("lines start at 0", 0 == owl_fmtext_line_number(&fm1, 0));
745  FAIL_UNLESS("trailing formatting characters part of false line",
746              2 == owl_fmtext_line_number(&fm1, owl_fmtext_num_bytes(&fm1)));
747  owl_regex_create_quoted(&re, "456");
748  FAIL_UNLESS("correctly find second line (line 1)",
749              1 == owl_fmtext_line_number(&fm1, owl_fmtext_search(&fm1, &re, 0)));
750  owl_regex_cleanup(&re);
751
752  /* Test owl_fmtext_line_extents. */
753  owl_fmtext_clear(&fm1);
754  owl_fmtext_append_normal(&fm1, "123\n456\n789");
755  owl_fmtext_line_extents(&fm1, 1, &start, &end);
756  FAIL_UNLESS("line contents",
757              !strncmp("456\n", owl_fmtext_get_text(&fm1)+start, end-start));
758  owl_fmtext_line_extents(&fm1, 2, &start, &end);
759  FAIL_UNLESS("point to end of buffer", end == owl_fmtext_num_bytes(&fm1));
760
761  owl_fmtext_cleanup(&fm1);
762  owl_fmtext_cleanup(&fm2);
763
764  printf("# END testing owl_fmtext (%d failures)\n", numfailed);
765
766  return numfailed;
767}
768
769static int owl_smartfilter_test_equals(const char *filtname, const char *expected) {
770  owl_filter *f = NULL;
771  char *filtstr = NULL;
772  int failed = 0;
773  f = owl_global_get_filter(&g, filtname);
774  if (f == NULL) {
775    printf("not ok filter missing: %s\n", filtname);
776    failed = 1;
777    goto out;
778  }
779
780  /* TODO: Come up with a better way to test this. */
781  filtstr = owl_filter_print(f);
782  if (strcmp(expected, filtstr)) {
783    printf("not ok filter incorrect: |%s| instead of |%s|\n",
784           filtstr, expected);
785    failed = 1;
786    goto out;
787  }
788
789 out:
790  g_free(filtstr);
791  return failed;
792}
793
794static int owl_classinstfilt_test(const char *c, const char *i, int related, const char *expected) {
795  char *filtname = NULL;
796  int failed = 0;
797
798  filtname = owl_function_classinstfilt(c, i, related);
799  if (filtname == NULL) {
800    printf("not ok null filtname: %s %s %s\n", c, i ? i : "(null)",
801           related ? "related" : "not related");
802    failed = 1;
803    goto out;
804  }
805  if (owl_smartfilter_test_equals(filtname, expected)) {
806    failed = 1;
807    goto out;
808  }
809 out:
810  if (!failed) {
811    printf("ok %s\n", filtname);
812  }
813  if (filtname)
814    owl_global_remove_filter(&g, filtname);
815  g_free(filtname);
816  return failed;
817}
818
819static int owl_zuserfilt_test(const char *longuser, const char *expected) {
820  char *filtname = NULL;
821  int failed = 0;
822
823  filtname = owl_function_zuserfilt(longuser);
824  if (filtname == NULL) {
825    printf("not ok null filtname: %s\n", longuser);
826    failed = 1;
827    goto out;
828  }
829  if (owl_smartfilter_test_equals(filtname, expected)) {
830    failed = 1;
831    goto out;
832  }
833 out:
834  if (!failed) {
835    printf("ok %s\n", filtname);
836  }
837  if (filtname)
838    owl_global_remove_filter(&g, filtname);
839  g_free(filtname);
840  return failed;
841}
842
843
844int owl_smartfilter_regtest(void) {
845  int numfailed = 0;
846
847  printf("# BEGIN testing owl_smartfilter\n");
848
849  /* Check classinst making. */
850
851#define TEST_CLASSINSTFILT(c, i, r, e) do {             \
852    numtests++;                                         \
853    numfailed += owl_classinstfilt_test(c, i, r, e);    \
854  } while (0)
855  TEST_CLASSINSTFILT("message", NULL, false,
856                     "class ^message$\n");
857  TEST_CLASSINSTFILT("message", NULL, true,
858                     "class ^(un)*message(\\.d)*$\n");
859  TEST_CLASSINSTFILT("message", "personal", false,
860                     "class ^message$ and instance ^personal$\n");
861  TEST_CLASSINSTFILT("message", "personal", true,
862                     "class ^(un)*message(\\.d)*$ and ( instance ^(un)*personal(\\.d)*$ )\n");
863
864  TEST_CLASSINSTFILT("message", "evil\tinstance", false,
865                     "class ^message$ and instance '^evil\tinstance$'\n");
866  TEST_CLASSINSTFILT("message", "evil instance", false,
867                     "class ^message$ and instance '^evil instance$'\n");
868  TEST_CLASSINSTFILT("message", "evil'instance", false,
869                     "class ^message$ and instance \"^evil'instance$\"\n");
870  TEST_CLASSINSTFILT("message", "evil\"instance", false,
871                     "class ^message$ and instance '^evil\"instance$'\n");
872  TEST_CLASSINSTFILT("message", "evil$instance", false,
873                     "class ^message$ and instance ^evil\\$instance$\n");
874
875#define TEST_ZUSERFILT(l, e) do {                       \
876    numtests++;                                         \
877    numfailed += owl_zuserfilt_test(l, e);              \
878  } while (0)
879  TEST_ZUSERFILT("user",
880                 "( type ^zephyr$ and filter personal and "
881                 "( ( direction ^in$ and sender "
882                 "^user$"
883                 " ) or ( direction ^out$ and recipient "
884                 "^user$"
885                 " ) ) ) or ( ( class ^login$ ) and ( sender "
886                 "^user$"
887                 " ) )\n");
888  TEST_ZUSERFILT("very evil\t.user",
889                 "( type ^zephyr$ and filter personal and "
890                 "( ( direction ^in$ and sender "
891                 "'^very evil\t\\.user$'"
892                 " ) or ( direction ^out$ and recipient "
893                 "'^very evil\t\\.user$'"
894                 " ) ) ) or ( ( class ^login$ ) and ( sender "
895                 "'^very evil\t\\.user$'"
896                 " ) )\n");
897
898  printf("# END testing owl_smartfilter (%d failures)\n", numfailed);
899
900  return numfailed;
901}
902
903int owl_history_regtest(void)
904{
905  int numfailed = 0;
906  int i;
907  owl_history h;
908
909  printf("# BEGIN testing owl_history\n");
910  owl_history_init(&h);
911
912  /* Operations on empty history. */
913  FAIL_UNLESS("prev NULL", owl_history_get_prev(&h) == NULL);
914  FAIL_UNLESS("next NULL", owl_history_get_next(&h) == NULL);
915  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
916
917  /* Insert a few records. */
918  owl_history_store(&h, "a", false);
919  owl_history_store(&h, "b", false);
920  owl_history_store(&h, "c", false);
921  owl_history_store(&h, "d", true);
922
923  /* Walk up and down the history a bit. */
924  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
925  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
926  FAIL_UNLESS("touched", owl_history_is_touched(&h));
927  FAIL_UNLESS("next d", strcmp(owl_history_get_next(&h), "d") == 0);
928  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
929  FAIL_UNLESS("next NULL", owl_history_get_next(&h) == NULL);
930  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
931  FAIL_UNLESS("prev b", strcmp(owl_history_get_prev(&h), "b") == 0);
932  FAIL_UNLESS("prev a", strcmp(owl_history_get_prev(&h), "a") == 0);
933  FAIL_UNLESS("prev NULL", owl_history_get_prev(&h) == NULL);
934
935  /* Now insert something. It should reset and blow away 'd'. */
936  owl_history_store(&h, "e", false);
937  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
938  FAIL_UNLESS("next NULL", owl_history_get_next(&h) == NULL);
939  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
940  FAIL_UNLESS("touched", owl_history_is_touched(&h));
941  FAIL_UNLESS("next e", strcmp(owl_history_get_next(&h), "e") == 0);
942  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
943
944  /* Lines get de-duplicated on insert. */
945  owl_history_store(&h, "e", false);
946  owl_history_store(&h, "e", false);
947  owl_history_store(&h, "e", false);
948  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
949  FAIL_UNLESS("next e", strcmp(owl_history_get_next(&h), "e") == 0);
950
951  /* But a partial is not deduplicated, as it'll go away soon. */
952  owl_history_store(&h, "e", true);
953  FAIL_UNLESS("prev e", strcmp(owl_history_get_prev(&h), "e") == 0);
954  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
955  FAIL_UNLESS("next e", strcmp(owl_history_get_next(&h), "e") == 0);
956  FAIL_UNLESS("next e", strcmp(owl_history_get_next(&h), "e") == 0);
957
958  /* Reset moves to the front... */
959  owl_history_store(&h, "f", true);
960  FAIL_UNLESS("prev e", strcmp(owl_history_get_prev(&h), "e") == 0);
961  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
962  owl_history_reset(&h);
963  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
964  /* ...and destroys any pending partial entry... */
965  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
966  FAIL_UNLESS("prev b", strcmp(owl_history_get_prev(&h), "b") == 0);
967  /* ...but not non-partial ones. */
968  owl_history_reset(&h);
969  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
970
971  /* Finally, check we are bounded by OWL_HISTORYSIZE. */
972  for (i = 0; i < OWL_HISTORYSIZE; i++) {
973    char *string = g_strdup_printf("mango%d", i);
974    owl_history_store(&h, string, false);
975    g_free(string);
976  }
977  /* The OWL_HISTORYSIZE'th prev gets NULL. */
978  for (i = OWL_HISTORYSIZE - 2; i >= 0; i--) {
979    char *string = g_strdup_printf("mango%d", i);
980    FAIL_UNLESS("prev mango_N", strcmp(owl_history_get_prev(&h), string) == 0);
981    g_free(string);
982  }
983  FAIL_UNLESS("prev NULL", owl_history_get_prev(&h) == NULL);
984
985  owl_history_cleanup(&h);
986
987  printf("# END testing owl_history (%d failures)\n", numfailed);
988  return numfailed;
989}
990
991int call_filter_regtest(void)
992{
993  int numfailed = 0;
994  int ret;
995  char *out = NULL;
996  int status;
997
998  printf("# BEGIN testing call_filter\n");
999
1000  const char *cat_argv[] = { "cat", NULL };
1001  ret = call_filter(cat_argv, "Mangos!", &out, &status);
1002  FAIL_UNLESS("call_filter cat", (ret == 0 &&
1003                                  status == 0 &&
1004                                  strcmp(out, "Mangos!") == 0));
1005  g_free(out); out = NULL;
1006
1007  ret = call_filter(cat_argv, "", &out, &status);
1008  FAIL_UNLESS("call_filter cat", (ret == 0 &&
1009                                  status == 0 &&
1010                                  strcmp(out, "") == 0));
1011  g_free(out); out = NULL;
1012
1013  ret = call_filter(cat_argv, NULL, &out, &status);
1014  FAIL_UNLESS("call_filter cat", (ret == 0 &&
1015                                  status == 0 &&
1016                                  strcmp(out, "") == 0));
1017  g_free(out); out = NULL;
1018
1019  printf("# END testing call_filter (%d failures)\n", numfailed);
1020  return numfailed;
1021}
1022
1023int owl_smartstrip_regtest(void)
1024{
1025  int numfailed = 0;
1026
1027  printf("# BEGIN testing owl_zephyr_smartstripped_user\n");
1028
1029#define CHECK_SMARTSTRIP(in, expected)                  \
1030  do {                                                  \
1031    char *__value = owl_zephyr_smartstripped_user(in);  \
1032    FAIL_UNLESS("owl_zephyr_smartstripped_user " in,    \
1033                strcmp((expected), __value) == 0);      \
1034    g_free(__value);                                    \
1035  } while (0)
1036
1037  CHECK_SMARTSTRIP("foo", "foo");
1038  CHECK_SMARTSTRIP("foo.bar", "foo");
1039  CHECK_SMARTSTRIP("foo/bar", "foo");
1040  CHECK_SMARTSTRIP("host/bar", "host/bar");
1041  CHECK_SMARTSTRIP("rcmd.bar", "rcmd.bar");
1042  CHECK_SMARTSTRIP("daemon/bar", "daemon/bar");
1043  CHECK_SMARTSTRIP("daemon.bar", "daemon.bar");
1044
1045  CHECK_SMARTSTRIP("foo@ATHENA.MIT.EDU", "foo@ATHENA.MIT.EDU");
1046  CHECK_SMARTSTRIP("foo.bar@ATHENA.MIT.EDU", "foo@ATHENA.MIT.EDU");
1047  CHECK_SMARTSTRIP("foo/bar@ATHENA.MIT.EDU", "foo@ATHENA.MIT.EDU");
1048  CHECK_SMARTSTRIP("host/bar@ATHENA.MIT.EDU", "host/bar@ATHENA.MIT.EDU");
1049  CHECK_SMARTSTRIP("rcmd.bar@ATHENA.MIT.EDU", "rcmd.bar@ATHENA.MIT.EDU");
1050  CHECK_SMARTSTRIP("daemon/bar@ATHENA.MIT.EDU", "daemon/bar@ATHENA.MIT.EDU");
1051  CHECK_SMARTSTRIP("daemon.bar@ATHENA.MIT.EDU", "daemon.bar@ATHENA.MIT.EDU");
1052
1053  printf("# END testing owl_zephyr_smartstripped_user\n");
1054
1055  return numfailed;
1056}
Note: See TracBrowser for help on using the repository browser.