/
niceSOFT
/
libconfuse
Обзор
Документация
Войти
/
niceSOFT
/
libconfuse
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tests/empty_string.c
62 строки
1 KB
Christian Göttsche
tests: skip test with broken fmemopen under sanitizers
18 июл 2026, 11:28
Не верифицирован
18 июл 2026, 11:28
00e4557
Код
Авторство
О чём код?
#include "check_confuse.h" #include <stdio.h> #include <string.h> #ifndef HAVE_FMEMOPEN extern FILE *fmemopen(void *buf, size_t size, const char *type); #endif #ifndef __has_feature # define __has_feature(x) 0 #endif int main(void) { cfg_opt_t opts[] = { CFG_STR("string", "hello", CFGF_NONE), CFG_END() }; cfg_t *cfg; char buf[100]; /* should be enough */ FILE *f; /* * override the default with a config with an empty string * and then generate a temporary config file with that */ cfg = cfg_init(opts, 0); fail_unless(cfg_parse_buf(cfg, "string = ''") == CFG_SUCCESS); fail_unless(strcmp(cfg_getstr(cfg, "string"), "") == 0); f = fmemopen(buf, sizeof(buf), "w+"); fail_unless(f != NULL); fail_unless(cfg_print(cfg, f) == CFG_SUCCESS); cfg_free(cfg); #if __has_feature(address_sanitizer) || __has_feature(memory_sanitizer) || defined(__SANITIZE_ADDRESS__) /* 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 */ cfg = cfg_init(opts, 0); fail_unless(cfg != NULL); fail_unless(fseek(f, 0L, SEEK_SET) == 0); fail_unless(cfg_parse_fp(cfg, f) == CFG_SUCCESS); fail_unless(strcmp(cfg_getstr(cfg, "string"), "") == 0); cfg_free(cfg); #endif fclose(f); return 0; } /** * Local Variables: * indent-tabs-mode: t * c-file-style: "linux" * End: */