Skip to content

Commit

Permalink
tests: skip test with broken fmemopen under sanitizers
Browse files Browse the repository at this point in the history
fmemopen(2) is broken with address and memory sanitizer, see
google/sanitizers#627 and
google/sanitizers#628.
  • Loading branch information
cgzones committed Sep 19, 2022
1 parent 9c486a9 commit 971b7de
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
17 changes: 14 additions & 3 deletions tests/empty_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,30 @@ int main(void)
fail_unless(strcmp(cfg_getstr(cfg, "string"), "") == 0);
f = fmemopen(buf, sizeof(buf), "w+");
fail_unless(f != NULL);
cfg_print(cfg, f);
fail_unless(cfg_print(cfg, f) == CFG_SUCCESS);
cfg_free(cfg);

#if defined(__has_feature)
# if __has_feature(address_sanitizer) || __has_feature(memory_sanitizer)
/* Skip check since fmemopen(2) is broken with sanitizers, see
* https://github.com/google/sanitizers/issues/627
* https://github.com/google/sanitizers/issues/628
*/
# else
/*
* try to reload the generated temporary config file to check
* that the default is indeed overridden by an empty string
*/
cfg = cfg_init(opts, 0);
fseek(f, 0L, SEEK_SET);
fail_unless(cfg != NULL);
fail_unless(fseek(f, 0L, SEEK_SET) == 0);
fail_unless(cfg_parse_fp(cfg, f) == CFG_SUCCESS);
fclose(f);
fail_unless(strcmp(cfg_getstr(cfg, "string"), "") == 0);
cfg_free(cfg);
# endif
#endif

fclose(f);

return 0;
}
Expand Down
13 changes: 11 additions & 2 deletions tests/print_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,32 @@ int main(void)
cfg_set_print_filter_func(cfg, no_foo);
f = fmemopen(buf, sizeof(buf), "w+");
fail_unless(f != NULL);
cfg_print(cfg, f);
fail_unless(cfg_print(cfg, f) == CFG_SUCCESS);
fclose(f);

#if defined(__has_feature)
# if __has_feature(memory_sanitizer)
/* Skip check since fmemopen(2) is broken with sanitizers, see
* https://github.com/google/sanitizers/issues/627
* https://github.com/google/sanitizers/issues/628
*/
# else
fprintf(stderr, "no_foo filter:\n%s", buf);
fail_unless(strstr(buf, "foo-") == NULL);
fail_unless(strstr(buf, "bar-") != NULL);

cfg_set_print_filter_func(cfg, no_bar);
f = fmemopen(buf, sizeof(buf), "w+");
fail_unless(f != NULL);
cfg_print(cfg, f);
fail_unless(cfg_print(cfg, f) == CFG_SUCCESS);
fclose(f);

fprintf(stderr, "----\n");
fprintf(stderr, "no_bar filter:\n%s", buf);
fail_unless(strstr(buf, "foo-") != NULL);
fail_unless(strstr(buf, "bar-") == NULL);
# endif
#endif

cfg_free(cfg);

Expand Down

0 comments on commit 971b7de

Please sign in to comment.