Skip to content

Commit 971b7de

Browse files
committed
tests: skip test with broken fmemopen under sanitizers
fmemopen(2) is broken with address and memory sanitizer, see google/sanitizers#627 and google/sanitizers#628.
1 parent 9c486a9 commit 971b7de

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

tests/empty_string.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,30 @@ int main(void)
2525
fail_unless(strcmp(cfg_getstr(cfg, "string"), "") == 0);
2626
f = fmemopen(buf, sizeof(buf), "w+");
2727
fail_unless(f != NULL);
28-
cfg_print(cfg, f);
28+
fail_unless(cfg_print(cfg, f) == CFG_SUCCESS);
2929
cfg_free(cfg);
3030

31+
#if defined(__has_feature)
32+
# if __has_feature(address_sanitizer) || __has_feature(memory_sanitizer)
33+
/* Skip check since fmemopen(2) is broken with sanitizers, see
34+
* https://github.com/google/sanitizers/issues/627
35+
* https://github.com/google/sanitizers/issues/628
36+
*/
37+
# else
3138
/*
3239
* try to reload the generated temporary config file to check
3340
* that the default is indeed overridden by an empty string
3441
*/
3542
cfg = cfg_init(opts, 0);
36-
fseek(f, 0L, SEEK_SET);
43+
fail_unless(cfg != NULL);
44+
fail_unless(fseek(f, 0L, SEEK_SET) == 0);
3745
fail_unless(cfg_parse_fp(cfg, f) == CFG_SUCCESS);
38-
fclose(f);
3946
fail_unless(strcmp(cfg_getstr(cfg, "string"), "") == 0);
4047
cfg_free(cfg);
48+
# endif
49+
#endif
50+
51+
fclose(f);
4152

4253
return 0;
4354
}

tests/print_filter.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,32 @@ int main(void)
3939
cfg_set_print_filter_func(cfg, no_foo);
4040
f = fmemopen(buf, sizeof(buf), "w+");
4141
fail_unless(f != NULL);
42-
cfg_print(cfg, f);
42+
fail_unless(cfg_print(cfg, f) == CFG_SUCCESS);
4343
fclose(f);
4444

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

4956
cfg_set_print_filter_func(cfg, no_bar);
5057
f = fmemopen(buf, sizeof(buf), "w+");
5158
fail_unless(f != NULL);
52-
cfg_print(cfg, f);
59+
fail_unless(cfg_print(cfg, f) == CFG_SUCCESS);
5360
fclose(f);
5461

5562
fprintf(stderr, "----\n");
5663
fprintf(stderr, "no_bar filter:\n%s", buf);
5764
fail_unless(strstr(buf, "foo-") != NULL);
5865
fail_unless(strstr(buf, "bar-") == NULL);
66+
# endif
67+
#endif
5968

6069
cfg_free(cfg);
6170

0 commit comments

Comments
 (0)