1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855
|
/*
* Copyright 2014 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <bson.h>
#include <mongoc.h>
#include <assert.h>
#include <fcntl.h>
#include <stdarg.h>
#include "mongoc-log.h"
#include "mongoc-log-private.h"
#if defined(__APPLE__)
# include <mach/mach_time.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if !defined(_WIN32)
# include <sys/types.h>
# include <inttypes.h>
# include <sys/utsname.h>
# include <sys/wait.h>
# include <unistd.h>
# include <sys/time.h>
#else
# include <windows.h>
#endif
#if defined(BSON_HAVE_CLOCK_GETTIME)
# include <time.h>
# include <sys/time.h>
#endif
#include "test-libmongoc.h"
#include "TestSuite.h"
#define TEST_VERBOSE (1 << 0)
#define TEST_NOFORK (1 << 1)
#define TEST_HELPONLY (1 << 2)
#define TEST_NOTHREADS (1 << 3)
#define TEST_DEBUGOUTPUT (1 << 4)
#define TEST_TRACE (1 << 5)
#define NANOSEC_PER_SEC 1000000000UL
#if !defined(_WIN32)
# include <pthread.h>
# define Mutex pthread_mutex_t
# define Mutex_Init(_n) pthread_mutex_init((_n), NULL)
# define Mutex_Lock pthread_mutex_lock
# define Mutex_Unlock pthread_mutex_unlock
# define Mutex_Destroy pthread_mutex_destroy
# define Thread pthread_t
# define Thread_Create(_t,_f,_d) pthread_create((_t), NULL, (_f), (_d))
# define Thread_Join(_n) pthread_join((_n), NULL)
#else
# define Mutex CRITICAL_SECTION
# define Mutex_Init InitializeCriticalSection
# define Mutex_Lock EnterCriticalSection
# define Mutex_Unlock LeaveCriticalSection
# define Mutex_Destroy DeleteCriticalSection
# define Thread HANDLE
# define Thread_Join(_n) WaitForSingleObject ((_n), INFINITE)
# define strdup _strdup
#endif
#if !defined(Memory_Barrier)
# define Memory_Barrier() bson_memory_barrier()
#endif
# define AtomicInt_DecrementAndTest(p) (bson_atomic_int_add(p, -1) == 0)
#if defined(_MSC_VER)
struct timespec
{
time_t tv_sec;
long tv_nsec;
};
#endif
#if defined(_WIN32)
static int
Thread_Create (Thread *thread,
void *(*cb)(void *),
void *arg)
{
*thread = CreateThread (NULL, 0, (void *)cb, arg, 0, NULL);
return 0;
}
#endif
#if defined(_WIN32) && !defined(BSON_HAVE_SNPRINTF)
static int
snprintf (char *str,
size_t size,
const char *format,
...)
{
int r = -1;
va_list ap;
va_start (ap, format);
if (size != 0) {
r = _vsnprintf_s (str, size, _TRUNCATE, format, ap);
}
if (r == -1) {
r = _vscprintf (format, ap);
}
va_end (ap);
return r;
}
#endif
void
_Print_StdOut (const char *format,
...)
{
va_list ap;
va_start (ap, format);
vprintf (format, ap);
fflush (stdout);
va_end (ap);
}
void
_Print_StdErr (const char *format,
...)
{
va_list ap;
va_start (ap, format);
vfprintf (stderr, format, ap);
fflush (stderr);
va_end (ap);
}
void
_Clock_GetMonotonic (struct timespec *ts) /* OUT */
{
#if defined(BSON_HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
clock_gettime (CLOCK_MONOTONIC, ts);
#elif defined(__APPLE__)
static mach_timebase_info_data_t info = { 0 };
static double ratio;
uint64_t atime;
if (!info.denom) {
mach_timebase_info(&info);
ratio = info.numer / info.denom;
}
atime = mach_absolute_time() * ratio;
ts->tv_sec = atime * 1e-9;
ts->tv_nsec = atime - (ts->tv_sec * 1e9);
#elif defined(_WIN32)
ULONGLONG ticks = GetTickCount64 ();
ts->tv_sec = ticks / NANOSEC_PER_SEC;
ts->tv_nsec = ticks % NANOSEC_PER_SEC;
#else
# warning "Monotonic clock is not yet supported on your platform."
#endif
}
void
_Clock_Subtract (struct timespec *ts, /* OUT */
struct timespec *x, /* IN */
struct timespec *y) /* IN */
{
struct timespec r;
ASSERT (x);
ASSERT (y);
r.tv_sec = (x->tv_sec - y->tv_sec);
if ((r.tv_nsec = (x->tv_nsec - y->tv_nsec)) < 0) {
r.tv_nsec += NANOSEC_PER_SEC;
r.tv_sec -= 1;
}
*ts = r;
}
static void
TestSuite_SeedRand (TestSuite *suite, /* IN */
Test *test) /* IN */
{
#ifndef BSON_OS_WIN32
int fd = open ("/dev/urandom", O_RDONLY);
int n_read;
unsigned seed;
if (fd != -1) {
n_read = read (fd, &seed, 4);
assert (n_read == 4);
close (fd);
test->seed = seed;
return;
} else {
test->seed = (unsigned)time (NULL) * (unsigned)getpid ();
}
#else
test->seed = (unsigned)time (NULL);
#endif
}
void
TestSuite_Init (TestSuite *suite,
const char *name,
int argc,
char **argv)
{
const char *filename;
int i;
memset (suite, 0, sizeof *suite);
suite->name = strdup (name);
suite->flags = 0;
suite->prgname = strdup (argv [0]);
for (i = 0; i < argc; i++) {
if (0 == strcmp ("-v", argv [i])) {
suite->flags |= TEST_VERBOSE;
} else if (0 == strcmp ("-d", argv [i])) {
suite->flags |= TEST_DEBUGOUTPUT;
} else if (0 == strcmp ("-f", argv [i])) {
suite->flags |= TEST_NOFORK;
} else if (0 == strcmp ("-p", argv [i])) {
suite->flags |= TEST_NOTHREADS;
} else if ((0 == strcmp ("-t", argv [i])) ||
(0 == strcmp ("--trace", argv [i]))) {
#ifdef MONGOC_TRACE
suite->flags |= TEST_TRACE;
#else
_Print_StdErr ("-t requires mongoc compiled with --enable-tracing.\n");
exit (EXIT_FAILURE);
#endif
} else if (0 == strcmp ("-F", argv [i])) {
if (argc - 1 == i) {
_Print_StdErr ("-F requires a filename argument.\n");
exit (EXIT_FAILURE);
}
filename = argv [++i];
if (0 != strcmp ("-", filename)) {
#ifdef _WIN32
if (0 != fopen_s (&suite->outfile, filename, "w")) {
suite->outfile = NULL;
}
#else
suite->outfile = fopen (filename, "w");
#endif
if (!suite->outfile) {
_Print_StdErr ("Failed to open log file: %s\n", filename);
}
}
} else if ((0 == strcmp ("-h", argv [i])) ||
(0 == strcmp ("--help", argv [i]))) {
suite->flags |= TEST_HELPONLY;
} else if ((0 == strcmp ("-l", argv [i]))) {
if (argc - 1 == i) {
_Print_StdErr ("-l requires an argument.\n");
exit (EXIT_FAILURE);
}
suite->testname = strdup (argv [++i]);
}
}
}
static int
TestSuite_CheckDummy (void)
{
return 1;
}
static void
TestSuite_AddHelper (void *cb_)
{
TestFunc cb = (TestFunc)cb_;
cb();
}
void
TestSuite_Add (TestSuite *suite, /* IN */
const char *name, /* IN */
TestFunc func) /* IN */
{
TestSuite_AddFull (suite, name, TestSuite_AddHelper, NULL, (void *)func, TestSuite_CheckDummy);
}
void
TestSuite_AddWC (TestSuite *suite, /* IN */
const char *name, /* IN */
TestFuncWC func, /* IN */
TestFuncDtor dtor, /* IN */
void *ctx) /* IN */
{
TestSuite_AddFull (suite, name, func, dtor, ctx, TestSuite_CheckDummy);
}
void
TestSuite_AddFull (TestSuite *suite, /* IN */
const char *name, /* IN */
TestFuncWC func, /* IN */
TestFuncDtor dtor, /* IN */
void *ctx,
int (*check) (void)) /* IN */
{
Test *test;
Test *iter;
test = (Test *)calloc (1, sizeof *test);
test->name = strdup (name);
test->func = func;
test->check = check;
test->next = NULL;
test->dtor = dtor;
test->ctx = ctx;
TestSuite_SeedRand (suite, test);
if (!suite->tests) {
suite->tests = test;
return;
}
for (iter = suite->tests; iter->next; iter = iter->next) { }
iter->next = test;
}
#if !defined(_WIN32)
static int
TestSuite_RunFuncInChild (TestSuite *suite, /* IN */
Test *test) /* IN */
{
pid_t child;
int exit_code = -1;
int fd;
if (suite->outfile) {
fflush (suite->outfile);
}
if (-1 == (child = fork())) {
return -1;
}
if (!child) {
if (suite->outfile) {
fclose (suite->outfile);
suite->outfile = NULL;
}
fd = open ("/dev/null", O_WRONLY);
dup2 (fd, STDOUT_FILENO);
close (fd);
srand (test->seed);
test->func (test->ctx);
TestSuite_Destroy (suite);
exit (0);
}
if (-1 == waitpid (child, &exit_code, 0)) {
perror ("waitpid()");
}
return exit_code;
}
#endif
static int
TestSuite_RunTest (TestSuite *suite, /* IN */
Test *test, /* IN */
Mutex *mutex, /* IN */
int *count) /* INOUT */
{
struct timespec ts1;
struct timespec ts2;
struct timespec ts3;
char name[MAX_TEST_NAME_LENGTH];
char buf[MAX_TEST_NAME_LENGTH + 500];
int status = 0;
snprintf (name, sizeof name, "%s%s", suite->name, test->name);
name [sizeof name - 1] = '\0';
if (!test->check || test->check ()) {
_Clock_GetMonotonic (&ts1);
/*
* TODO: If not verbose, close()/dup(/dev/null) for stdout.
*/
/* Tracing is superduper slow */
#ifdef MONGOC_TRACE
if (suite->flags & TEST_TRACE) {
mongoc_log_set_handler (mongoc_log_default_handler, NULL);
mongoc_log_trace_enable ();
} else {
mongoc_log_trace_disable ();
}
#endif
#if defined(_WIN32)
srand (test->seed);
if (suite->flags & TEST_DEBUGOUTPUT) {
_Print_StdOut ("Begin %s\n", name);
}
test->func (test->ctx);
status = 0;
#else
if (suite->flags & TEST_DEBUGOUTPUT) {
_Print_StdOut ("Begin %s\n", name);
}
if ((suite->flags & TEST_NOFORK)) {
srand (test->seed);
test->func (test->ctx);
status = 0;
} else {
status = TestSuite_RunFuncInChild (suite, test);
}
#endif
_Clock_GetMonotonic (&ts2);
_Clock_Subtract (&ts3, &ts2, &ts1);
Mutex_Lock (mutex);
snprintf (buf, sizeof buf,
" { \"status\": \"%s\", "
"\"name\": \"%s\", "
"\"seed\": \"%u\", "
"\"elapsed\": %u.%09u }%s\n",
(status == 0) ? "PASS" : "FAIL",
name,
test->seed,
(unsigned)ts3.tv_sec,
(unsigned)ts3.tv_nsec,
((*count) == 1) ? "" : ",");
buf [sizeof buf - 1] = 0;
_Print_StdOut ("%s", buf);
if (suite->outfile) {
fprintf (suite->outfile, "%s", buf);
fflush (suite->outfile);
}
Mutex_Unlock (mutex);
} else {
status = 0;
Mutex_Lock (mutex);
snprintf (buf, sizeof buf,
" { \"status\": \"SKIP\", \"name\": \"%s\" },\n",
test->name);
buf [sizeof buf - 1] = '\0';
_Print_StdOut ("%s", buf);
if (suite->outfile) {
fprintf (suite->outfile, "%s", buf);
fflush (suite->outfile);
}
Mutex_Unlock (mutex);
}
return status ? 1 : 0;
}
static void
TestSuite_PrintHelp (TestSuite *suite, /* IN */
FILE *stream) /* IN */
{
Test *iter;
fprintf (stream,
"usage: %s [OPTIONS]\n"
"\n"
"Options:\n"
" -h, --help Show this help menu.\n"
" -f Do not fork() before running tests.\n"
" -l NAME Run test by name, e.g. \"/Client/command\" or \"/Client/*\".\n"
" -p Do not run tests in parallel.\n"
" -v Be verbose with logs.\n"
" -F FILENAME Write test results (JSON) to FILENAME.\n"
" -d Print debug output (useful if a test hangs).\n"
" -t, --trace Enable mongoc tracing (useful to debug tests).\n"
"\n"
"Tests:\n",
suite->prgname);
for (iter = suite->tests; iter; iter = iter->next) {
fprintf (stream, " %s%s\n", suite->name, iter->name);
}
fprintf (stream, "\n");
}
static void
TestSuite_PrintJsonHeader (TestSuite *suite, /* IN */
FILE *stream) /* IN */
{
char *uri_str = test_framework_get_uri_str ();
#ifdef _WIN32
# define INFO_BUFFER_SIZE 32767
SYSTEM_INFO si;
DWORD version = 0;
DWORD major_version = 0;
DWORD minor_version = 0;
DWORD build = 0;
GetSystemInfo(&si);
version = GetVersion();
major_version = (DWORD)(LOBYTE(LOWORD(version)));
minor_version = (DWORD)(HIBYTE(LOWORD(version)));
if (version < 0x80000000) {
build = (DWORD)(HIWORD(version));
}
fprintf (stream,
"{\n"
" \"uri\": \"%s\",\n"
" \"is_mongos\": \"%s\",\n"
" \"host\": {\n"
" \"sysname\": \"Windows\",\n"
" \"release\": \"%ld.%ld (%ld)\",\n"
" \"machine\": \"%ld\",\n"
" \"memory\": {\n"
" \"pagesize\": %ld,\n"
" \"npages\": %d\n"
" }\n"
" },\n"
" \"options\": {\n"
" \"parallel\": \"%s\",\n"
" \"fork\": \"%s\"\n"
" \"tracing\": \"%s\"\n"
" },\n"
" \"tests\": [\n",
uri_str,
test_framework_is_mongos () ? "true" : "false",
major_version, minor_version, build,
si.dwProcessorType,
si.dwPageSize,
0,
(suite->flags & TEST_NOTHREADS) ? "false" : "true",
(suite->flags & TEST_NOFORK) ? "false" : "true",
(suite->flags & TEST_TRACE) ? "true" : "false");
#else
struct utsname u;
uint64_t pagesize;
uint64_t npages = 0;
ASSERT (suite);
if (uname (&u) == -1) {
perror ("uname()");
return;
}
pagesize = sysconf (_SC_PAGE_SIZE);
# if defined(_SC_PHYS_PAGES)
npages = sysconf (_SC_PHYS_PAGES);
# endif
fprintf (stream,
"{\n"
" \"uri\": \"%s\",\n"
" \"is_mongos\": \"%s\",\n"
" \"host\": {\n"
" \"sysname\": \"%s\",\n"
" \"release\": \"%s\",\n"
" \"machine\": \"%s\",\n"
" \"memory\": {\n"
" \"pagesize\": %"PRIu64",\n"
" \"npages\": %"PRIu64"\n"
" }\n"
" },\n"
" \"options\": {\n"
" \"parallel\": \"%s\",\n"
" \"fork\": \"%s\"\n"
" \"tracing\": \"%s\"\n"
" },\n"
" \"tests\": [\n",
uri_str,
test_framework_is_mongos () ? "true" : "false",
u.sysname,
u.release,
u.machine,
pagesize,
npages,
(suite->flags & TEST_NOTHREADS) ? "false" : "true",
(suite->flags & TEST_NOFORK) ? "false" : "true",
(suite->flags & TEST_TRACE) ? "true" : "false");
#endif
fflush (stream);
bson_free (uri_str);
}
static void
TestSuite_PrintJsonFooter (FILE *stream) /* IN */
{
fprintf (stream, " ]\n}\n");
fflush (stream);
}
typedef struct
{
TestSuite *suite;
Test *test;
Mutex *mutex;
int *count;
} ParallelInfo;
static void *
TestSuite_ParallelWorker (void *data) /* IN */
{
ParallelInfo *info = (ParallelInfo *)data;
int status;
ASSERT (info);
status = TestSuite_RunTest (info->suite, info->test, info->mutex, info->count);
if (AtomicInt_DecrementAndTest (info->count)) {
TestSuite_PrintJsonFooter (stdout);
if (info->suite->outfile) {
TestSuite_PrintJsonFooter (info->suite->outfile);
}
exit (status);
}
return NULL;
}
static void
TestSuite_RunParallel (TestSuite *suite) /* IN */
{
ParallelInfo *info;
Thread *threads;
Mutex mutex;
Test *test;
int count = 0;
int i;
ASSERT (suite);
Mutex_Init (&mutex);
for (test = suite->tests; test; test = test->next) {
count++;
}
threads = (Thread *)calloc (count, sizeof *threads);
Memory_Barrier ();
for (test = suite->tests, i = 0; test; test = test->next, i++) {
info = (ParallelInfo *)calloc (1, sizeof *info);
info->suite = suite;
info->test = test;
info->count = &count;
info->mutex = &mutex;
Thread_Create (&threads [i], TestSuite_ParallelWorker, info);
}
#ifdef _WIN32
Sleep (30000);
#else
sleep (30);
#endif
_Print_StdErr ("Timed out, aborting!\n");
abort ();
}
static int
TestSuite_RunSerial (TestSuite *suite) /* IN */
{
Test *test;
Mutex mutex;
int count = 0;
int status = 0;
Mutex_Init (&mutex);
for (test = suite->tests; test; test = test->next) {
count++;
}
for (test = suite->tests; test; test = test->next) {
status += TestSuite_RunTest (suite, test, &mutex, &count);
count--;
}
TestSuite_PrintJsonFooter (stdout);
if (suite->outfile) {
TestSuite_PrintJsonFooter (suite->outfile);
}
Mutex_Destroy (&mutex);
return status;
}
static int
TestSuite_RunNamed (TestSuite *suite, /* IN */
const char *testname) /* IN */
{
Mutex mutex;
char name[128];
Test *test;
int count = 1;
bool star = strlen (testname) && testname[strlen (testname) - 1] == '*';
bool match;
int status = 0;
ASSERT (suite);
ASSERT (testname);
Mutex_Init (&mutex);
for (test = suite->tests; test; test = test->next) {
snprintf (name, sizeof name, "%s%s",
suite->name, test->name);
name [sizeof name - 1] = '\0';
if (star) {
/* e.g. testname is "/Client*" and name is "/Client/authenticate" */
match = (0 == strncmp (name, testname, strlen (testname) - 1));
} else {
match = (0 == strcmp (name, testname));
}
if (match) {
status += TestSuite_RunTest (suite, test, &mutex, &count);
}
}
TestSuite_PrintJsonFooter (stdout);
if (suite->outfile) {
TestSuite_PrintJsonFooter (suite->outfile);
}
Mutex_Destroy (&mutex);
return status;
}
int
TestSuite_Run (TestSuite *suite) /* IN */
{
int failures = 0;
if ((suite->flags & TEST_HELPONLY)) {
TestSuite_PrintHelp (suite, stderr);
return 0;
}
TestSuite_PrintJsonHeader (suite, stdout);
if (suite->outfile) {
TestSuite_PrintJsonHeader (suite, suite->outfile);
}
if (suite->tests) {
if (suite->testname) {
failures += TestSuite_RunNamed (suite, suite->testname);
} else if ((suite->flags & TEST_NOTHREADS)) {
failures += TestSuite_RunSerial (suite);
} else {
TestSuite_RunParallel (suite);
}
} else {
TestSuite_PrintJsonFooter (stdout);
if (suite->outfile) {
TestSuite_PrintJsonFooter (suite->outfile);
}
}
return failures;
}
void
TestSuite_Destroy (TestSuite *suite)
{
Test *test;
Test *tmp;
for (test = suite->tests; test; test = tmp) {
tmp = test->next;
if (test->dtor) {
test->dtor(test->ctx);
}
free (test->name);
free (test);
}
if (suite->outfile) {
fclose (suite->outfile);
}
free (suite->name);
free (suite->prgname);
free (suite->testname);
}
|