Changeset 443dcfa


Ignore:
Timestamp:
Jan 20, 2011, 7:59:38 PM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
f47696f
Parents:
b31252d
git-author:
David Benjamin <davidben@mit.edu> (01/03/11 15:26:56)
git-committer:
David Benjamin <davidben@mit.edu> (01/20/11 19:59:38)
Message:
Add a test for zuserfilt
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester.c

    rb31252d r443dcfa  
    704704}
    705705
     706static int owl_zuserfilt_test(const char *longuser, const char *expected) {
     707  char *filtname = NULL;
     708  int failed = 0;
     709
     710  filtname = owl_function_zuserfilt(longuser);
     711  if (filtname == NULL) {
     712    printf("not ok null filtname: %s\n", longuser);
     713    failed = 1;
     714    goto out;
     715  }
     716  if (owl_smartfilter_test_equals(filtname, expected)) {
     717    failed = 1;
     718    goto out;
     719  }
     720 out:
     721  if (!failed) {
     722    printf("ok %s\n", filtname);
     723  }
     724  if (filtname)
     725    owl_global_remove_filter(&g, filtname);
     726  owl_free(filtname);
     727  return failed;
     728}
     729
     730
    706731int owl_smartfilter_regtest(void) {
    707732  int numfailed = 0;
     
    735760                     "class ^message$ and instance ^evil\\$instance$\n");
    736761
     762#define TEST_ZUSERFILT(l, e) do {                       \
     763    numtests++;                                         \
     764    numfailed += owl_zuserfilt_test(l, e);              \
     765  } while (0)
     766  TEST_ZUSERFILT("user",
     767                 "( type ^zephyr$ and filter personal and "
     768                 "( ( direction ^in$ and sender "
     769                 "^user$"
     770                 " ) or ( direction ^out$ and recipient "
     771                 "^user$"
     772                 " ) ) ) or ( ( class ^login$ ) and ( sender "
     773                 "^user$"
     774                 " ) )\n");
     775  TEST_ZUSERFILT("very evil\t.user",
     776                 "( type ^zephyr$ and filter personal and "
     777                 "( ( direction ^in$ and sender "
     778                 "'^very evil\t\\.user$'"
     779                 " ) or ( direction ^out$ and recipient "
     780                 "'^very evil\t\\.user$'"
     781                 " ) ) ) or ( ( class ^login$ ) and ( sender "
     782                 "'^very evil\t\\.user$'"
     783                 " ) )\n");
    737784
    738785  printf("# END testing owl_smartfilter (%d failures)\n", numfailed);
Note: See TracChangeset for help on using the changeset viewer.