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#628.
  • Loading branch information
cgzones committed Sep 20, 2022
1 parent 5f771fc commit 6fbb37a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/empty_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ int main(void)
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/628
*/
# else
/*
* try to reload the generated temporary config file to check
* that the default is indeed overridden by an empty string
Expand All @@ -36,9 +42,12 @@ int main(void)
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
8 changes: 8 additions & 0 deletions tests/print_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ int main(void)
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/628
*/
# else
fprintf(stderr, "no_foo filter:\n%s", buf);
fail_unless(strstr(buf, "foo-") == NULL);
fail_unless(strstr(buf, "bar-") != NULL);
Expand All @@ -56,6 +62,8 @@ int main(void)
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 6fbb37a

Please sign in to comment.