Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester.c

    r14c9e05 r0ba7333  
    44#undef WINDOW
    55
    6 #include <errno.h>
    76#include <unistd.h>
    8 #include <pwd.h>
    97#include <stdio.h>
    108#include <stdlib.h>
    119#include <string.h>
    12 #include <sys/types.h>
    1310
    1411#undef instr
     
    136133{
    137134  int numfailed=0;
    138   const char *home;
    139   char *s, *path;
    140   struct passwd *pw;
     135  char *s, *path, *home;
    141136
    142137  printf("# BEGIN testing owl_util\n");
     
    227222                "\"");
    228223
    229   GString *g = g_string_new("");
    230   owl_string_appendf_quoted(g, "%q foo %q%q %s %", "hello", "world is", "can't");
     224  GString *quoted = g_string_new("");
     225  owl_string_appendf_quoted(quoted, "%q foo %q%q %s %", "hello", "world is", "can't");
    231226  FAIL_UNLESS("owl_string_appendf",
    232               !strcmp(g->str, "hello foo 'world is'\"can't\" %s %"));
    233   g_string_free(g, true);
     227              !strcmp(quoted->str, "hello foo 'world is'\"can't\" %s %"));
     228  g_string_free(quoted, true);
    234229
    235230
     
    274269  g_free(s);
    275270
    276   errno = 0;
    277   pw = getpwuid(getuid());
    278   if (pw) {
    279     home = pw->pw_dir;
    280   } else {
    281     /* Just make some noise so we notice. */
    282     home = "<WHAT>";
    283     fprintf(stderr, "getpwuid: %s", errno ? strerror(errno) : "No such user");
    284   }
     271  home = g_strdup(owl_global_get_homedir(&g));
    285272  s = owl_util_makepath("~");
    286273  FAIL_UNLESS("makepath ~", !strcmp(home, s));
    287274  g_free(s);
    288275
    289   path = g_strconcat(home, "/foo/bar/baz", NULL);
     276  path = g_build_filename(home, "foo/bar/baz", NULL);
    290277  s = owl_util_makepath("~///foo/bar//baz");
    291278  FAIL_UNLESS("makepath ~///foo/bar//baz", !strcmp(path, s));
    292279  g_free(s);
    293280  g_free(path);
    294 
    295   errno = 0;
    296   pw = getpwnam("root");
    297   if (pw) {
    298     home = pw->pw_dir;
    299   } else {
     281  g_free(home);
     282
     283  home = owl_util_homedir_for_user("root");
     284  if (home == NULL) {
    300285    /* Just make some noise so we notice. */
    301     home = "<WHAT>";
    302     fprintf(stderr, "getpwnam: %s", errno ? strerror(errno) : "No such user");
     286    home = g_strdup("<WHAT>");
     287    fprintf(stderr, "owl_util_homedir_for_user failed");
    303288  }
    304289
     
    307292  g_free(s);
    308293
    309   path = g_strconcat(home, "/foo/bar/baz", NULL);
     294  path = g_build_filename(home, "foo/bar/baz", NULL);
    310295  s = owl_util_makepath("~root///foo/bar//baz");
    311296  FAIL_UNLESS("makepath ~root///foo/bar//baz", !strcmp(path, s));
    312297  g_free(s);
    313298  g_free(path);
     299  g_free(home);
    314300
    315301  /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */
Note: See TracChangeset for help on using the changeset viewer.