ccanlint.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. /*
  2. * ccanlint: assorted checks and advice for a ccan package
  3. * Copyright (C) 2008 Rusty Russell, Idris Soule
  4. * Copyright (C) 2010 Rusty Russell, Idris Soule
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  13. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program; if not, write to the Free Software Foundation, Inc., 51
  18. * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #include "ccanlint.h"
  21. #include "../tools.h"
  22. #include "../read_config_header.h"
  23. #include <unistd.h>
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #include <err.h>
  28. #include <ctype.h>
  29. #include <ccan/str/str.h>
  30. #include <ccan/take/take.h>
  31. #include <ccan/opt/opt.h>
  32. #include <ccan/foreach/foreach.h>
  33. #include <ccan/cast/cast.h>
  34. #include <ccan/tlist/tlist.h>
  35. #include <ccan/tal/path/path.h>
  36. #include <ccan/strmap/strmap.h>
  37. typedef STRMAP(struct ccanlint *) ccanlint_map_t;
  38. int verbose = 0;
  39. static ccanlint_map_t tests;
  40. bool safe_mode = false;
  41. bool keep_results = false;
  42. bool non_ccan_deps = false;
  43. bool build_failed = false;
  44. static bool targeting = false;
  45. static unsigned int timeout;
  46. const char *config_header;
  47. const char *ccan_dir;
  48. #if 0
  49. static void indent_print(const char *string)
  50. {
  51. while (*string) {
  52. unsigned int line = strcspn(string, "\n");
  53. printf("\t%.*s", line, string);
  54. if (string[line] == '\n') {
  55. printf("\n");
  56. line++;
  57. }
  58. string += line;
  59. }
  60. }
  61. #endif
  62. bool ask(const char *question)
  63. {
  64. char reply[80];
  65. printf("%s ", question);
  66. fflush(stdout);
  67. return fgets(reply, sizeof(reply), stdin) != NULL
  68. && toupper(reply[0]) == 'Y';
  69. }
  70. /* Skip, but don't remove. */
  71. static bool skip_test(struct dgraph_node *node, const char *why)
  72. {
  73. struct ccanlint *c = container_of(node, struct ccanlint, node);
  74. c->skip = why;
  75. return true;
  76. }
  77. static const char *dep_failed(struct manifest *m UNNEEDED)
  78. {
  79. return "dependency couldn't run";
  80. }
  81. static bool cannot_run(struct dgraph_node *node, void *all UNNEEDED)
  82. {
  83. struct ccanlint *c = container_of(node, struct ccanlint, node);
  84. c->can_run = dep_failed;
  85. return true;
  86. }
  87. struct run_info {
  88. bool noninteractive;
  89. unsigned int score, total;
  90. struct manifest *m;
  91. const char *prefix;
  92. bool pass;
  93. };
  94. static bool run_test(struct dgraph_node *n, struct run_info *run)
  95. {
  96. struct ccanlint *i = container_of(n, struct ccanlint, node);
  97. unsigned int timeleft;
  98. struct score *score;
  99. if (i->done)
  100. return true;
  101. score = tal(run->m, struct score);
  102. list_head_init(&score->per_file_errors);
  103. score->error = NULL;
  104. score->pass = false;
  105. score->score = 0;
  106. score->total = 1;
  107. /* We can see skipped things in two cases:
  108. * (1) _info excluded them (presumably because they fail).
  109. * (2) A prerequisite failed.
  110. */
  111. if (i->skip) {
  112. if (verbose)
  113. printf("%s%s: skipped (%s)\n",
  114. run->prefix, i->name, i->skip);
  115. /* Pass us up to the test which failed, not us. */
  116. score->pass = true;
  117. goto out;
  118. }
  119. if (i->can_run) {
  120. i->skip = i->can_run(run->m);
  121. if (i->skip) {
  122. /* Test doesn't apply, or can't run? That's OK. */
  123. if (verbose > 1)
  124. printf("%s%s: skipped (%s)\n",
  125. run->prefix, i->name, i->skip);
  126. /* Mark our dependencies to skip. */
  127. dgraph_traverse_from(&i->node, cannot_run, NULL);
  128. score->pass = true;
  129. score->total = 0;
  130. goto out;
  131. }
  132. }
  133. timeleft = timeout ? timeout : default_timeout_ms;
  134. i->check(run->m, &timeleft, score);
  135. if (timeout && timeleft == 0) {
  136. i->skip = "timeout";
  137. if (verbose)
  138. printf("%s%s: skipped (%s)\n",
  139. run->prefix, i->name, i->skip);
  140. /* Mark our dependencies to skip. */
  141. dgraph_traverse_from(&i->node, skip_test,
  142. "dependency timed out");
  143. score->pass = true;
  144. score->total = 0;
  145. goto out;
  146. }
  147. assert(score->score <= score->total);
  148. if (!score->pass
  149. || (score->score < score->total && verbose)
  150. || verbose > 1) {
  151. printf("%s%s (%s): %s",
  152. run->prefix, i->name, i->key,
  153. score->pass ? "PASS" : "FAIL");
  154. if (score->total > 1)
  155. printf(" (+%u/%u)", score->score, score->total);
  156. printf("\n");
  157. }
  158. if (!score->pass || verbose) {
  159. if (score->error) {
  160. printf("%s%s", score->error,
  161. strends(score->error, "\n") ? "" : "\n");
  162. }
  163. }
  164. if (!run->noninteractive && score->score < score->total && i->handle)
  165. i->handle(run->m, score);
  166. if (!score->pass) {
  167. /* Skip any tests which depend on this one. */
  168. dgraph_traverse_from(&i->node, skip_test, "dependency failed");
  169. }
  170. out:
  171. run->score += score->score;
  172. run->total += score->total;
  173. /* FIXME: Free score. */
  174. run->pass &= score->pass;
  175. i->done = true;
  176. if (!score->pass && i->compulsory) {
  177. warnx("%s%s failed", run->prefix, i->name);
  178. run->score = 0;
  179. return false;
  180. }
  181. return true;
  182. }
  183. static void register_test(struct ccanlint *test)
  184. {
  185. if (!strmap_add(&tests, test->key, test))
  186. err(1, "Adding test %s", test->key);
  187. test->options = tal_arr(NULL, char *, 1);
  188. test->options[0] = NULL;
  189. dgraph_init_node(&test->node);
  190. }
  191. static bool get_test(const char *member UNNEEDED, struct ccanlint *i,
  192. struct ccanlint **ret)
  193. {
  194. if (tlist_empty(&i->node.edge[DGRAPH_TO])) {
  195. *ret = i;
  196. return false;
  197. }
  198. return true;
  199. }
  200. /**
  201. * get_next_test - retrieves the next test to be processed
  202. **/
  203. static inline struct ccanlint *get_next_test(void)
  204. {
  205. struct ccanlint *i = NULL;
  206. strmap_iterate(&tests, get_test, &i);
  207. if (i)
  208. return i;
  209. if (strmap_empty(&tests))
  210. return NULL;
  211. errx(1, "Can't make process; test dependency cycle");
  212. }
  213. static struct ccanlint *find_test(const char *key)
  214. {
  215. return strmap_get(&tests, key);
  216. }
  217. bool is_excluded(const char *name)
  218. {
  219. return find_test(name)->skip != NULL;
  220. }
  221. static bool init_deps(const char *member UNNEEDED,
  222. struct ccanlint *c, void *unused UNNEEDED)
  223. {
  224. char **deps = tal_strsplit(NULL, c->needs, " ", STR_EMPTY_OK);
  225. unsigned int i;
  226. for (i = 0; deps[i]; i++) {
  227. struct ccanlint *dep;
  228. dep = find_test(deps[i]);
  229. if (!dep)
  230. errx(1, "BUG: unknown dep '%s' for %s",
  231. deps[i], c->key);
  232. dgraph_add_edge(&dep->node, &c->node);
  233. }
  234. tal_free(deps);
  235. return true;
  236. }
  237. static bool check_names(const char *member UNNEEDED, struct ccanlint *c,
  238. ccanlint_map_t *names)
  239. {
  240. if (!strmap_add(names, c->name, c))
  241. err(1, "Duplicate name %s", c->name);
  242. return true;
  243. }
  244. static void init_tests(void)
  245. {
  246. ccanlint_map_t names;
  247. struct ccanlint **table;
  248. size_t i, num;
  249. strmap_init(&tests);
  250. table = autodata_get(ccanlint_tests, &num);
  251. for (i = 0; i < num; i++)
  252. register_test(table[i]);
  253. autodata_free(table);
  254. strmap_iterate(&tests, init_deps, NULL);
  255. /* Check for duplicate names. */
  256. strmap_init(&names);
  257. strmap_iterate(&tests, check_names, &names);
  258. strmap_clear(&names);
  259. }
  260. static bool reset_test(struct dgraph_node *node, void *unused UNNEEDED)
  261. {
  262. struct ccanlint *c = container_of(node, struct ccanlint, node);
  263. c->skip = NULL;
  264. c->done = false;
  265. return true;
  266. }
  267. static void reset_tests(struct dgraph_node *all)
  268. {
  269. dgraph_traverse_to(all, reset_test, NULL);
  270. }
  271. static bool print_deps(const char *member UNNEEDED,
  272. struct ccanlint *c, void *unused UNNEEDED)
  273. {
  274. if (!tlist_empty(&c->node.edge[DGRAPH_FROM])) {
  275. struct dgraph_edge *e;
  276. printf("These depend on %s:\n", c->key);
  277. dgraph_for_each_edge(&c->node, e, DGRAPH_FROM) {
  278. struct ccanlint *to = container_of(e->n[DGRAPH_TO],
  279. struct ccanlint,
  280. node);
  281. printf("\t%s\n", to->key);
  282. }
  283. }
  284. return true;
  285. }
  286. static void print_test_depends(void)
  287. {
  288. printf("Tests:\n");
  289. strmap_iterate(&tests, print_deps, NULL);
  290. }
  291. static void show_tmpdir(const char *dir)
  292. {
  293. printf("You can find ccanlint working files in '%s'\n", dir);
  294. }
  295. static char *keep_tests(void *unused UNNEEDED)
  296. {
  297. keep_results = true;
  298. /* Don't automatically destroy temporary dir. */
  299. keep_temp_dir();
  300. tal_add_destructor(temp_dir(), show_tmpdir);
  301. return NULL;
  302. }
  303. static bool remove_test(struct dgraph_node *node, const char *why)
  304. {
  305. struct ccanlint *c = container_of(node, struct ccanlint, node);
  306. c->skip = why;
  307. dgraph_clear_node(node);
  308. return true;
  309. }
  310. static char *exclude_test(const char *testname, void *unused UNNEEDED)
  311. {
  312. struct ccanlint *i = find_test(testname);
  313. if (!i)
  314. return tal_fmt(NULL, "No test %s to --exclude", testname);
  315. /* Remove this, and everything which depends on it. */
  316. dgraph_traverse_from(&i->node, remove_test, "excluded on command line");
  317. remove_test(&i->node, "excluded on command line");
  318. return NULL;
  319. }
  320. static void skip_test_and_deps(struct ccanlint *c, const char *why)
  321. {
  322. /* Skip this, and everything which depends on us. */
  323. dgraph_traverse_from(&c->node, skip_test, why);
  324. skip_test(&c->node, why);
  325. }
  326. static char *list_tests(void *arg UNNEEDED)
  327. {
  328. struct ccanlint *i;
  329. printf("Tests:\n");
  330. /* This makes them print in topological order. */
  331. while ((i = get_next_test()) != NULL) {
  332. printf(" %-25s %s\n", i->key, i->name);
  333. dgraph_clear_node(&i->node);
  334. strmap_del(&tests, i->key, NULL);
  335. }
  336. exit(0);
  337. }
  338. static bool draw_test(const char *member UNNEEDED,
  339. struct ccanlint *c, const char *style)
  340. {
  341. /*
  342. * todo: escape labels in case ccanlint test keys have
  343. * characters interpreted as GraphViz syntax.
  344. */
  345. printf("\t\"%p\" [label=\"%s\"%s]\n", c, c->key, style);
  346. return true;
  347. }
  348. static void test_dgraph_vertices(const char *style)
  349. {
  350. strmap_iterate(&tests, draw_test, style);
  351. }
  352. static bool draw_edges(const char *member UNNEEDED,
  353. struct ccanlint *c, void *unused UNNEEDED)
  354. {
  355. struct dgraph_edge *e;
  356. dgraph_for_each_edge(&c->node, e, DGRAPH_FROM) {
  357. struct ccanlint *to = container_of(e->n[DGRAPH_TO],
  358. struct ccanlint,
  359. node);
  360. printf("\t\"%p\" -> \"%p\"\n", c->name, to->name);
  361. }
  362. return true;
  363. }
  364. static void test_dgraph_edges(void)
  365. {
  366. strmap_iterate(&tests, draw_edges, NULL);
  367. }
  368. static char *test_dependency_graph(void *arg UNNEEDED)
  369. {
  370. puts("digraph G {");
  371. test_dgraph_vertices("");
  372. test_dgraph_edges();
  373. puts("}");
  374. exit(0);
  375. }
  376. static void add_options(struct ccanlint *test, char **options,
  377. unsigned int num_options)
  378. {
  379. unsigned int num;
  380. if (!test->options)
  381. num = 0;
  382. else
  383. /* -1, because last one is NULL. */
  384. num = tal_count(test->options) - 1;
  385. tal_resize(&test->options, num + num_options + 1);
  386. memcpy(&test->options[num], options, (num_options + 1)*sizeof(char *));
  387. }
  388. void add_info_options(struct manifest *m)
  389. {
  390. unsigned int i;
  391. char **info_options = get_ccanlint(m, m->dir, get_or_compile_info);
  392. for (i = 0; info_options[i]; i++) {
  393. char **words = tal_strsplit(m, info_options[i], " \t",
  394. STR_NO_EMPTY);
  395. struct ccanlint *test;
  396. if (!words[0])
  397. continue;
  398. test = find_test(words[0]);
  399. if (!test) {
  400. warnx("%s: unknown ccanlint test '%s'",
  401. m->info_file->fullname, words[0]);
  402. continue;
  403. }
  404. if (!words[1]) {
  405. warnx("%s: no argument to test '%s'",
  406. m->info_file->fullname, words[0]);
  407. continue;
  408. }
  409. /* Known failure? */
  410. if (strcasecmp(words[1], "FAIL") == 0) {
  411. if (!targeting)
  412. skip_test_and_deps(test,
  413. "excluded in _info"
  414. " file");
  415. } else {
  416. if (!test->takes_options)
  417. warnx("%s: %s doesn't take options",
  418. m->info_file->fullname, words[0]);
  419. add_options(test, words+1, tal_count(words)-1);
  420. }
  421. }
  422. }
  423. /* If options are of form "filename:<option>" they only apply to that file */
  424. char **per_file_options(const struct ccanlint *test, struct ccan_file *f)
  425. {
  426. char **ret;
  427. unsigned int i, j = 0;
  428. /* Fast path. */
  429. if (!test->options[0])
  430. return test->options;
  431. ret = tal_arr(f, char *, tal_count(test->options));
  432. for (i = 0; test->options[i]; i++) {
  433. char *optname;
  434. if (!test->options[i] || !strchr(test->options[i], ':')) {
  435. optname = test->options[i];
  436. } else if (strstarts(test->options[i], f->name)
  437. && test->options[i][strlen(f->name)] == ':') {
  438. optname = test->options[i] + strlen(f->name) + 1;
  439. } else
  440. continue;
  441. /* FAIL overrides anything else. */
  442. if (streq(optname, "FAIL")) {
  443. ret = tal_arr(f, char *, 2);
  444. ret[0] = (char *)"FAIL";
  445. ret[1] = NULL;
  446. return ret;
  447. }
  448. ret[j++] = optname;
  449. }
  450. ret[j] = NULL;
  451. /* Shrink it to size so tal_array_length() works as expected. */
  452. tal_resize(&ret, j + 1);
  453. return ret;
  454. }
  455. static char *opt_set_const_charp(const char *arg, const char **p)
  456. {
  457. return opt_set_charp(arg, cast_const2(char **, p));
  458. }
  459. static char *opt_set_target(const char *arg, struct dgraph_node *all)
  460. {
  461. struct ccanlint *t = find_test(arg);
  462. if (!t)
  463. return tal_fmt(NULL, "unknown --target %s", arg);
  464. targeting = true;
  465. dgraph_add_edge(&t->node, all);
  466. return NULL;
  467. }
  468. static bool run_tests(struct dgraph_node *all,
  469. bool summary,
  470. bool deps_fail_ignore,
  471. struct manifest *m,
  472. const char *prefix)
  473. {
  474. struct run_info run;
  475. const char *comment = "";
  476. run.noninteractive = summary;
  477. run.m = m;
  478. run.prefix = prefix;
  479. run.score = run.total = 0;
  480. run.pass = true;
  481. non_ccan_deps = build_failed = false;
  482. dgraph_traverse_to(all, run_test, &run);
  483. /* We can completely fail if we're missing external stuff: ignore */
  484. if (deps_fail_ignore && non_ccan_deps && build_failed) {
  485. comment = " (missing non-ccan dependencies?)";
  486. run.pass = true;
  487. } else if (!run.pass) {
  488. comment = " FAIL!";
  489. }
  490. printf("%sTotal score: %u/%u%s\n",
  491. prefix, run.score, run.total, comment);
  492. return run.pass;
  493. }
  494. static bool add_to_all(const char *member UNNEEDED, struct ccanlint *c,
  495. struct dgraph_node *all)
  496. {
  497. /* If we're excluded on cmdline, don't add. */
  498. if (!c->skip)
  499. dgraph_add_edge(&c->node, all);
  500. return true;
  501. }
  502. static bool test_module(struct dgraph_node *all,
  503. const char *dir, const char *prefix, bool summary,
  504. bool deps_fail_ignore)
  505. {
  506. struct manifest *m = get_manifest(autofree(), dir);
  507. char *testlink = path_join(NULL, temp_dir(), "test");
  508. /* Create a symlink from temp dir back to src dir's
  509. * test directory. */
  510. unlink(testlink);
  511. if (symlink(path_join(m, dir, "test"), testlink) != 0)
  512. err(1, "Creating test symlink in %s", temp_dir());
  513. return run_tests(all, summary, deps_fail_ignore, m, prefix);
  514. }
  515. int main(int argc, char *argv[])
  516. {
  517. bool summary = false, pass = true, deps_fail_ignore = false;
  518. int i;
  519. const char *prefix = "";
  520. char *cwd = path_cwd(NULL), *dir;
  521. struct ccanlint top; /* cannot_run may try to set ->can_run */
  522. const char *override_compiler = NULL, *override_cflags = NULL;
  523. /* Empty graph node to which we attach everything else. */
  524. dgraph_init_node(&top.node);
  525. opt_register_early_noarg("--verbose|-v", opt_inc_intval, &verbose,
  526. "verbose mode (up to -vvvv)");
  527. opt_register_noarg("-n|--safe-mode", opt_set_bool, &safe_mode,
  528. "do not compile anything");
  529. opt_register_noarg("-l|--list-tests", list_tests, NULL,
  530. "list tests ccanlint performs (and exit)");
  531. opt_register_noarg("--test-dep-graph", test_dependency_graph, NULL,
  532. "print dependency graph of tests in Graphviz .dot format");
  533. opt_register_noarg("-k|--keep", keep_tests, NULL,
  534. "do not delete ccanlint working files");
  535. opt_register_noarg("--summary|-s", opt_set_bool, &summary,
  536. "give results only, no interactive correction");
  537. opt_register_arg("-x|--exclude <testname>", exclude_test, NULL, NULL,
  538. "exclude <testname> (can be used multiple times)");
  539. opt_register_arg("--timeout <milleseconds>", opt_set_uintval,
  540. NULL, &timeout,
  541. "ignore (terminate) tests that are slower than this");
  542. opt_register_arg("-t|--target <testname>", opt_set_target, NULL,
  543. &top.node,
  544. "only run one test (and its prerequisites)");
  545. opt_register_arg("--compiler <compiler>", opt_set_const_charp,
  546. NULL, &override_compiler, "set the compiler");
  547. opt_register_arg("--cflags <flags>", opt_set_const_charp,
  548. NULL, &override_cflags, "set the compiler flags");
  549. opt_register_noarg("--deps-fail-ignore", opt_set_bool,
  550. &deps_fail_ignore,
  551. "don't fail if external dependencies are missing");
  552. opt_register_noarg("-?|-h|--help", opt_usage_and_exit,
  553. "\nA program for checking and guiding development"
  554. " of CCAN modules.",
  555. "This usage message");
  556. /* Do verbose before anything else... */
  557. opt_early_parse(argc, argv, opt_log_stderr_exit);
  558. /* We move into temporary directory, so gcov dumps its files there. */
  559. if (chdir(temp_dir()) != 0)
  560. err(1, "Error changing to %s temporary dir", temp_dir());
  561. init_tests();
  562. if (verbose >= 3) {
  563. compile_verbose = true;
  564. print_test_depends();
  565. }
  566. if (verbose >= 4)
  567. tools_verbose = true;
  568. opt_parse(&argc, argv, opt_log_stderr_exit);
  569. if (!targeting)
  570. strmap_iterate(&tests, add_to_all, &top.node);
  571. if (argc == 1)
  572. dir = cwd;
  573. else
  574. dir = path_simplify(NULL, take(path_join(NULL, cwd, argv[1])));
  575. ccan_dir = find_ccan_dir(dir);
  576. if (!ccan_dir)
  577. errx(1, "Cannot find ccan/ base directory in %s", dir);
  578. config_header = read_config_header(ccan_dir, verbose > 1);
  579. /* We do this after read_config_header has set compiler & cflags */
  580. if (override_cflags)
  581. cflags = override_cflags;
  582. if (override_compiler)
  583. compiler = override_compiler;
  584. if (argc == 1)
  585. pass = test_module(&top.node, cwd, "",
  586. summary, deps_fail_ignore);
  587. else {
  588. for (i = 1; i < argc; i++) {
  589. dir = path_canon(NULL,
  590. take(path_join(NULL, cwd, argv[i])));
  591. if (!dir)
  592. err(1, "Cannot get canonical name of '%s'",
  593. argv[i]);
  594. prefix = path_join(NULL, ccan_dir, "ccan");
  595. prefix = path_rel(NULL, take(prefix), dir);
  596. prefix = tal_strcat(NULL, take(prefix), ": ");
  597. pass &= test_module(&top.node, dir, prefix, summary,
  598. deps_fail_ignore);
  599. reset_tests(&top.node);
  600. }
  601. }
  602. return pass ? 0 : 1;
  603. }