int main(void) { char *result = NULL; plan(12); is_int(7, test_asprintf(&result, "%s", "testing"), "asprintf length"); is_string("testing", result, "asprintf result"); free(result); ok(3, "free asprintf"); is_int(0, test_asprintf(&result, "%s", ""), "asprintf empty length"); is_string("", result, "asprintf empty string"); free(result); ok(6, "free asprintf of empty string"); is_int(6, vatest(&result, "%d %s", 2, "test"), "vasprintf length"); is_string("2 test", result, "vasprintf result"); free(result); ok(9, "free vasprintf"); is_int(0, vatest(&result, "%s", ""), "vasprintf empty length"); is_string("", result, "vasprintf empty string"); free(result); ok(12, "free vasprintf of empty string"); return 0; }
int main (int argc, char *argv[]) { test_vasprintf (); test_asprintf (); return 0; }
int main(int argc, char **argv) { grpc_test_init(argc, argv); test_strdup(); test_hexdump(); test_parse_uint32(); test_asprintf(); return 0; }
bool torture_local_replace(struct torture_context *ctx) { bool ret = true; ret &= test_ftruncate(); ret &= test_strlcpy(); ret &= test_strlcat(); ret &= test_mktime(); ret &= test_initgroups(); ret &= test_memmove(); ret &= test_strdup(); ret &= test_setlinebuf(); ret &= test_vsyslog(); ret &= test_timegm(); ret &= test_setenv(); ret &= test_strndup(); ret &= test_strnlen(); ret &= test_waitpid(); ret &= test_seteuid(); ret &= test_setegid(); ret &= test_asprintf(); ret &= test_snprintf(); ret &= test_vasprintf(); ret &= test_vsnprintf(); ret &= test_opendir(); ret &= test_readdir(); ret &= test_telldir(); ret &= test_seekdir(); ret &= test_dlopen(); ret &= test_chroot(); ret &= test_bzero(); ret &= test_strerror(); ret &= test_errno(); ret &= test_mkdtemp(); ret &= test_mkstemp(); ret &= test_pread(); ret &= test_pwrite(); ret &= test_getpass(); ret &= test_inet_ntoa(); ret &= test_strtoll(); ret &= test_strtoull(); ret &= test_va_copy(); ret &= test_FUNCTION(); ret &= test_MIN(); ret &= test_MAX(); ret &= test_socketpair(); ret &= test_strptime(); ret &= test_getifaddrs(); ret &= test_utime(); ret &= test_utimes(); ret &= test_memmem(); return ret; }
int main(int argc, char **argv) { grpc_test_init(argc, argv); test_strdup(); test_dump(); test_dump_slice(); test_parse_uint32(); test_asprintf(); test_strjoin(); test_strjoin_sep(); test_strsplit(); return 0; }
int main(int argc, char **argv) { grpc_test_init(argc, argv); test_strdup(); test_dump(); test_parse_uint32(); test_asprintf(); test_strjoin(); test_strjoin_sep(); test_ltoa(); test_int64toa(); test_leftpad(); test_stricmp(); return 0; }
/* * Take the amount of memory to allocate in bytes as a command-line argument * and call test_malloc with that amount of memory. */ int main(int argc, char *argv[]) { size_t size, max; size_t limit = 0; int willfail = 0; unsigned char code; if (argc < 3) die("Usage error. Type, size, and limit must be given."); errno = 0; size = strtol(argv[2], 0, 10); if (size == 0 && errno != 0) sysdie("Invalid size"); errno = 0; limit = strtol(argv[3], 0, 10); if (limit == 0 && errno != 0) sysdie("Invalid limit"); /* If the code is capitalized, install our customized error handler. */ code = argv[1][0]; if (isupper(code)) { xmalloc_error_handler = test_handler; code = tolower(code); } /* * Decide if the allocation should fail. If it should, set willfail to 2, * so that if it unexpectedly succeeds, we exit with a status indicating * that the test should be skipped. */ max = size; if (code == 's' || code == 'n' || code == 'a' || code == 'v') { max += size; if (limit > 0) limit += size; } if (limit > 0 && max > limit) willfail = 2; /* * If a memory limit was given and we can set memory limits, set it. * Otherwise, exit 2, signalling to the driver that the test should be * skipped. We do this here rather than in the driver due to some * pathological problems with Linux (setting ulimit in the shell caused * the shell to die). */ if (limit > 0) { #if HAVE_SETRLIMIT && defined(RLIMIT_AS) struct rlimit rl; void *tmp; size_t test_size; rl.rlim_cur = limit; rl.rlim_max = limit; if (setrlimit(RLIMIT_AS, &rl) < 0) { syswarn("Can't set data limit to %lu", (unsigned long) limit); exit(2); } if (size < limit || code == 'r') { test_size = code == 'r' ? 10 : size; if (test_size == 0) test_size = 1; tmp = malloc(test_size); if (tmp == NULL) { syswarn("Can't allocate initial memory of %lu (limit %lu)", (unsigned long) test_size, (unsigned long) limit); exit(2); } free(tmp); } #else warn("Data limits aren't supported."); exit(2); #endif } switch (code) { case 'c': exit(test_calloc(size) ? willfail : 1); case 'm': exit(test_malloc(size) ? willfail : 1); case 'r': exit(test_realloc(size) ? willfail : 1); case 's': exit(test_strdup(size) ? willfail : 1); case 'n': exit(test_strndup(size) ? willfail : 1); case 'a': exit(test_asprintf(size) ? willfail : 1); case 'v': exit(test_vasprintf(size) ? willfail : 1); default: die("Unknown mode %c", argv[1][0]); break; } exit(1); }