+static struct ccanlint *find_test(const char *key)
+{
+ struct ccanlint *i;
+
+ list_for_each(&compulsory_tests, i, list)
+ if (streq(i->key, key))
+ return i;
+
+ list_for_each(&normal_tests, i, list)
+ if (streq(i->key, key))
+ return i;
+
+ return NULL;
+}
+
+static void keep_test(const char *testname)
+{
+ struct ccanlint *i = find_test(testname);
+ if (!i)
+ errx(1, "No test %s to --keep", testname);
+ i->keep_results = true;
+}
+
+static void print_tests(struct list_head *tests, const char *type)
+{
+ struct ccanlint *i;
+
+ printf("%s tests:\n", type);
+ /* This makes them print in topological order. */
+ while ((i = get_next_test(tests)) != NULL) {
+ const struct dependent *d;
+ printf(" %-25s %s\n", i->key, i->name);
+ list_del(&i->list);
+ list_for_each(&i->dependencies, d, node)
+ d->dependent->num_depends--;
+ }
+}
+
+static void list_tests(void)
+{
+ print_tests(&compulsory_tests, "Compulsory");
+ print_tests(&normal_tests, "Normal");
+ exit(0);
+}
+