Changes in tester.c [14c9e05:0ba7333]
Legend:
- Unmodified
- Added
- Removed
-
tester.c
r14c9e05 r0ba7333 4 4 #undef WINDOW 5 5 6 #include <errno.h>7 6 #include <unistd.h> 8 #include <pwd.h>9 7 #include <stdio.h> 10 8 #include <stdlib.h> 11 9 #include <string.h> 12 #include <sys/types.h>13 10 14 11 #undef instr … … 136 133 { 137 134 int numfailed=0; 138 const char *home; 139 char *s, *path; 140 struct passwd *pw; 135 char *s, *path, *home; 141 136 142 137 printf("# BEGIN testing owl_util\n"); … … 227 222 "\""); 228 223 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"); 231 226 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); 234 229 235 230 … … 274 269 g_free(s); 275 270 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)); 285 272 s = owl_util_makepath("~"); 286 273 FAIL_UNLESS("makepath ~", !strcmp(home, s)); 287 274 g_free(s); 288 275 289 path = g_ strconcat(home, "/foo/bar/baz", NULL);276 path = g_build_filename(home, "foo/bar/baz", NULL); 290 277 s = owl_util_makepath("~///foo/bar//baz"); 291 278 FAIL_UNLESS("makepath ~///foo/bar//baz", !strcmp(path, s)); 292 279 g_free(s); 293 280 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) { 300 285 /* 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"); 303 288 } 304 289 … … 307 292 g_free(s); 308 293 309 path = g_ strconcat(home, "/foo/bar/baz", NULL);294 path = g_build_filename(home, "foo/bar/baz", NULL); 310 295 s = owl_util_makepath("~root///foo/bar//baz"); 311 296 FAIL_UNLESS("makepath ~root///foo/bar//baz", !strcmp(path, s)); 312 297 g_free(s); 313 298 g_free(path); 299 g_free(home); 314 300 315 301 /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */
Note: See TracChangeset
for help on using the changeset viewer.