Changeset 34132f7 for tester.c


Ignore:
Timestamp:
Mar 11, 2012, 10:34:18 PM (12 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
release-1.8
Children:
6a08f16
Parents:
4a80a16
git-author:
David Benjamin <davidben@mit.edu> (01/23/12 00:38:29)
git-committer:
David Benjamin <davidben@mit.edu> (03/11/12 22:34:18)
Message:
Rewrite call_filter to use g_spawn_async_with_pipes

This simplifies the error-handling code. Also fixes a bug where file
descriptors get double-closed in call_filter. Also adds a unit test. The
separate prog argument is removed to avoid having to deal with
G_SPAWN_FILE_AND_ARGV_ZERO, and since we don't really use it anyway.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester.c

    r67e5ba36 r34132f7  
    33#include "owl.h"
    44#undef WINDOW
     5#include "filterproc.h"
    56
    67#include <unistd.h>
     
    2627int owl_smartfilter_regtest(void);
    2728int owl_history_regtest(void);
     29int call_filter_regtest(void);
    2830
    2931extern void owl_perl_xs_init(pTHX);
     
    116118  numfailures += owl_smartfilter_regtest();
    117119  numfailures += owl_history_regtest();
     120  numfailures += call_filter_regtest();
    118121  if (numfailures) {
    119122      fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
     
    982985  return numfailed;
    983986}
     987
     988int call_filter_regtest(void)
     989{
     990  int numfailed = 0;
     991  int ret;
     992  char *out = NULL;
     993  int status;
     994
     995  printf("# BEGIN testing call_filter\n");
     996
     997  const char *cat_argv[] = { "cat", NULL };
     998  ret = call_filter(cat_argv, "Mangos!", &out, &status);
     999  FAIL_UNLESS("call_filter cat", (ret == 0 &&
     1000                                  status == 0 &&
     1001                                  strcmp(out, "Mangos!") == 0));
     1002  g_free(out); out = NULL;
     1003
     1004  ret = call_filter(cat_argv, "", &out, &status);
     1005  FAIL_UNLESS("call_filter cat", (ret == 0 &&
     1006                                  status == 0 &&
     1007                                  strcmp(out, "") == 0));
     1008  g_free(out); out = NULL;
     1009
     1010  ret = call_filter(cat_argv, NULL, &out, &status);
     1011  FAIL_UNLESS("call_filter cat", (ret == 0 &&
     1012                                  status == 0 &&
     1013                                  strcmp(out, "") == 0));
     1014  g_free(out); out = NULL;
     1015
     1016  printf("# END testing call_filter (%d failures)\n", numfailed);
     1017  return numfailed;
     1018}
Note: See TracChangeset for help on using the changeset viewer.